In-cell editing with dataTable
The dataTable
component supports the in-cell editing feature for updating values within the table without navigating to another detail page.
How to do it...
In order to enable editing, first we need to set the editable
attribute of the table to true
. Each column definition that we need to be editable should contain the p:cellEditor
helper component that will contain two facets for rendering output components; one for visualizing the data and input components, and the other for getting input data from the user. The in-place editor palette, which is the p:rowEditor
component, also needs to be rendered as a column in order to activate editing.
<p:dataTable id="inCellEditing" var="car" value="#{dataTableController.cars}" rowKey="#{car.name}" editable="true">
<p:column headerText="Year">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.year}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car...