1
votes

I want to get the row as object in My managed bean with its updated properties. I used the PrimeFaces showcase example DataTable - InCell Editing. I don't understand how to get the edited values to update the database. How can I achieve this?

1

1 Answers

9
votes

Just add a save button to the same form. E.g.

<p:commandButton value="Save" action="#{bean.save}" />

with

public void save() {
    someService.save(someList);
}

Or, if you want to perform the save on every individual row edit event, then add a <p:ajax event="rowEdit"> to the <p:dataTable>. E.g.

<p:dataTable ...>
    ...
    <p:column>
        <p:rowEditor />  
    </p:column>  
    <p:ajax event="rowEdit" listener="#{bean.save}" />
</p:dataTable>

with

public void save(RowEditEvent event) {
    someService.save((SomeItem) event.getObject());
}