Book Image

Primefaces Cookbook Second Edition

Book Image

Primefaces Cookbook Second Edition

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

In-cell editing with dataTable


The dataTable component supports the in-cell editing feature to update values within the table without navigating to another 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 to render output components—one to visualize the data for the user and the other to get input data from the user. The in-place editor palette, which is the <p:rowEditor> component, also needs to be rendered in a column of dataTable in order to activate editing with user interaction. Here's the code that encapsulates the discussion in this paragraph:

<p:dataTable id="inCellEditing" var="car"
  value="#{dataTableBean.cars}" rowKey="#{car.name}"
  editable="true">
  <p:column headerText="Year">
    <p:cellEditor>
    <f:facet name="output">
      <h:outputText value...