-1

This is my current structure for my p:selectOneMenu:

<h:form id="groupSelectionForm">
    <p:outputLabel value="Momentane Gruppe:" for="groupSelection" />

    <p:selectOneMenu id="groupSelection" value="#{foodPlanManagementBean.selectedGroup}" style="width:150px">
        <f:selectItem itemLabel="-" itemValue="#{null}"/>
        <f:selectItems value="#{foodPlanManagementBean.getGroups()}" var="group" itemLabel="#{group.name}" itemValue="#{group}"/>
        <p:ajax event="change"/>
    </p:selectOneMenu>
</h:form>

This results in a checkbox containing a default value given by the single selectItem as well as a few generated options from the selectItems.

However, the setter for the given field "selectedGroup" is only triggering for the selectItem.

The selectItems do not seem to do anything when they are being clicked.

Any ideas?

Sossenbinder
  • 4,852
  • 5
  • 35
  • 78
  • Your question is ambiguous and in its current state a duplicate of http://stackoverflow.com/q/2118656 First of all, do you see any conversion/validation error when you add ``? – BalusC May 10 '16 at 17:29

1 Answers1

0

try to define a listener in ajax component, ex:

<p:ajax id="seasonAjax" event="change" process="@this" listener="#{yourBean.yourMethod}"  update="elementThatYouWantToUpdate" />

process = this to process selected element.

In selectItems don't use get method use directly list elements(put get/set in your bean) ex:

<f:selectItems value="#{yourBean.yourList}" var="" itemLabel="" itemValue="" />

If this doesn't work test if you need to use a converter, if selectedGroup is a complex object or pass directly identification of selectGroup( selectedGroup.id)

I hope it helps.

ZaoTaoBao
  • 2,567
  • 2
  • 20
  • 28
  • Thanks, this somewhat helps already. At least I am now able to see my POST in the chrome console, also sending the right value, but there is nothing happening in the method I added to listener. Any idea what this could be? – Sossenbinder May 10 '16 at 15:55
  • have you get/set correctly written (selectedGroup) in your backing bean?SelectGroup is a complex object? or is an id? try to pass just id if is a complex object.. – ZaoTaoBao May 10 '16 at 16:07