Pages

Friday, May 25, 2012

Implementation of SelectManyCheckBox component

The selectManyCheckbox component creates a component which allows the user to select many values from a series of checkboxes. SelectManyCheckBox.

It is quite similar to my earlier post on SelectManyListBox component. But here the use case, implementation is different.

Use-Case:
The association between two entities should be persisted in the third database entity.
Here the association means only UI association, don't get confused with ADF BC Association.

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, & commit the changes. The SelectBooleanCheckBox is used to display all the ROLES with check Box like Manager, President etc. For an EMP record, the user can select as many roles as possible. 

When the user select any check box (i.e ROLE) for an EMP record,  an entry is made in the EMP_ROLES Table and vice versa. The EMP_ROLES table contains all the ROLES selected for an EMP record in the form of one to one mapping. And while navigating between the EMP records, the corresponding ROLES saved in the EMP_ROLES db table are displayed as selected.


UI:


Steps implemented are:
1. Create a Fusion Web Application.
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 check boxes as selected for an EMP record.
4. Drag and drop the EmpVO as a form layout with navigations.
5. Drag a SelectManyCheckBox UI Component and bind the value property of SelectManyCheckBox to a managed bean property, which evaluates the values to be displayed as selected for an EMP record as shown.

6. When any Role is selected/unselected on the UI, 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 selected.

Sample Workspace:
Download the sample workspace from here.


10 comments:

  1. Hi Umesh,

    I am new on ADF, I have one query in my application i am using one attribute OperatingDays. now i want use SelectManyCheckBox for this attribute, like this
    Monday 1
    Tuesday 2
    Wednesday 3
    ......
    ......
    Sunday 7

    (1,2,3,4,5,6,7 these are the value of days) now my query is when i select monday operationdays attribute value will be 1 if i selected monday and tuesday then value will be 1,2 and so on.

    please help me to sort out this issue.
    Thanks

    ReplyDelete
    Replies
    1. Hi Kashif,
      Sorry for late reply.
      Can you please check this forum thread, if it could resolve your issue.
      https://forums.oracle.com/forums/message.jspa?messageID=10335532#10335532

      Thanks,
      Umesh Agarwal

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. hi umesh..

    i need ur help.

    if i select the any of 2 select items in selectmanycheckbox , the remaining selectitems should be disabled.

    mycode:i m getting the data from db based on 0ther component like selectonechoice.



    ReplyDelete
    Replies
    1. Hi Santosh,

      Sorry for late response.
      Can you please explain your use case in more detail?

      Thanks,
      Umesh

      Delete
  4. Could you please upload the project

    ReplyDelete
    Replies
    1. Hi Alekhya,

      The workspace URL link is mentioned towards end of this blog post. I am pasting the link here as well:

      http://adf-use-cases.googlecode.com/files/SelectManyCheckBoxImplementation.rar

      Thanks,
      Umesh

      Delete
  5. Hi Umesh,

    In my project, I'm using af:selectManyCheckbox to get a list of checkbox options. After selecting few of these checkboxes, I want to deselect all the selected checkboxes at some point. Please let me know if you can help me out.

    Thanks

    ReplyDelete