0

I have a Primefaces 6.0 datatable with editable columns. The problem is, the first and second column is a p:selectOneMenu element und the second one needs to be updated on value change of the first. The data of the second is generated on basis of the selection value of the first list box. I have a valueChangeListener which works fine but the problem is, in the backing bean i don't know how to access/modify the second listbox to change its elements.

what is best practice to solve this issue?

<p:column headerText="Register">
    <p:cellEditor>
        <f:facet name="output">
            <h:outputText value="#{dfAdmin.getMainGroupLabel(df.group.mainGroup.id)}" />
        </f:facet>
        <f:facet name="input">
            <p:selectOneMenu id="mainGroup" value="#{df.group.mainGroup.id}"
                valueChangeListener="#{dfAdmin.mainGroupSelectOneListener}" style="width:150px">
                <p:ajax event="valueChange" immediate="true" process="@this" render=":form_df_datatable:group"/>
                <f:selectItem itemLabel="Register wählen" itemValue=""
                    noSelectionOption="true" />
                <f:selectItems
                    value="#{mainGroupService.getMappedGroups().entrySet()}" var="entry"
                    itemValue="#{entry.key}" itemLabel="#{entry.value}" />
            </p:selectOneMenu>
        </f:facet>
    </p:cellEditor>
</p:column>                 

<p:column headerText="Gruppe">
    <p:cellEditor>
        <f:facet name="output">
            <h:outputText value="#{dfAdmin.getGroupLabel(df.group.id)}" />
        </f:facet>
        <f:facet name="input">
            <p:selectOneMenu id="group" value="#{df.group.id}"
                style="width:150px">
                <f:selectItem itemLabel="Gruppe wählen" itemValue=""
                    noSelectionOption="true" />
                <f:selectItems
                    value="#{groupService.getMappedGroupsForMainGroup(df.group.mainGroup.id).entrySet()}" var="entry"
                    itemValue="#{entry.key}" itemLabel="#{entry.value}" />
            </p:selectOneMenu>
        </f:facet>
    </p:cellEditor>
</p:column>
hbacher
  • 1
  • 3
  • p:ajax doesn't have a render attribute, you need to use the update attribute instead. – lastresort Apr 26 '17 at 06:26
  • thx mate :-) it works now. – hbacher Apr 26 '17 at 09:25
  • Possible duplicate of [Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes](https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) – Kukeltje Nov 25 '17 at 16:48

0 Answers0