Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.11.6.  < rich:inplaceInput > available since 3.2.0

Table 6.426. rich : inplaceInput attributes

Attribute Name Description
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
cancelControlIconDefines custom cancel icon
changedClassAssigns one or more space-separated CSS class names to the component in the changed state
changedHoverClassAssigns one or more space-separated CSS class names to the component hovered in the changed state
controlClassAssigns one or more space-separated CSS class names to the component controls
controlHoverClassAssigns one or more space-separated CSS class names to the component control hovered
controlPressedClassAssigns one or more space-separated CSS class names to the component control pressed
controlsHorizontalPositionPositions the controls horizontally. Possible values are "left", "center", "right". Default value is "right".
controlsVerticalPositionPositions the controls vertically. Possible values are "bottom","center" and "top". Default value is "center"
converter JSF: Id 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
editClassAssigns one or more space-separated CSS class names to the component in the edit state
editEventProvides an option to assign an JavaScript action that initiates the change of the state. Default value is "onclick".
id JSF: Every 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
inputWidthSets width of the input field
labelA localized user presentable name for this component.
layoutDefines how the component is displayed in the layout. Possible values are "block", "inline". Default value is "inline".
maxInputWidthSets the maximum width of the input field. Default value is "500px".
maxlengthHTML: Specifies the maximum number of digits that could be entered into the input field. The maximum number is unlimited by default.
minInputWidthSets the minimum width of the input field. Default value is "40px".
onblur DHTML: The client-side script method to be called when the component loses the focus
onchange DHTML: The client-side script method to be called when the component value is changed
onclick DHTML: The client-side script method to be called when the element is clicked
ondblclick DHTML: The client-side script method to be called when the element is double-clicked
oneditactivatedThe client-side script method to be called when the component edit state is activated
oneditactivationThe client-side script method to be called before the component edit state is activated
onfocus DHTML: The client-side script method to be called when the component gets the focus
oninputclickThe client-side script method to be called when the input field is clicked
oninputdblclickThe client-side script method to be called when the input field is double-clicked
oninputkeydownThe client-side script method to be called when a key is pressed down in the input field
oninputkeypressThe client-side script method to be called when a key is pressed and released in the input field
oninputkeyupThe client-side script method to be called when a key is released in the input field
oninputmousedownThe client-side script method to be called when a mouse button is pressed down in the input field
oninputmousemoveThe client-side script method to be called when a pointer is moved within the input field
oninputmouseoutThe client-side script method to be called when a pointer is moved away from the input field
oninputmouseoverThe client-side script method to be called when a pointer is moved onto the input field
oninputmouseupThe client-side script method to be called when a mouse button is released in the input field
onkeydown DHTML: The client-side script method to be called when a key is pressed down over the element
onkeypress DHTML: The client-side script method to be called when a key is pressed over the element and released
onkeyup DHTML: The client-side script method to be called when a key is released
onmousedown DHTML: The client-side script method to be called when a mouse button is pressed down over the element
onmousemove DHTML: The client-side script method to be called when a pointer is moved within the element
onmouseout DHTML: The client-side script method to be called when a pointer is moved away from the element
onmouseover DHTML: The client-side script method to be called when a pointer is moved onto the element
onmouseup DHTML: The client-side script method to be called when a mouse button is released
onselect DHTML: The client-side script method to be called when some text is selected in the input field
onviewactivatedThe client-side script method to be called when the component view state is activated
onviewactivationThe client-side script method to be called before the component view state is activated
rendered JSF: If "false", this component is not rendered
required JSF: If "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute which defines text of validation message to show, if a required field is missing
saveControlIconDefines custom save icon
selectOnEditMakes the input field select when switched to edit state. Default value is "false"
showControlsServes to display "save" and "cancel" controls. Default value is "false".
styleClass JSF: Assigns one or more space-separated CSS class names to the component. Corresponds to the HTML "class" attribute.
tabindexHTML: Serves to define the tabbing order
validator JSF: MethodBinding 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
value JSF: The current value of this component
valueChangeListener JSF: Listener for value changes
viewClassAssigns one or more space-separated CSS class names to the component in the view state
viewHoverClassAssigns one or more space-separated CSS class names to the component hovered in the view state


The <rich:inplaceInput> component was designed to facilitate displaying and inputting(editing) some data.

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

The component has three functional states:

The "editEvent" attribute provides an option to assign a JavaScript action to initiate the change of the state from view/changed to edit. The default value is "onclick".

Example:


...
<rich:inplaceInput value="#{bean.value}" editEvent="ondblclick"/> 
... 

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

Example:


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

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.

Using the boolean "selectOnEdit" attribute set to true, the text in the input field will be selected when the change from view/changed state to edit occurs.

This is the result:


If the <rich:inplaceInput> loses focus, input data is saved automatically and the component displays a new value. Additionally, the data is saved when "Enter" is pressed. Nevertheless, you can use the "showControls" attribute, which makes "Save" and "Cancel" buttons appear next to the input field. If the controls are used, data is not saved automatically when the form loses focus: user has to confirm that he/she wants to save/discard the data explicitly. In both cases(with controls or without them) the input data can be discarded by pressing "Esc" key.

Example:


...
<rich:inplaceInput value="#{bean.value}" showControls="true"/>
... 

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", "center" and "top" definitions

Example:


...
<rich:inplaceInput value="#{bean.value}" showControls="true" controlsVerticalPosition="bottom" controlsHorizontalPosition="left"/>
... 

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.

Example:


...
<rich:inplaceInput defaultLabel="Click here to edit" showControls="true" controlsHorizontalPosition="left" controlsVerticalPosition="bottom" id="inplaceInput">
    <f:facet name="controls">
        <h:commandButton value="Save" onclick="#{rich:component('inplaceInput')}.save();" type="button" />
        <h:commandButton value="Cancel" onclick="#{rich:component('inplaceInput')}.cancel();" type="button" />
    </f:facet>
</rich:inplaceInput>
... 

This is the result:


Note:

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

Redefinition of the "save" and "cancel" icons can be performed using "saveControlIcon" and "cancelControlIcon" attributes. You need to define the path to where your images are located.

Example:


...
<rich:inplaceInput value="#{bean.value}" defaultLabel='click to edit'
    showControls="true"
    controlsHorizontalPosition="left"
    controlsVerticalPosition="top"
    saveControlIcon="/images/cancel.gif"
    cancelControlIcon="/images/save.gif"/> 
    ... 

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

The <rich:inplaceInput> component supports standard "tabindex" attribute. When the component gets focus the edit mode is activated.

The "inputWidth" , "minInputWidth" , "maxInputWidth" attributes are provided to specify the width, minimal width and maximal width for the input element respectively.


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







In order to redefine styles for all <rich:inplaceInput> 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-field {
      
font-style: italic;
}                       
...

This is the result:


In the shown example the font in edit state is changed to bold.

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

Example:


...
.myClass {
    
color:  #008cca;
}
...

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

Example:


<rich:inplaceInput value="click to edit" styleClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font color of the text on the component was changed.

On the component Live Demo page you can see the example of <rich:inplaceIput> usage and sources for the given example.