General Behaviour
Both the encode and decode behavior require the ability to get the id/name for a hidden field whose value is set by the JavaScript form submit. This name must be constructed as follows:
Get the clientId for the form of which this component is a child.
AppendNamingContainer.SEPARATOR_CHAR
.
Append a constant string that is the same for all command link components in the tree.
In the following text, this String is called hiddenFieldName.
Decode Behavior
Obtain the "clientId" property of the component. Obtain theMap
from the "requestParameterMap" property of theExternalContext
. Derive hiddenFieldName as above.
Get the entry in the Map
under the key that is the
hiddenFieldName. If the there is no entry, or the entry is the
empty String, or the entry is not equal to the value of the
"clientId" property, return immediately. If there is an entry,
and its value is equal to the value of the "clientId" property,
create a new javax.faces.event.ActionEvent
instance
around the component and call queueActionEvent()
on
the component, passing the event.
Encode Behavior
Render "#" as the value of the "href" attribute. Render the current value of the component as the link text if it is specified. Render javascript that is functionally equivalent to the following as the value of the "onclick" attribute:
document.forms['CLIENT_ID']['hiddenFieldName'].value='CLIENT_ID';
document.forms['CLIENT_ID']['PARAM1_NAME'].value='PARAM1_VALUE';
document.forms['CLIENT_ID']['PARAM2_NAME'].value='PARAM2_VALUE';
return false;
document.forms['CLIENT_ID'].submit()" where hiddenFieldName isas described above, CLIENT_ID is the clientId of the UICommand component, PARAM*_NAME and PARAM*_VALUE are the names and values, respectively, of any nested UIParameter children. The name and the value must be URLEncoded. If the "styleClass" attribute is specified, render its value as the value of the "class" attribute. Render any non-UIParameter children as normal inside of the "a" element. These will appear as the link text. Allow the form renderer to output a single "input" element (for the entire page, regardless of how many command link components are in the page) of "type" "hidden" whose "name" is the value of hiddenFieldName, and which must not have a "value" attribute. Multiple occurrences of command link components in the tree should not cause multiple hiddenFieldName hidden fields. Allow the form renderer to output an "input" element of "type" "hidden" for each of the nested UIParameter children, taking the name property (but not the value) from each one in turn.
Decode Behavior
Obtain the Map
from the "requestParameterMap"
property of the ExternalContext
. If the value in theMap
for the value of the "clientId" property of the
component is null
, create a String by concatenating
the value of the "clientId" property of the component with the
String ".x" (without the quotes). Create another String in the
same manner, but concatenate ".y" (without the quotes). Ifnull
is the value in the Map
for both
Strings, return from decode()
. If the value in theMap
for the value of the "clientId" property of the
component is not null
, get the value of the "type"
attribute, and convert it to lower case. If the result is equal
to the String "reset" (without the quotes), return fromdecode()
. Otherwise, create ajavax.faces.event.ActionEvent
around the component,
and pass it to the queueEvent()
method of the
component, which must be an instance ofUICommand
.
Encode Behavior
Render the clientId of the component as the value of the "name" attribute. Render the current value of the component as the value of the "value" attribute. If the "styleClass" attribute is specified, render its value as the value of the "class" attribute.
See the "Decode Behavior for UISelectOne Components" section.
Encode Behavior
Render an HTML "select" element. Render the clientId of the
component as the value of the "name" attribute. If the
"styleClass" attribute is specified, render its value as the value
of the "class" attribute on the "select" element. If the component
to be rendered is a UISelectMany, render "true" as the value of
the "multiple" attribute. Use the number of items as the value of
the "size" attribute. See the "Rendering
the option elements" specification forListboxRenderer
for more detail on how to render the "option" elements in this renderer.