webuijsf
Tag staticText


Use the webuijsf:staticText tag to display text that is not interactive in the rendered HTML page.  The text can be plain static text, or be formatted using parameters to insert variable text in the rendered HTML. The JSF core tag f:param can be used along with view beans to provide the variable data.

If there are one or more params, the component will convert the list of parameter values to an Object array, and call MessageFormat.format(), passing the value of the param of this component as the first argument, the value of the array of parameter values as the second argument, and render the result. See MessageFormat.format()for details.Otherwise, render the text of this component unmodified.

HTML Elements and Layout

The rendered HTML page includes a <span> element that contains the resulting text.  In the <span> element, the class and style attribute values are set to the values specified with the webuijsf:staticText tag's styleclass and style attributes.

Client Side Javascript Functions

When the component is rendered, a DOM object corresponding to the component is created. To manipulate the component on the client side, you may invoke functions on the DOM object. With reference to the DOM id, to disable the component, invoke document.getElementById(id).setProps({value: "My Text"}).

getProps() Use this function to get widget properties. Please see setProps() function for a list of supported properties.
refresh(execute)
Use this function to asynchronously refresh the component.
  • [optional] execute: Comma separated string containing a list of client ids against which the execute portion of the request processing lifecycle must be run. If omitted, no other components are executed.
setProps(props) Use this function to change any of the following supported properties:
  • className
  • dir
  • escape
  • id
  • lang
  • onClick
  • onDblClick
  • onMouseDown
  • onMouseMove
  • onMouseOut
  • onMouseOver
  • onMouseUp
  • style
  • title
  • value
  • visible
subscribe(topic, obj, func) Use this function to subscribe to an event topic.
  • topic: The event topic to subscribe to.
  • obj: The object in which a function will be invoked, or null for default scope.
  • func The name of a function in context, or a function reference to invoke when topic is published.

Client Side JavaScript Events

When the component is manipulated client side, some functions may publish event topics for custom AJAX implementations to listen for. For example, you can listen for the refresh event topic using:

<webuijsf:script>
    var processEvents = {                       
        update: function(props) {
            // Do something...
        }
    }

    // Subscribe to refresh event.
    var domNode = document.getElementById("form1:test1");
    domNode.subscribe(domNode.event.refresh.endTopic, processEvents, "update");


</webuijsf:script>

The following events are supported.

<Node>.event.refresh.beginTopic Event topic published before asynchronously refreshing the component. Supported properties include:
  • [optional] execute - list of the components to be executed along with this component
  • id - The client id to process the event for
<Node>.event.refresh.endTopic Event topic published after asynchronously refreshing the component. Supported properties include: See setProps() function.
  • props - JSON object containing properties of the component. See setProps() function for details on properties and their usage

Examples

Example 1: Render plain old text

<webuijsf:staticText id="statictext1" text="#{bean.someText}" />
<webuijsf:staticText id="statictext1" text="some text to display" />

Example 2: Use Params to format a whole line

      <webuijsf:staticText id="blah" text="At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.">
          <f:param id="b1" value="#{HyperlinkBean.myInt}"/>
          <f:param id="b2" value="#{HyperlinkBean.date}"/>
          <f:param id="b3" value="2 fools"/>                 
      </webuijsf:staticText>

The above will render:  "At 8:36:18 AM on Dec 13, 2004, there was 2 fools on planet 7."

Example 3: Update client-side text properties using the getProps and setProps functions

This example shows how to toggle the disabled state of text client side using the getProps and setProps functions. When the user clicks the radio button, the text is either hown or hidden.
<webuijsf:radioButton id="rb1" name="rb1" label="Toggle Text Visible" onClick="toggleVisible()"/>
<webuijsf:staticText id="text1" text="My Text" />

<webuijsf:script>
function toggleVisible() {
var domNode = document.getElementById("form1:text1"); // Get text
return domNode.setProps({visible: !domNode.getProps().visible}); // Toggle visible
}
</webuijsf:script>

Example 4: Asynchronously update text using refresh function

This example shows how to asynchronously update text using the refresh function. When the user clicks on the radio button, the text is asynchronously updated with new data.
<webuijsf:radioButton id="rb1" name="rb1" label="Refresh Button" onClick="refreshText()"/>
<webuijsf:staticText id="text1" text="#{MyBean.text}"/>
<webuijsf:script>
    function refreshText() {
        var domNode = document.getElementById("form1:text1"); // Get text
        return domNode.refresh(); // Asynchronously refresh text
    }
</webuijsf:script>

Note that the refresh function can optionally take a list of elements to execute. Thus, a comma-separated list of ids can be provided to update components server-side: refresh("form1:id1,form2:id2,..."). When no parameter is given, the refresh function acts as a reset. That is, the component will be redrawn using values set server-side, but not updated.

Example 5: Asynchronously update text using refresh function

This example shows how to asynchronously update text using the refresh function. The execute property of the refresh function is used to define the client id which is to be submitted and updated server-side. As the user types in the text field, the input value is updated server-side and the text is updated client-side -- all without a page refresh.
<webuijsf:staticText id="text1" text="#{MyBean.text}"/>
<webuijsf:textField id="field1" text="#{MyBean.text}" label="Change Text"
onKeyPress="setTimeout('refreshText();', 0);"/> // Field used to asynchronously update text.
<webuijsf:script>
    function
refreshText() {
        var domNode = document.getElementById("form1:text1"); // Get text
        return domNode.refresh("form1:field1"); // Asynchronously refresh while submitting field value
    }
</webuijsf:script>


Note that the refresh function can optionally take a list of elements to execute. Thus, a comma-separated list of ids can be provided to update components server-side: refresh("form1:id1,form2:id2,...")



Tag Information
Tag Classcom.sun.webui.jsf.component.StaticTextTag
TagExtraInfo ClassNone
Body ContentJSP
Display NameNone

Attributes
NameRequiredRequest-timeTypeDescription
bindingfalsefalsejava.lang.String A ValueExpression that resolves to the UIComponent that corresponds to this tag. This attribute allows the Java bean that contains the UIComponent to manipulate the UIComponent, its properties, and its children.
onMouseDownfalsefalsejava.lang.String

Scripting code executed when the user presses a mouse button while the mouse pointer is on the component.

toolTipfalsefalsejava.lang.String

Sets the value of the title attribute for the HTML element. The specified text will display as a tooltip if the mouse cursor hovers over the HTML element.

onDblClickfalsefalsejava.lang.String

Scripting code executed when a mouse double click occurs over this component.

converterfalsefalsejava.lang.String The converter attribute is used to specify a method to translate native property values to String and back for this component. The converter attribute value must be one of the following:
  • A JavaServer Faces EL expression that resolves to a backing bean or bean property that implements the javax.faces.converter.Converter interface; or
  • the ID of a registered converter (a String).
onMouseOutfalsefalsejava.lang.String

Scripting code executed when a mouse out movement occurs over this component.

renderedfalsefalsejava.lang.String Use the rendered attribute to indicate whether the HTML code for the component should be included in the rendered HTML page. If set to false, the rendered HTML page does not include the HTML for the component. If the component is not rendered, it is also not processed on any subsequent form submission.
escapefalsefalsejava.lang.String

Escape the html text so it won't be interpreted by the browser as HTML

idfalsetruejava.lang.StringNo Description
onMouseOverfalsefalsejava.lang.String

Scripting code executed when the user moves the mouse pointer into the boundary of this component.

htmlTemplatefalsefalsejava.lang.String Alternative HTML template to be used by this component.
onMouseMovefalsefalsejava.lang.String

Scripting code executed when the user moves the mouse pointer while over the component.

onMouseUpfalsefalsejava.lang.String

Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.

styleClassfalsefalsejava.lang.String

CSS style class(es) to be applied to the outermost HTML element when this component is rendered.

textfalsefalsejava.lang.String

The text to be displayed for this component.

stylefalsefalsejava.lang.String

CSS style(s) to be applied to the outermost HTML element when this component is rendered.

visiblefalsefalsejava.lang.String

Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, visible is set to true, so HTML for the component HTML is included and visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.

onClickfalsefalsejava.lang.String

Scripting code executed when a mouse click occurs over this component.


Variables
No Variables Defined.


Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.