سؤال

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