Thursday, June 18, 2015

Select One Choice with Select Items Tag

If you need to implement select one choice based on alternative data sources (not based on ADF BC) - you shouldn't use af:forEach inside af:selectOneChoice component. Don't get confused with af:forEach tag, this tag is supposed to generate multiple components and not to iterate over a collection of objects and render HTML for each item. There could be cases, when choice list data will come duplicated, with af:forEach tag applied. I would suggest to construct array of SelectItem objects and return it to the f:selectItems tag to be rendered.

This is how proper af:selectOneChoice definition should look like. Array of items is being rendered in the choice list through f:selectItems tag:


Value property for f:selectItems can be entered manually or through the wizard, when creating af:selectOneChoice - this should point to the custom method, where array of SelectItem objects is constructed:


Custom method could read data from any source and construct array of SelectItem objects. This is the input for f:selectItems tag, it knows how to render a list of choice list items out of it:


This is how it looks on runtime - choice list is working fine, no need to use af:forEach:


Download sample application - CustomSelectListApp.zip.

1 comment:

Unknown said...

Hi Andrejus,

Thanks for the info. Actually I need to implement same thing for filter table dropdownlist. How can I achieve this?.

UseCase: when a dropdown is displayed its having multiple duplicated records I want to remove those from that list. but here the list is coming from #{vs.filterCriteria.ViewAttr1}. How can we create a list from these values.

Best Regards,
Raju Chetri