cell or row update inside PF subTable

前端 未结 1 1372
轮回少年
轮回少年 2021-01-26 17:15

I have not many experiences with JSF. I have trouble to update only the cell specific to the dynamic response column inside a subtable with

1条回答
  •  长发绾君心
    2021-01-26 17:19

    Extracted from this @BalusC answer:

    However, since Mojarra 2.2.5 the started to support it (it simply stopped validating it; thus you would never face the in the question mentioned exception anymore; another enhancement fix is planned for that later).

    This only doesn't work yet in current MyFaces 2.2.7 and PrimeFaces 5.2 versions. The support might come in the future versions. In the meanwhile, your best bet is to update the iterating component itself, or a parent in case it doesn't render HTML, like .

    I checked it in Mojarra 2.2.11 with success. If you are allowed to update all the questions each time user clicks an answer then use:

    I hope this will be added in PF 5.3!

    EDIT:

    I will clarify. You have two alternatives:

    1. Use PF 5.2 and refresh all the table instead of only the current row field, if your requisites allow it. This is possible using .

    2. Use Mojarra 2.2.5+, so instead of using p:dataTable and p:subTable you should to manually build an iterative structure using only JSF standard components such as h:dataTable or ui:repeat. I tried this code with success. Observe that I can refer to a row element from the command component. The page:

      
          
              

      The backing bean:

      @Named
      @ViewScoped
      public class yourBean implements Serializable{
      
          private static final long serialVersionUID = 1L;
      
          private List lista = new ArrayList<>(); 
          public List getLista() {
              return lista;
          }
      
          public void updateSecond(){
              this.lista.set(1, 9999);
          }
      
          @PostConstruct
          public void populateModel(){    
              lista = Arrays.asList(1,2,3,4,5,6,7,8,9);   
          }       
      }
      

    0 讨论(0)
提交回复
热议问题