Using setPropertyListener to set value in memory scope variables

Sharing is Caring

Sometimes we need to set a value in memory scope variable on some event, We can do this using setPropertyListener in ADF.

The setPropertyListener tag provides a declarative syntax for assigning values when an event fires. The set Property Listener 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 its 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

setPropertyListener

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

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;

ADFContext.getCurrent().getRequestScope().get("valName")

Related Posts

2 thoughts on “Using setPropertyListener to set value in memory scope variables”

Leave a Reply

Your email address will not be published. Required fields are marked *