Building Select Choice with an ArrayList

This blog is about building a select once choice using an ArrayList.
In few scenarios , we have to show the list of values returned by a web service , this solution can be used  for such cases.1)Create a bean with an arraylist and code to populate this arraylist.

2)By default , While dropping a select one choice  f:selectItems is created and it’s value points to ListBinding.
For our use case  , we will replace   f:selectItems  with  af:forEach and map it’s value to appropriate arraylist.

3)Run the page.

2 thoughts on “Building Select Choice with an ArrayList

  1. Tarun November 7, 2012 at 9:40 pm Reply

    Perhaps, giving an example of a scenario where arraylist would be required to be used as a source of selectOneChoice will be useful. How would I achieve ID – Meaning feature, i would want to store ID value in DB and display Meaning in list?

    • sai_explorer November 7, 2012 at 10:52 pm Reply

      In few scenarios , we have to show the list of values returned by a web service , this solution can be used for such cases. “How would I achieve ID – Meaning feature, i would want to store ID value in DB and display Meaning in list?”This will be achieved by using the Label and value properties of af:selectItem appropriately.

Leave a comment