A link type control for switching between togglePanel facets. Target Panel is specified with "for" attribute. It can be located inside or outside the togglePanel. As the result of switching between facets previous facet is hidden and another one (specified with "switchToState" or panel "stateOrder" attributes) is shown.
Highly customizable look and feel
Can be located anywhere in a page layout
Switching is provided in the three modes
Server
Client
Ajax
Table 6.449. rich : toggleControl attributes
Attribute Name | Description |
---|---|
accesskey | Access key that, when pressed, transfers focus to this element |
action | MethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property |
actionListener | MethodBinding pointing at method accepting an ActionEvent with return type void |
ajaxSingle | if "true", submit ONLY one field/link, instead of all form controls |
binding | The attribute takes a value-binding expression for a component property of a backing bean |
bypassUpdates | If "true", after process validations phase skip updates of model beans an force render response. Can be used for validate components input |
data | Serialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax |
dir | Direction indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left) |
eventsQueue | Name of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move, etc.) |
focus | id of element to set focus after request completed on client side |
for | String, which contains id (in the format of a UIComponent.findComponent() call) of the target Toggle Panel. |
id | Every component may have a unique id that is automatically created if omitted |
ignoreDupResponses | Attribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now |
immediate | True means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase |
lang | Code describing the language used in the generated markup for this component |
limitToList | If "true", updates on client side ONLY elements from this 'reRender' property. if "false" (default) updates all rendered by ajax region components |
onbeforedomupdate | JavaScript code for call before DOM has been updated on client side |
onblur | JavaScript code executed when this element loses focus |
onclick | JavaScript code executed when a pointer button is clicked over this element |
oncomplete | JavaScript code for call after request completed on client side |
ondblclick | JavaScript code executed when a pointer button is double clicked over this element |
onfocus | JavaScript code executed when this element receives focus |
onkeydown | JavaScript code executed when a key is pressed down over this element |
onkeypress | JavaScript code executed when a key is pressed and released over this element |
onkeyup | JavaScript code executed when a key is released over this element |
onmousedown | JavaScript code executed when a pointer button is pressed down over this element |
onmousemove | JavaScript code executed when a pointer button is moved within this element |
onmouseout | JavaScript code executed when a pointer button is moved away from this element |
onmouseover | JavaScript code executed when a pointer button is moved onto this element |
onmouseup | JavaScript code executed when a pointer button is released over this element |
panelId | Attribute defines Id for corresponding panel |
process | Id['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection |
rendered | If "false", this component is not rendered |
requestDelay | Attribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already |
status | ID (in format of call UIComponent.findComponent()) of Request status component |
style | CSS style(s) to be applied when this component is rendered |
styleClass | Space-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup |
switchToState | Contains one of the facets names where target togglePanel is switched to |
tabindex | Position of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767 |
timeout | Response waiting time on a particular request. If a response is not received during this time, the request is aborted |
title | Advisory title information about markup elements generated for this component |
value | Initial value to set when rendered for the first time |
Table 6.450. Component identification parameters
Name | Value |
---|---|
component-type | org.richfaces.ToggleControl |
component-class | org.richfaces.component.html.HtmlToggleControl |
component-family | org.richfaces.ToggleControl |
renderer-type | org.richfaces.ToggleControlRenderer |
tag-class | org.richfaces.taglib.ToggleControlTag |
To create the simplest variant on a page use the following syntax:
Example:
...
<rich:toggleControl for="panel"/>
...
<rich:togglePanel id="panel" stateOrder="[facets order to be switched]">
<!--//Set of Facets-->
</rich:togglePanel>
...
Example:
import org.richfaces.component.html.HtmlToggleControl;
...
HtmlToggleControl myControl = new HtmlToggleControl();
...
As it was mentioned above, the control could be in any place in layout and linked to a switching panel that is managed with "for" attribute (in the "for" attribute the full component "id" is specified according to naming containers).
The togglePanel could be also switched from the side of the control instead of being strictly defined in "switchOrder" attribute of <rich:togglePanel>.
Example:
...
<rich:togglePanel id="panel" initialState="empty" switchType="client">
<f:facet name="first">
<h:panelGroup>
<rich:toggleControl for="helloForm:panel" value="Empty " switchToState="empty"/>
<rich:toggleControl for="helloForm:panel" value=" Second" switchToState="second"/>
...//Some Content
</h:panelGroup>
</f:facet>
<f:facet name="second">
<h:panelGroup>
<rich:toggleControl for="helloForm:panel" value="Empty " switchToState="empty"/>
<rich:toggleControl for="helloForm:panel" value=" first" switchToState="first"/>
...//Some Content
</h:panelGroup>
</f:facet>
<f:facet name="empty">
<h:panelGroup>
<rich:toggleControl for="helloForm:panel" value="first " switchToState="first"/>
<rich:toggleControl for="helloForm:panel" value=" second" switchToState="second"/>
</h:panelGroup>
</f:facet>
</rich:togglePanel>
...
In this example the switching is performed on facets specified in the "switchToState" attribute.
Information about the "process" attribute usage you can find here.
For skinnability implementation, the components use a style class redefinition method.
To redefine the appearance of all <rich:toggleControl> components at once, you should add to your style sheets style class used by a <rich:toggleControl> component.
Table 6.451. Classes names that define a component appearance
Class name | Description |
---|---|
rich-tglctrl | Defines styles for a toggle control |
In order to redefine styles for all <rich:toggleControl> components on a page using CSS, it's enough to create a class with the same name and define necessary properties in it.
To change styles of particular <rich:toggleControl> components define your own style class in the corresponding <rich:toggleControl> attributes.