10.5. <rich:inplaceInput>
The
<rich:inplaceInput> component allows information to be entered in-line in blocks of text, improving readability of the text. Multiple input regions can be navigated with keyboard navigation. The component has three functional states: the view state, where the component displays its initial setting, such as "click to edit"; the edit state, where the user can input text; and the "changed" state, where the new value for the component has been confirmed but can be edited again if required.
10.5.1. Basic usage
Basic usage requires the
value attribute to point to the expression for the current value of the component. Validation and conversion rules for the JSF UIInput control apply as usual.
10.5.2. Interactivity options
When in the initial view state, the starting label can be set using the
defaultLabel attribute. Alternatively, if the initial value is already set through the value attribute, this is displayed instead.
Once the user has entered text, the label is stored in the model specified by the
value attribute. The use of the default label and value is shown in Example 10.7, “Default label and value”.
Example 10.7. Default label and value
<rich:inplaceInput value="#{bean.value}" defaultLabel="click to edit"/>
By default, the event to switch the component to the edit state is a single mouse click. This can be changed using the
editEvent attribute to specify a different event.
The user can confirm and save their input in multiple ways:
- By default, pressing the Enter key will confirm and save the input.
- If
showControls="true"is set, buttons for confirming or canceling are added to the component. - If
saveOnBlur="true"is set, the input is saved on the component's blur event.
Pressing the Esc key cancels editing in all cases.
10.5.3. JavaScript API
The
<rich:inplaceInput> component can be controlled through the JavaScript API. The JavaScript API provides the following functions:
getValue()- Get the current value of the input control.
setValue(newValue)- Set the value of the input control to the
newValuestring passed as a parameter. isEditState()- Returns
trueif the control is currently in the edit state, orfalseif the control is currently in the view state. isValueChanged()- Returns
trueif the control's value has been changed from the default. save()- Saves the current item as the control's value.
cancel()- Cancel editing the value.
getInput()- Return the DOM element for the input.
10.5.4. Reference data
component-type:org.richfaces.InplaceInputcomponent-class:org.richfaces.component.UIInplaceInputcomponent-family:org.richfaces.InplaceInputrenderer-type:org.richfaces.InplaceInputRenderer
10.5.5. Style classes and skin parameters
Table 10.5. Style classes (selectors) and corresponding skin parameters
| Class (selector) | Skin Parameters | Mapped CSS properties |
|---|---|---|
| editorBackgroundColor
|
background-color
|
generalTextColor
|
border-bottom-color
| |
| No skin parameters. | |
| No skin parameters. | |
| No skin parameters. | |
| editBackgroundColor
|
background-color, border-bottom-color
|
generalTextColor
|
color
| |
generalFamilyFont
|
font-family
| |
generalSizeFont
|
font-size
| |
| generalTextColor
|
color
|
generalSizeFont
|
font-size
| |
| No skin parameters. | |
| tabBackgroundColor
|
background-color
|
panelBorderColor
|
border-color
| |
| tabBackgroundColor
|
background-color
|
panelBorderColor
|
border-color
| |
| No skin parameters. | |
| No skin parameters. | |
| No skin parameters. | |
| No skin parameters. | |