webuijsf
Tag hiddenField


Use the webuijsf:hiddenField tag to create a hidden field, which is present in the HTML, but not displayed to the user. Hidden fields are useful for saving state information.

HTML Elements and Layout

The hiddenField component renders an XHTML <input type="hidden"> element.

Configuring the webuijsf:hiddenField Tag

Use the value attribute to associate the component with a model object that represents the current value, by setting the attribute's value to a JavaServer Faces EL expression that corresponds to a property of a backing bean.

Facets

This component has no facets.

Theme Identifiers

This component does not use any style classes from the theme.

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({disabled: true}).

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:
  • disabled
  • id
  • name
  • value
submit(execute)
Use this function to asynchronously submit 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, the component on which the function has been invoked, is submitted.

Client Side JavaScript Events

When the component is manipulated client side, some functions may publish event topics for custom AJAX implementations to listen for. Using the Dojo event system, listen for the refresh event topic using:

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

    // Subscribe to refresh event.
    dojo.subscribe(webui.suntheme.widget.hiddenField.event.<eventname>.endTopic, processEvents, "update");


</webuijsf:script>

The following events are supported.

webui.suntheme.widget.hiddenField.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
webui.suntheme.widget.hiddenField.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
webui.suntheme.widget.hiddenField.event.submit.beginTopic Event topic published before asynchronously submitting 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
webui.suntheme.widget.hiddenField.event.submit.endTopic

Event topic published after asynchronously submitting the component. Supported properties include:

  • props - JSON object containing messages (if any) raised by the server.In particular, valdiation messages will be present here if validation failed

Examples

Example 1:

This example uses a backing bean FieldTest with a property counter. The property is an int but it is not necessary to specify a converter since the default JavaServer Faces converter will be used. The value of the hidden field may be updated through a JavaScript. The tag generates an HTML input element.

 <webuijsf:hiddenField id="counter" value="#{FieldTest.counter}"/>

Example 2: Update client-side hiddenField properties using the getProps and setProps functions

This example shows how to toggle the disabled state of a hidden field client side using the getProps and setProps functions. When the user clicks the radio button, the hidden field is either disabled or enabled.
<webuijsf:radioButton id="rb1" name="rb1" label="Toggle Field Disabled" onClick="toggleDisabled()"/>
<webuijsf:textField id="field1" value="#{MyBean.value}" />

<webuijsf:script>
function toggleDisabled() {
var domNode = document.getElementById("form1:field1"); // Get field
return domNode.setProps({disabled: !domNode.getProps().disabled}); // Toggle disabled state
}
</webuijsf:script>

Example 3: Asynchronously update hiddenField using refresh function

This example shows how to asynchronously update a text field using the refresh function. When the user clicks on the radio button, the text field is asynchronously updated with new data.
<webuijsf:radioButton id="rb1" name="rb1" label="Refresh Text Field" onClick="refreshField()"/>
<webuijsf:hiddenField id="field1" value="#{MyBean.value}" />
<webuijsf:script>
    function refreshField() {
        var domNode = document.getElementById("form1:field1"); // Get field
        return domNode.refresh(); // Asynchronously refresh field
    }
</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 4: Asynchronously update hiddenField using refresh function

This example shows how to asynchronously update a text field 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. When the user clicks on the radio button, the input value is updated server-side and the text field is updated client-side -- all without a page refresh.
<webuijsf:radioButton id="rb1" name="rb1" label="Refresh Text Field" onClick="refreshField()"/>
<webuijsf:hiddenField id="field1" value="#{MyBean.value}" /> // Field used to asynchronously update value.
<webuijsf:script>
    function
refreshField() {
        var domNode = document.getElementById("form1:field1"); // Get field
        return domNode.refresh("form1:rb1"); // Asynchronously refresh while submitting radio button 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.HiddenFieldTag
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 binding allows the Java bean that contains the UIComponent to manipulate the UIComponent, its properties, and its children.
htmlTemplatefalsefalsejava.lang.String Alternative HTML template to be used by this component.
textfalsefalsejava.lang.String

Literal value to be rendered in this hidden field. If this property is specified by a value binding expression, the corresponding value will be updated if validation succeeds.

disabledfalsefalsejava.lang.String

Flag indicating that the hidden field should not send its value to the server.

converterfalsefalsejava.lang.String Specifies 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).
immediatefalsefalsejava.lang.String Flag indicating that event handling for this component should be handled immediately (in Apply Request Values phase) rather than waiting until Invoke Application phase.
validatorExpressionfalsefalsejava.lang.String Used to specify a method in a backing bean to validate input to the component. The value must be a JavaServer Faces EL expression that resolves to a public method with return type void. The method must take three parameters:
  • a javax.faces.context.FacesContext
  • a javax.faces.component.UIComponent (the component whose data is to be validated)
  • a java.lang.Object containing the data to be validated.

The backing bean where the method is defined must implement java.io.Serializable or javax.faces.component.StateHolder.

The method is invoked during the Process Validations Phase.

renderedfalsefalsejava.lang.String Indicates 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.
valueChangeListenerExpressionfalsefalsejava.lang.String Specifies a method to handle a value-change event that is triggered when the user enters data in the input component. The attribute value must be a JavaServer Faces EL expression that resolves to a backing bean method. The method must take a single parameter of type javax.faces.event.ValueChangeEvent, and its return type must be void. The backing bean where the method is defined must implement java.io.Serializable or javax.faces.component.StateHolder.
idfalsetruejava.lang.StringNo Description

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.