Follow by Email

Friday, 28 August 2015

ADF Basics: Using setPropertyListener to set value in memory scope variables

Soemtimes we need to set a value in memory scope variable on some event
In ADF af:setPropertyListener does this for you declaratively

The setPropertyListener tag provides a declarative syntax for assigning values when an event fires. The setPropertyListener implements the listener interface for a variety of events, to indicate which event type it should listen for set the 'type' attribute.

Read more about <af:setPropertyListener>

Suppose i have an attribute EmployeeId is present in pageDef and i want to set it's value in a request scope variable on a button click
Using setPropertyListener we can do it without writing a single line of java code
See how to use it-
Drop a button on page and setPropertyListener under it

<af:button text="Set Value" id="b6" actionListener="#{viewScope.Testbean.buttonActionToTest}">
                        <af:setPropertyListener type="action" from="#{bindings.EmployeeId.inputValue}" to="#{requestScope.valName}"/>

Set properties of setPropertyListener-

All done :) Now to get this request scope variable value on button click using this code

import oracle.adf.share.ADFContext;


No comments :

Post a Comment