The selectManyShuttle provides a mechanism for selecting multiple values from a list of values by allowing the user to move items between two lists. SelectManyShuttle
Use-Case:
The mapping between two entities should be persisted in a third database entity.
Say, there are three tables in an application, EMP, ROLES & EMP_ROLES. The EMP table is shown as a form layout allowing the user to navigate between the records, create a new record, update an existing record & commit all the changes. The SelectManyShuttle component is used to display all the ROLES like Manager, President etc. For an EMP record, the user can select multiple roles and shuttle them to the right.
When a user shuttle any Role to the right for an EMP record, an entry is made in EMP_ROLES Table and vice versa. The EMP_ROLES table contains all the ROLES selected for an EMP record. And while navigating between the EMP records, the corresponding ROLES saved in the EMP_ROLES db table are displayed as selected.
The UI looks like:
The UI looks like:
Steps implemented are:
1. Create a Fusion Web Application using jdeveloper.
2. Create all the required Business Components (EO, VO,VLink AM) for the above data model.
3. Don't forget to create a view link between EmpVO and EmpRolesVO, which will be used to display the pre-selected roles for an EMP record. The data model will be as shown:
3. Don't forget to create a view link between EmpVO and EmpRolesVO, which will be used to display the pre-selected roles for an EMP record. The data model will be as shown:
4. Drag and drop the EmpVO as a form layout with navigations.
5. Drag SelectManyShuttle UI Component and bind the value property of it to a managed bean property, which evaluates the values to be displayed as selected for an EMP record as shown:where getSelectedRoles method is:
6. When any Role is shuttle to the right, first it is saved in a pageFlowScope variable, then it is processed in the commit method as shown:
7. When user navigates between the records, getSelectedRoles() method is called, which will fetch the ROLES for an EMP record and then display them as pre-selected in SelectManyShuttle component. Partial triggers is set on the SelectManyShuttle component wrt to the navigation buttons as shown:
Sample Workspace:
Download the sample work space from here.
Hey its very useful thanks a lot ... you made my day :)
ReplyDeletewaiting for your interesting posts
that mean: we will insert into data EMP table and EMP_ROLES table?
ReplyDeleteI mean, insert into two table ?
Phai,
DeleteYes we will insert data into EMP and EMP_ROLES table if we are creating a new Employee record.
Thanks,
Umesh
Thanks for respons. So, in database: you have two table : Emp and EmpRolse.. right? And then you created a new association between the two EO (EmpEO and EmpRolesEO)...The problem is i don't know Where is RoleVO come from. I see on your project contains: two Entitty and Three ViewObject///
DeletePhai,
DeleteRoleVO is displayed as SelectManyShuttle component to select roles for an employee. In your case, StudentVO is same as RoleVO.
Hope it helps.
Thanks,
i did do like same your coding but it's not working....
ReplyDeletePhai,
DeleteIn your case, Class will be inserted into db using ClassEO which is shown as a form. So once you click on commit, the data you enter into Class Id and Class Name is automatically persisted into db. For ClassStudent record, please see the commit method code mentioned in point#6.
If you still have any issues with it, please let me know.
Thanks,
Umesh
How about to edit Emp_Role?
ReplyDeleteWhen selected Emp to Edit...we have to select * Role for Emp, right?
If I understand your scenario correctly, you want to change the roles assigned to an employee using selectManyShuttle component.
Deletei.e say for an employee ABC, if roles are saved as President and Manager in the db and now you want to edit them, i,e you want to give the employee ABC, different roles as Director, Vice President etc.
In that case, it is already implemented. In commit method, I am removing all the selected roles before inserting into emp_roles table. Please have a look at it.
If above use case, does not satisfy your requirement, please explain your use case in detail.
It is really helpful
ReplyDeleteThanks
Dennis.k
Thanks Dennis.
Deletethanks Umesh so helpful example, I cannot download sample code, please send it to my mail: prowael@yahoo.com
ReplyDeletePlease check now. I uploaded the workspace at a different location.
DeleteHi ,
ReplyDeleteI fail in binding operations.Can you please help me ?
I create view objects StudentVO and StudentLessonsVO.But I can not binding them in shuttle object.Please help me
I have three tables 1-Users(UserID,Name) 2- Roles(RoleId,Name) 3-User Roles(ID(PK) , UserId, UserName)
ReplyDeleteand I've done the same think like the example you posted but it giving me null pointer exception IDK why.