How to update specific row in Primefaces datatable

前端 未结 2 1271
南方客
南方客 2020-12-06 03:24

Primefaces 3.5, Mojarra 2.1.14. This is my PF datatable, it contains one non-editable boolean column named \'automatic\', and editable \'label\' column:



        
2条回答
  •  粉色の甜心
    2020-12-06 03:35

    I believe you can solve this without having to know the details of the ID of the component you wish to update. You can pass it as a parameter to the bean.

    First, bind the component you wish to update. You don't actual need a bean to which this component is bound to. You just need to define some value which you can use to identify this component later in your JSF. So in your case, you would do something like:

    
    

    Now access the component when you do your update. ie:

    
    

    Now you can update the component from your cellEdit event method without knowing the contents of the ID. ie:

    public void onEditLabel(CellEditEvent event, String idOfComponentToUpdate) {
    ...
    RequestContext.getCurrentInstance().update(idOfComponentToUpdate);
    ...
    

提交回复
热议问题