select All checkbox in JSF without using Javascript

前端 未结 2 1461
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 07:45

I am trying to select/unselect all checkboxes in the datatable using a single checkbox. As I am trying to set it on the server, I am unable to do so. I have looked around fo

相关标签:
2条回答
  • 2020-12-16 08:26

    It's because the ValueChangeEvent occurs before the update model phase, so the value you change gets overwritten.
    Do this in the public void selectAllComponents(ValueChangeEvent event)

    if (event.getPhase() != PhaseId.INVOKE_APPLICATION) {
        event.setPhase(PhaseId.INVOKE_APPLICATON);
        event.queue();
     } else {
        //do your stuff here
     }
    
    0 讨论(0)
  • 2020-12-16 08:30

    Or just before your code add next line code in your original method

    selectAll = (Boolean) event.getNewValue();

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