Wednesday, November 3, 2010

How To Access Page Element Value from Backing Bean

I have received question from ADF newbie developer, who is starting to work with the framework. Question was simple, however I have decided to post it on the blog - simple topic for a change. It happens we work too much on complex things and forget about simple ones. Today I will describe how you can access Page Element (Input Text, etc.) value from Backing Bean.

First thing, you should register Java class as a bean. If you are working with page/fragment from bounded task flow, register it under that task flow:

There is Binding property in Advanced section, for every Page Element, it will reference component binding accessible from the bean class. I will use DepartmentName attribute in this example. Also I will declare my Page Element to have auto submit functionality - this will invoke Value Change Listener:

For the demonstration purpose, I will declare one more DepartmentName attribute value in page definition - DepartmentNameTest:

There are four different approaches implemented in the bean class. First is accessing element binding and getting its value. Another approach works with current row from iterator. Third approach is accessing attribute value from page definition. I prefer this approach, it makes implementation more loosely coupled and independent from the model refactoring. There is fourth approach as well - to get new value from value change listener directly:

We can press Test button, DepartmentName value will be accessed in the bean class:

Value is accessed:

DepartmentName value is changed:

Accessed from value change listener:

Download sample application -


chemic said...

thank you andre, now I become more familiar....:)

kurotsuki said...

I've tried your solution via component binding. When I use setValue, the value of component instance is changed, but did not enforce the one in the page to refresh.

How can I refresh the component on the page?

Andrej Baranovskij said...


It works well for me, just by adding mentioned code into testAction() method.


Rafael said...

You can use this to refresh a component:

Anonymous said...


I have a question regarding basic ADF.

how to add two rows to a table on one commit button click?
my case here is i have a customer address table and Primary address VO and Correspondence address vo on ui.
and m differentiating them by a flag Addresstype in table.On click of commit button primary address should go as one record and correspondence address as other record.

Hope u got my problem...


Andrej Baranovskij said...


Yes, you would need to do insert programmatically. Let me know if you need a sample.


Yousuf Baig said...

Thanks for this!

How does it change if I need to access the value from Rich Text Editor along with the html formatting.

Please help :)

Andrej Baranovskij said...

How it should change actually?


ruBeck said...

It is not highlighted that the InputText should have autoSubmit="true" or you will get nulls with all 4 methods listed.

Andrej Baranovskij said...

It is highlighted to use autoSubmit - check second screenshot and description text above it.


Anonymous said...

Hi Can you please upload your old projects again ? when ever I want to download one it gives me 404 error. Thanks


Andrej Baranovskij said...

All old samples (prior to 2014) are available from Google Archive: