In this post I will be describing how we can have a custom selection listener for ADF Table. By default when we drag and drop a ADF Table Component, it gives us the option to select a row. If that option is selected, it creates a default selectionListener for the table component that is
#{bindings.VO.currentModel.makeCurrent"} where Iterator is VO iterator. This operation synchronizes the current selected row with the Iterator to which this Tree Binding is pointing to.
In Addition to this it also adds a attribute selectedRowKeys which has a value
#{bindings.VO.collectionModel.selectedRow}. This makes the selected row from the collection.
But when you change this to your custom selection handler of your managed bean, then the operation which are performed by {bindings.Iterator.currentModel.makeCurrent"} and selectedRowKeys needs to be done programmatically.
One way is to invoke #{bindings.VO.currentModel.makeCurrent"} programmatically in the selectionListener of the managed bean. This has been explained very clearly by my friend Ashish Awasthi :- Custom Selection Listener
In this article I will go through a different approach to implement custom selection listener.
Lets create a ADF project using HR Schema and create DepartmentsVO.
After that create a JSPX page and drag the VO as a table and select singe row selection. Now change the selectionListener to point to managed bean and create a selectionListener method. Also remove the selectedRowKeys attribute from the table as we will be doing this programmatically.
The Table should look like below:
#{bindings.VO.currentModel.makeCurrent"} where Iterator is VO iterator. This operation synchronizes the current selected row with the Iterator to which this Tree Binding is pointing to.
In Addition to this it also adds a attribute selectedRowKeys which has a value
#{bindings.VO.collectionModel.selectedRow}. This makes the selected row from the collection.
But when you change this to your custom selection handler of your managed bean, then the operation which are performed by {bindings.Iterator.currentModel.makeCurrent"} and selectedRowKeys needs to be done programmatically.
One way is to invoke #{bindings.VO.currentModel.makeCurrent"} programmatically in the selectionListener of the managed bean. This has been explained very clearly by my friend Ashish Awasthi :- Custom Selection Listener
In this article I will go through a different approach to implement custom selection listener.
Lets create a ADF project using HR Schema and create DepartmentsVO.
After that create a JSPX page and drag the VO as a table and select singe row selection. Now change the selectionListener to point to managed bean and create a selectionListener method. Also remove the selectedRowKeys attribute from the table as we will be doing this programmatically.
The Table should look like below:
In the managed bean, there are two methods. One is onTableRowSelection and customListener.
customListener is what binded to the selectionListener from table component and onTableRowSelection method has actual logic to make the current row of the table as selected.
Below is the code in the bean.
After onTableRowSelection set the current Row , customListener gets the current row and access its department name.
Thats all. Lets run the page.
On Selecting Public Relations, we get output in the consoles as same name.
Thats it.
Application can be downloaded at Custom Table Selection Listener
Thanks
Thank you for such a fantastic blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently working on, and I have been on the lookout for such information.
ReplyDeletegoogle watch
This works as expected.. Thanks
ReplyDeleteThanks Saif !!
ReplyDeleteHi Rohan,
ReplyDeleteNice Post. One update. Using Rich Component within the Managed Bean and Binding with UI Components can lead to potential memory leak. There are couple of other method/ways too get the updated row within the Manged Bean without doing Binding of UI Components
Hi Bish,
ReplyDeleteHope you are doing good as well as the project.
Yes I understand your point, the post is just to demonstrate the Custom Selection Listener. Its a demo project and does not take care about advanced project level things. Its up to the developers for how to access bindings in bean !!
Thanks
Thank you very much.. You save my time..
ReplyDeleteYour Welcome. Glad you liked it.
DeleteHi Rohan
ReplyDeletecouple for first images are not opening.
Hi Waqar, Just checked again.All Images are opening fine. Kindly please check again.
DeleteThanks
Thanks for the blog.
ReplyDeleteI created a custom selection listener based on the above example. My requirement restricts edit/delete for each row based on business logic. However, on making these changes, I face the below issues:
a) when I add a new row, it is not displayed as selected as the listener is not invoked.
b) when the table is loaded, none of the rows are selected by default.
Can you please advise?
Hi Kumarjit, Have you figured out the resolution for your questions.?
DeleteI have a table in page 1 which renders a af:table. It has cust id as one of its columns. On clicking the cust id, it navigates to page 2 which renders a table which also has cust id as one of its column. What i need is when i land on page2, the row that has cust id that i clicked on page 1 to be selected by default.
ReplyDeleteHello,
ReplyDeleteYour blog really helped resolve the issue. Thanks a lot !!
Hi ,
ReplyDeleteI have done the above said logic but when i click on the row from table it throws null pointer exception as like --> java.lang.NullPointerException: UIComponent is null
I am lucky that I discovered this web site, just the right info that I was looking for! 𝗖𝗿𝗼𝘀𝘀 𝗖𝗼𝘂𝗻𝘁𝗿𝘆 𝗖𝗮𝗿 𝗦𝗵𝗶𝗽𝗽𝗶𝗻𝗴 - TERMINAL TO TERMINAL CAR SHIPPING SERVICE
ReplyDeleteI like this site very much, Its a really nice situation to read and get info . Shipping Heavy Equipment with A-1 Auto Transport
ReplyDeleteThe actual challenge to become is normally you can actually SOLE check out that level of your tax discount over the internet by looking at your RATES web-site. instagram++ 2022
ReplyDeleteThank you pertaining to sharing that excellent written content on your website. I ran into it on google. I am going to check back again once you publish much more aricles. Moving And Storage Services
ReplyDeleteI adore your wordpress web template, wherever would you download it from? UFABETสมัครแทงบอลเว็บตรง
ReplyDeleteRegards for this marvellous post, I am glad I detected this web site on yahoo. Rays 2-in-1 Blender & Grinder 3001
ReplyDeleteGood article , I am going to spend more time learning about this topic Tent Rent
ReplyDeleteThank you pertaining to sharing that excellent written content on your website. I ran into it on google. I am going to check back again once you publish much more aricles. 3pl warehouse
ReplyDeletePUBG: BATTLEGROUNDS is a battle royale that pits 100 players against each other. Outplay your opponents to become the lone survivor. Play free now! pubg
ReplyDeleteLaunched in 1990'S, Khawaja Suiting is a Pakistani brand store that is offering a perfect blend of youthful, classy, and chic designs at highly affordable prices.
ReplyDeleteledies feshion
In the ever-evolving world of smartphones, Apple has consistently set the benchmark for innovation, design, and performance. iPhone 15 Pro Max
ReplyDeleteI’ve recently started a site, the information you offer on this web site has helped me greatly. Thank you for all of your time & work. Disability Services
ReplyDeleteThank you for this great website. I am trying to read some more posts but I cant get your blog to display properly in my Firefox Browser. Thank you again! Land Transport Services in UAE
ReplyDeleteI am impressed, I must say. very seldom do I stumble upon a blog thats both educational and entertaining, and let me tell you, youve hit the nail on the head. seo agency in dubai
ReplyDeleteGreat post, I think owners should acquire a lot from this web site its very user pleasant. endorsed training course
ReplyDelete"I appreciate you linking to this article! It provided some really interesting perspectives on the topic. I’m going to dive deeper into the linked content, but this post was a fantastic starting point."mowing wet grass
ReplyDelete