Saturday, February 6, 2010

Custom Attribute to Pass ADF Button Key

I got a question, based on my previous post - CRUD Operations in Oracle ADF 11g Table Using PopUp Component. Blog reader was asking, if its possible to identify ADF button component in Backing Bean without checking component Id. Answer is yes, it is possible - just need to use JSF attribute component. You can declare JSF attribute for ADF button and pass button key through this attribute:

It will be possible to access value passed through JSF attribute in Backing Bean. You just need to specify JSF attribute name and value. In this example, I will use insert value in order to identify Insert button:

In Backing Bean, you will need to access UI Component (ADF button in this case) object, and use getAttributes() function to get a map of available attributes. Retrieve defined JSF attribute using its name:

In a case, if Insert button will be pressed, we will check attribute and will invoke CreateInsert operation:

In other case - row will be opened for editing:

Download sample application -

1 comment:

Baptiste Sorrentino said...

Hi Andrejus,
Thanks for that.
Do you think it's also possible to pass a backing bean in an aattribute of a component ?
For example, in my jsff :

And in my component :

This example doesn't work, but do you know how to make it work ?