Please disable your adblock and script blockers to view this page

Search this blog

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}"/>
                    </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")


1 comment :

  1. Hi Ashish,

    How can we pass a boolean value to pageFlowScope using setPropertyListener.

    ReplyDelete