JBoss.orgCommunity Documentation

6.61.  < rich:inplaceSelect >

The <rich:inplaceSelect> is used for creation select based inputs: it shows the value as text in one state and enables editing the value, providing a list of options in another state


Table 6.285. rich : inplaceSelect attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
cancelControlIconDefines custom cancel icon
changedClassCSS style class for changed state
controlClassCSS style class for controls
controlHoverClassCSS style class for hovered control
controlPressClassCSS style class for controls pressed
controlsHorizontalPositionThe attribute positions the controls horizontally. Possible values are "right","center","left". Default value is "right".
controlsVerticalPositionThe attribute positions the controls vertically. Possible values are "bottom","top"
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
defaultLabelThe attribute is used to display text while value is undefined
editClassCSS style class for edit state
editEventThe attribute provides an option to assign an JavaScript action that initiates the change of the state. Default value is "onclick".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
layoutDefines how the component is displayed in the layout. Possible values are "block", "inline". Default value is "inline".
listHeightThe attribute defines the height of option list. Default value is "200px".
listWidthThe attribute defines the width of option list. Default value is "200px".
maxSelectWidthSets the maximum width of the select element. Default value is "200px".
minSelectWidthSets the minimum width of the select element. Default value is "100px".
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
oneditactivatedThe attributes provide a possibility to assign JavaScript to be executed when edit state is activated
oneditactivationThe attributes provide a possibility to assign JavaScript on edit state activation
onfocusHTML: script expression; the element got the focus
oninputblurHTML: script expression; the element lost the focus
oninputclickHTML: a script expression; a pointer button is clicked
oninputdblclickHTML: a script expression; a pointer button is double-clicked
oninputfocusHTML: script expression; the element got the focus
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
oninputmousedownHTML: script expression; a pointer button is pressed down
oninputmousemoveHTML: a script expression; a pointer is moved within
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputmouseupHTML: script expression; a pointer button is released
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; the onselect event occurs when you select some menu item
onviewactivatedThe attributes provide a possibility to assign JavaScript to be executed when view state is activated
onviewactivationThe attributes provide a possibility to assign JavaScript on view state activation
openOnEditThe attribute opens the list once edit activated. Default value is "true".
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
saveControlIconDefines custom save icon
selectWidthSets width of the select element
showControlsThe attribute serves to display "save" and "cancel" controls. Default value is "false".
showValueInViewIf true show the SelectItem labels in the InplaceSelect's pull-down list but display the value in the field in view mode once an item is selected
styleClassCorresponds to the HTML class attribute
tabindexThe attribute serves to define the tabbing order
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
viewClassStyle class for view state
viewHoverClassCSS style class for hovered text in view state

Table 6.286. Component identification parameters

NameValue
component-typeorg.richfaces.InplaceSelect
component-classorg.richfaces.component.html.HtmlInplaceSelect
component-familyorg.richfaces.InplaceSelect
renderer-typeorg.richfaces.renderkit.InplaceSelectRenderer
tag-classorg.richfaces.taglib.InplaceSelectTag

Here is a simple example of how the component can be used on a page:

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}">
    <f:selectItem itemValue="1" itemLabel="factory"/>
</rich:inplaceSelect>
...

Example:

import org.richfaces.component.html.inplaceSelect;

... 
HtmlInpaceSelect myInplaceSelect = new InplaceSelect();
...

The "value" attribute is a value-binding expression for the current value of the component.

The <rich:inplaceSelect> component has three functional states:

You can form the list of the options using <f:selectItem/> and <f:selectItems/> facets.

Please, see the example below.

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" defaultLabel="click to edit">
    <f:selectItems  value="#{bean.selectItems}"/>
    <f:selectItem itemValue="1" itemLabel="factory"/>
    <f:selectItem itemValue="2" itemLabel="newspaper"/>
</rich:inplaceSelect>
...

In the example above the value of the selected item is available via "value" attribute.

The "editEvent" attribute provides an option to assign an JavaScript action that initiates the change of the state from view to edit. The default value is "onclick".

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" defaultLabel="Double Click to edit" editEvent="ondblclick">
    <f:selectItems value="#{demo.selectItems}" />
</rich:inplaceSelect>
...

The <rich:inplaceSelect> component provides specific event attributes:

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" oneditactivation="if (!confirm('Are you sure you want to change the value?')){return false;}">
    <f:selectItems value="#{demo.selectItems}" />
</rich:inplaceSelect>
... 

The given code illustrates how "oneditactivation" attribute works, namely when the state is being changed from view to edit, a confirmation window with a message "Are you sure you want to change value?" comes up.

To prevent opening the drop-down list by default, once edit state is activated, set the "openOnEdit" attribute to "false". The default value is "true".

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" showControls="true" openOnEdit="false">
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
...

This is the result:


Nowever, if you want to confirm the data saving explicitly you can use the "showControls" attribute, which makes "Save" and "Cancel" buttons (displayed as icons) appear next to the input field. Edit state can be deactivated by pressing "Esc" key. An option in the drop-drown list can be also selected by pressing "Enter".

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" showControls="true">
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
...

This is the result:


You can also position the controls relatively to the input field, by means of

  • The "controlsHorizontalPosition" attribute with "left", "right" and "center" definitions

  • The "controlsVerticalPosition " attribute with "bottom" and "top" definitions

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" controlsHorizontalPosition="left" controlsVerticalPosition="center" showControls="true">
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
... 

This is the result:


It is also possible to use "controls" facet in order to replace the default controls with facets content. See the example below.

Please, see the example.

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" showControls="true">
    <f:facet name="controls">
        <button onclick="#{rich:component('inplaceSelect')}.save();" type="button">Save</button>
        <button onclick="#{rich:component('inplaceSelect')}.cancel();" type="button">Cancel</button> 
    </f:facet>  
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
... 

This is the result:


Note:

The "controls" facet also implies using "showControls" attribute and it has to be defined as "true".

The <rich:inplaceSelect> component could be rendered with <span> or <div> elements to display its value. In order to change default <span> output, use the "layout" attribute with "block" value.

The <rich:inplaceSelect> component supports standard "tabindex" attribute. When the component gets focus the edit mode is activated and drop-down list is opened.

The "selectWidth" , "minSelectWidth" and "maxSelectWidth" attributes are provided to specify the width, minimal width and maximal width for the input element respectively.

In order to specify the height and width parameters for the list items of the component, you can use "listHeight" and " listWidth" attributes.



For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all <rich:inplaceSelect> components at once:







On the screenshot there are classes names that define styles for component elements.








In order to redefine styles for all <rich:inplaceSelect> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-inplace-select-list-decoration{
    
background-color: #ecf4fe;
}                      
   
...

This is the result:


In the shown example the background color for list is changed.

It's aslo possible to change styles of a particular <rich:inplaceSelect> component. In this case you should create own style classes and use them in corresponding <rich:inplaceSelect> styleClass attributes. An example is placed below:

Example:


...
.myClass {
    
background-color:#bed6f8;
    
font-style:italic;}
...

The "viewClass" attribute for <rich:inplaceSelect> is defined as it's shown in the example below:

Example:


<rich:inplaceSelect value="click to edit" viewClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style and background color in view state is changed.

Here you can see the example of <rich:inplaceSelect> usage and sources for the given example.