jsfprimefacesselectonebutton

I can't update my components when I change the state of selectOneButton component


I'm using primefaces to implement my web site and I'm facing an issue.
I've used selectOneButton component and depending on which button is selected I want to show a specific datatable. So when I click the button1 I want to show table1, and table2 when I click the button2.

This is the code I am using:

<p:selectOneButton 
    value="#{myBean.dataTableType}"
    valueChangeListener="#{myBean.dataTableTypeChange}">
    <f:selectItems value="#{myBean.dataTableTypes}"
        var="type"
        itemLabel="#{msg['datatable.type.'.concat(type)]}"
        itemValue="#{type}" />
    <p:ajax update="table1 table2"/>
</p:selectOneButton>

With this code, I'm unable to reach what I want :(


Solution

  • You should declare an attribute process for ajax with value @this. This attribute say to selectOneButton to set value into bean when will happen some event for selectOneButtton. And you will have an actual value for datatable type.

    Now you don't have it. And if you have a condition for example:

    <ui:fragment rendered="#{myBean.dataTableType eq FirstTable}">
        <p:datatable id="first_table">
            ...
        </p:datatable>
    </ui:framgent>
    

    Condition return false..