Friday, September 25, 2009

Dynamically changing multiselect to single select in Table in OAF

I would like to share a small piece of code, which recently a friend shared with me, this is a typical requirement, which might look too trivial at first shot, but is quite easy to implement. Suppose you have a table where in you have a requirement to have single or multi selection based on a dynamic conditon eg, some selection or press of a button you wanna change the multiselection to single selection and vice versa.

In such scenario, in the action of the event you redirect to same page and use following code in process request on the base of parameter you set in session/pagecontext :
// Hiding the Multiple Select Table Action and add single selection
OAAdvancedTableBean tabBean = (OAAdvancedTableBean)webBean.
findIndexedChildRecursive("[table item id]");

//Since the multiselect is at the end, get the total count -1 for removing
int count = tabBean.getIndexedChildCount(pageContext.getRenderingContext());
System.out.println("Child Count "+count);
tabBean.removeIndexedChild(count-1);

OAMultipleSelectionBean sel = (OAMultipleSelectionBean)tabBean.getTableSelection();
OASingleSelectionBean singleSelection = new OASingleSelectionBean() ;
singleSelection.setText("Select");

//Set the attribute for the single select
singleSelection.setViewAttributeName("SelectFlag");
tabBean.setTableSelection(singleSelection);

I hope this helps anybody who tries to implement such scenario!

5 comments:

cnu said...

Hi Mukul,
I have one doubt. Where I have to post my question.

Vijaya said...

Mukul,
This is Regarding Special Information Self Service Pages. would like to disable selection button (Update/Delete) for existing rows. Only enable for the new row. How can I acheive this functionality.

Thanks,
Vijaya

Unknown said...

Hi Mukul,
I am new to OAF. I created advance table region, added 2 columns and a multiple selection (view attribute property to selectFlag transient attribute). But, when I click selectAll or selectNone I am getting a Java script error “Error:'this._form' is null or not an object”. Can you please help? Do I need to write any code for this?
Thanks,
Badari

paulsmith198914@gmail.com said...

Thank you for sharing a small piece of code, which recently your friend shared with you! You're right, this is a typical requirement, which might look too trivial at first shot, but is quite easy to implement. Remember that custom esssays writing is a long and difficult process.

Vishal Kumar said...

Hi Mukul,

I have a requirement of making some rows read only in the VO table with Multi selection enabled. Basically we dont want user to choose certain rows from the multi selection table rows. How can we achieve this ?