By default, when the 'Row Selection' property of the ADF af:table component is set to 'Single', the first row rendered in the table at run-time is 'Selected'. This is all fine and works as expected. The issue occurs in a scenario where the end-user wants to choose exactly the same row that ADF renders as 'Selected' especially when there is a back end logic to fetch and process the selected row values. This is because the 'selection listener' on the table is invoked only when a row state changes from 'unselected' to 'selected' - hence the behaviour.
In order to overcome this situation and ensure that 'NO' rows are 'rendered' selected by default, clear the 'SelectedRowKeys' property under the 'Advanced' section. This will ensure that at runtime ADF renders the table with no rows selected.
On the other hand, if you override the 'Selection Listener' with a custom listener (to process selected row values) you might want to use the following code snippet in your backing bean to make the current row selected;
ADFUtil.invokeEL("#{bindings.CI_CA_HDR_PNG.collectionModel.makeCurrent}",
new Class[] { SelectionEvent.class },
new Object[] { selectionEvent });
where #{bindings.CI_CA_HDR_PNG.collectionModel.makeCurrent} is nothing but the default 'Selection Listener' value.
In order to overcome this situation and ensure that 'NO' rows are 'rendered' selected by default, clear the 'SelectedRowKeys' property under the 'Advanced' section. This will ensure that at runtime ADF renders the table with no rows selected.
On the other hand, if you override the 'Selection Listener' with a custom listener (to process selected row values) you might want to use the following code snippet in your backing bean to make the current row selected;
ADFUtil.invokeEL("#{bindings.CI_CA_HDR_PNG.collectionModel.makeCurrent}",
new Class[] { SelectionEvent.class },
new Object[] { selectionEvent });
where #{bindings.CI_CA_HDR_PNG.collectionModel.makeCurrent} is nothing but the default 'Selection Listener' value.
Hi Sathyam,
ReplyDeleteMany thanks for the nice post.
I'm a novice to ADF and have a difficulty. I want to display an alert message, once a (specific)table cell been clicked.
I have added commandLink to perform the action (display alert) to the table.
My observation is row select event occurs/has precedence first over the cell/command link click.
I want to have command link functionality to run first (ahead of row select event/row selection listener).
Could you please suggest work-around to achieve this?
Hi Mandar,
DeleteI think you should be using a 'goLink' or 'commandButton' component instead of 'commandlink' the reason being commandLink component generates an action event on the server. There are two things that you can do;
1. Use the button or goLink component to generate the popup message
2. On the rowSelectionListener method, invoke the popup programmatically. On how to do this, refer the ADF documentation below;
http://docs.oracle.com/cd/E16162_01/web.1112/e16181/af_dialog.htm#BEJIHFFH
Hope this helps
HI sathya,
ReplyDeleteMy question not related to this post. I have a master-detail table. I am implementing CRUD functionality in both the tables. It is working fine. When I insert a new row in the child table, I am auto populating tow column values, the third column value has to entered by the user. In my case, it is not happening. The third column is becoming non-editable. If I don’t auto populate those two columns, I am able to enter the value for the third column. How to achieve this? Please help me.
Check if the EO/VO is 'updatable'. I would like to know the technique which you are using to auto populate certain columns. One thing that you can try is to drag drop the data control to the page as ADF table. Select the columns (which you would auto populate) and set the read only property of input text to 'true'. This way you prevent users from entering values in the auto-populated columns at the same time allow them to enter values for other columns.
DeleteHI Sathya,
DeleteThanks for the kind reply. Let me explain my requirement. I have table, which has 3 columns. In that, 2 are output text, 1 is input text. I am auto populating those 2 columns. First one, I have hard coded it. For the second column, I am calling the implementation class, executing the package and returning value. That will be there in the managed bean of the 'ADD' action.If I auto populate this, the input text column is becoming non-editable. If I auto hard code this, then I am able to edit the input text column. And yes, both EO/VO are updatable.
Hi Sathya,
ReplyDeleteIn my application I search with some data and get the result set in a table and by default the first row is selected. My problem is when I select another row in the table it is highlighted. Now if I search again the highlighted row remains the previously selected one and the selected row is first row only since I am selecting it by my managed bean.
Hi, If you follow the post it has been clearly mentioned. You will have to clear the 'selectedRowKeys' property under the 'Advanced' tab of ADF table. This will get rid of the 'default' first row selection. As for the selected row being 'selected' even after 2nd search, you can probably try to add a simple line of code in your managed bean on the table binding getter method to manually clear the selectedRowkeys property. This will ensure that every time the table results are loaded, the previous selection will be discarded.
DeleteHope it helps.
Hi Satya,
ReplyDeleteI have a custom selectionListener that I am using to set some values in bean based on the selected row. I also have a setDefaultRow method in my bean(I have a requirement to make the first row selected by default) that I am using to set the default row in the table on UI. But when I select any other row on UI after setting the default row, the selectionEvent is persisting the default selected row values but not the newly selected row values.
Hence my selectionListener is always fetching me the default row values. How can I make the selectionEvent that I get from selectionListener fetch me the data of newly selected row but not the default row always. Thanks in advance.
Sanju
Sanju,
DeleteADF is behaving the way it should. Every time you click on a row in your table, the custom selection listener gets invoked - calls the set default row which is nothing but the first row of your table. You don't have to write code in your bean to make the first row of the table selected. By default ADF table renders the first row selected. But if the end user wants to choose the first row (which is selected by default) selection listener will not be invoked - that's where this post will help you overcome the issue.
Thanks much for the prompt reply. Do you mean to say it is selected by default in the backend? If the first row is already selected by default, why doesn't it show as selected(highlighted) when page loads. (I hope it is selected by default even when you have your own selectionListener.) How can I get it highlighted when the page loads, if it is already selected by default. See, my requirement is that first row should be selected(and displayed so on UI) by default and I have my own custom Listener on the table. How to do this? Also, to overcome the issue of first row not invoking selListener, should I put the above code in the selListener method? What will be the CI_CA_HDR_PNG value in a regular managed bean scenario? Sorry, I am relatively new to ADF,as you can see.
DeleteSanju
Also, btw, you said it will be selected by default. When I load the page and check the value in my selListener as follows, the tableList size is zero where as at should be 1 when a row gets selected.
ReplyDeleteList tableList = TableUtilBean.getSelectedRowData(ev); // ev is SelectionEvent
sanju
Hi Satya,
ReplyDeleteI have a mail.jsff page inside it included another jsff file which contains a popup. My main.jsff contains a table in this table one of the row contains commandimageLink. When i click this link inside the listener action i would like to access the Popup(Included Page). I am not able to findout. Will you please pour your suggetions on this. Thanks in advance
HI Sathya,
ReplyDeleteMy question is apart from this topic....Can you please tell me how to fetch the records of same id in bpel??
Thanks,
Wasia
Hi Wasia,
DeleteYour query is so open ended. Can you please elaborate?
Dear Satya,
ReplyDeleteI have a requirement such that my first row should get selected and call the selection listener. Is there any way to achieve it?
I also have master detail relationship.
Do you mean on page load? Then you can do this in backing bean easily.. but selection listener triggers only on user-selection. It can't trigger on itself automatically with page load.
Deletehi sathya
ReplyDeleteI want the application to change the current row of the table with tab. It keeps the current row as the first row even though with using tab i am on the fifth row. please help.
Hi sathya,
ReplyDeleteI have a Backing bean method for Selection Listener on ADF Table. Row is not getting invoked for First Row.(also in case of one and only one row in the result set of the table).
What will be the solution for this scenario?
Thanks
Shashank
Hi Sathya,
ReplyDeleteI have a table in page1 which has cust id as one of its columns. On clicking the that cust id i navigate to page 2 which renders a table with cust id as one of its colulmn. what i need is when i land in page 2 the row that has cust id that i clicked on page 1 needs to be selected by default.
Thanks.
Hi Sathya,
ReplyDeleteNice post but my table is dynamically binded means my table is constructed by List not by any VO. So I cannot override the selection listener as you suggested in this post. Can you please suggest in this case?