Pregunta

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?

¿Fue útil?

Solución

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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top