Assume that I'm using this component as following:

<tr:selectOneChoice label="Sports" required="#{true}" showRequired="#{true}">
 <f:selectItem itemLabel="Swimming" itemValue="1" />
 <f:selectItem itemLabel="Football" itemValue="2" />
 <f:selectItem itemLabel="Soccer" itemValue="3" />
 <f:selectItem itemLabel="Running" itemValue="4" />
  <f:selectItem itemLabel="Sailing" itemValue="5" />
    <f:facet name="help">
     <tr:outputText value="Please select" />
   </f:facet>     
</tr:selectOneChoice>

Is it possible to add dynamically new item to the list after some event trigger from the server?

I'm mean let's say the user has select some item and then, before submit an event was fire from the server which should change the selected item to some other item.

Thanks!

有帮助吗?

解决方案

Yes. this is possible but you have to define a list which is mapped in backing bean like:

<tr:selectOneChoice label="Sports" required="#{true}" showRequired="#{true}">   
    <f:selectItems value="#{backingBean.values}" />    
</tr:selectOneChoice>

Notice the difference here f:selectItems is being used instead of f:selectItem

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top