Question

I am using Prime-faces to create drop downs in <ui:repeat> tag. I'm trying to get values of each drop down separately.

The code I have tried:

<ui:repeat value="#{deviceTypeController.lstSensors}" var="sensor">
     <p:selectOneMenu value="#{deviceTypeController.selectedSensorBean}">
         <f:selectItem itemLabel="Select One"/>
         <f:selectItems value="#{deviceTypeController.lstSensors}" var="fields"
                        itemLabel="#{fields.sensor}" itemValue="#{fields}"/>
     </p:selectOneMenu>
</ui:repeat>

I have some strings in this list #{deviceTypeController.lstSensors}.

<ui:repeat> showing all those drop downs[In the List]

But how can I get each value from them?

Was it helpful?

Solution

You could additional parameter, lets say the parameter name is sensor_name and this value could be extracted from the method, selectedSensorBean. You also need an identifer in your sensor variable, ex: #{sensor.name}

<p:selectOneMenu value="#{deviceTypeController.selectedSensorBean}">
     <f:selectItem itemLabel="Select One"/>
     <f:param name="sensor_name" value="#{sensor.name}" /> 
     <f:selectItems value="#{deviceTypeController.lstSensors}" var="fields"
                    itemLabel="#{fields.sensor}" itemValue="#{fields}"/>
</p:selectOneMenu>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top