This post talks about a common development requirement
while using shuttle component sometimes we need to show some values on the selected side of af:selectManyShuttle , so to do this normally we use a custom shuttle component that is populated from managed bean code.
but when I have all data in a view object so why should I iterate viewObject to get all data in the managed bean and then set some values in an ArrayList to populate selected shuttle values.
it is time-consuming and requires a lot of coding, so for the viewObject based shuttle, we can do it in an efficient way.
- In this example I’m using Departments table of HR schema to populate af:selectManyShuttle, I think you all know how to create a shuttle in ADF
- So next is to populate selected shuttle values on some event, created a fusion web application using Departments table
- It’s time to drop Departments ViewObject on the page as shuttle component
- Suppose on a button click I want to set selected values in the shuttle, so I have created an actionEvent for the button in the managed bean and component binding of af:selectManyShuttle, so basic structure of the page is like this
- See the code of actionEvent , create an arrayList and add all values in it that you want to set as selected values and then just set the value in shuttle using binding
- Now run this page and test your shuttle component
Cheers- Happy Coding
- But this method works only when you have to set values on some action or other event after page load, because before page load , binding of shuttle component will not be accessible
- So if you have a requirement of setting selected values on page load then you must use a list defined in the managed bean and bind it to value property of shuttle component, value property denotes selected values of the shuttle
- And just write same code on getter of List, in this case selected values in shuttle are populated on page load
You can use both methods as per your requirement 🙂
Sample ADF Application- Download
An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF