Wednesday, September 5, 2007

Multi-selection and Row Data Editing in ADF Faces

In this post I have decided to dive into multi-selection feature offered by ADF Faces little bit more deeper and to show how it could be used in practice. Developed application use case is based on two pages, in first page user can select multiple rows in search results table and press edit button. Second page will be opened only with selected rows. So, this post is focused on how to open in second page only rows selected in first page.

Sample application - TableSelection.zip is based on standard HR schema. Two pages are implemented - search.jspx and edit.jspx. In search.jspx you can find two components - a search form and and a table for search results. In search form is implemented af:selectOneChoice component and table contains read-only af:selectOneChoice for region names. In edit.jspx there is editable table with af:selectOneChoice component for region name.

So, what happens when in search.jspx Edit button is pressed? Edit button is binded with editButton_action() method, available in backing_search backing bean. This means, when Edit button is pressed - editButton_action() is invoked:


This method finds needed iterator and acquires keys for selected rows. And main functionality - method sets where clause for View object that is used in edit.jspx page. Where clause is generated according to primary keys data of selected rows, this allows to open in edit.jspx only needed rows.

Just imagine, that we want to move several countries to other continent - no problem, select those countries and press Edit button:


Edit form is opened, here you can change region name for selected countries, save your changes and return to search form:


And..., you can continue a process... :-)

When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.

18 comments:

siva said...

i dont know how to do this "Multi-selection and Row Data Editing in ADF Faces" application can u send screen shot or documents for this one

Andrej Baranovskij said...

Hi Siva,

What step is not clear for you? I can explain it more. Currently I don't have screenshots for this sample. But if some part of application is unclear, I can develop a set of screenshots.

You can contact me by email also.

Regards,
Andrejus

Anonymous said...

This works only Editable VO, does not work with ReadOnly View Object with Expert Mode checked on

Andrej Baranovskij said...

Hi,

There should be no difference is Expert Mode checked on or no.

What error and at what step you get when using ReadOnly View?

Thanks,
Andrejus

Anonymous said...

Hai Andrejus,
I have created Multi-selection table using tableSelectMany.
When I will select some row and press updateCommandButton the selected rows will be updated using the method declared in
the ApplicationModule.
These things working perfectly for me.
But my problem is the updated rows are not disappeared from the table.
Is it possible to reexecute the
view object iterater after return from the method?.
Thanks
Ans

Andrej Baranovskij said...

Hi Ans,

Sure its possible. You need to put Execute action for your iterator in Page Definition file. And, you can invoke this action from backing bean method.

Regards,
Andrejus

Anonymous said...

Hai Andrejus,

I can insert an Execute action for the iterator in Page Definition file.But will u please tell me how
to invoke this action from backing bean method after the control is
return from the method declared in ApplicationModule.
Thanks
ANS

Andrej Baranovskij said...

Hi Ans,

You can do it with similar code:

BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Execute");
operationBinding.execute();

You can put this code into backing bean method.

Regards,
Andrejus

Anonymous said...

Hi Andrejus,

I have a problem with this multiselection thing. I have a page where I use tableselectmany atribute. So each row in a table has a multiselection checkbox (primary checkboxes). Then I have a detailstamp in each row and when I
expand that detailstamp I have some more rows with multiselection checkboxes (secondary checkboxes). So here is my problem. I want to do a selection (select all) of secondary checboxes by clicking on one of primary checkboxes. Is it possible to do it with some javascript or there is another way? I tried with javascript and I saw (at my pagesource which was generated by firefox) that there is a generated function _uixt_myPrimaryTableName_0_
mySecondaryTableName.multiSelect(true);
which is called by link select All.
But this number value in upper function depends on which row at primary checkbox was chosen.

Thanks for your answer,
Davor

Andrej Baranovskij said...

Hi,

I think you can enable autoSubmit on main multi selection and put partial triggering on detail selection. And add selection listener in Backing bean, where you can programmatically set selection state.

Regards,
Andrejus

Anonymous said...

Hi Andrejus,

Question.. i'm using a tableSelectMany but i don't want to have the links "Select all" and "Select none". Any idea how to remove these links?

Thnx

Alexander

Andrej Baranovskij said...

Hi,

There is no straightforward solution, but I remember something similar was discussed and solved on OTN Forum. Just search there.

Regards,
Andrejus

Anonymous said...

Andrejus,

Do you have suggestions about keywords to search with? Because I already tried searching at OTN Forum but without any success. I'll try again but if you know the thread or keywords to search on let me know! Thanks in advance..

Anonymous said...

Andrejus,

I found the solution.. adding
.x2l, .x21h {display:none;}

to the css file.

Alexander

Andrej Baranovskij said...

Alexander,

Thanks for update!

Andrejus

KK said...

Hai Andrejus,

I am new to ADF

My requirements is that I need to create Multi-selection table using tableSelectMany.
When user l select some row and press updateCommandButton the selected rows will be updated.

Please help me.

Regards
Krishna
krish.works@gmail.com

Shishir said...

Hi Andrejus,

I have a search page built out of the box using the Find and Execute operations of the view object.

However, the search performed is case sensitive and does not return any results when the search is performed for parameters in different case other than what's there in the database.


I need to do a case agnostic search using the out of the box operations which I am using. Can you please let me know if that's possible. If not can you point me to an example or a link to do that programmatically.

Thanks,
Shishir

Jobz said...

Hi,
can you plz tell, how can I select a value from next set of contents.. like --- a vlaue from 10-20 range..