The af:setPropertyListener comes very handy when we use af:iterator and need some processing to be done on an event fired by a component within the iterator.
af:iterator dynamically creates the multiple component instances of the component defined within in during design time. If we want to do some processing on event handling of a component instance within that, af:setPropertyListener is very useful.
Consider a scenario where we have a list of booleans to be rendered in a UI page. We can use af:iterator as below:
<af:panelGroupLayout id="pgl8" layout="vertical">
<af:iterator id="i1" value="#{pageFlowScope.accessGroups}"
var="accessGroup">
<af:selectBooleanCheckbox text="#{accessGroup.name}"
value="#{accessGroup.selected}"
label=""
id="sbc1" autoSubmit="true"
disabled="#{ !accessGroup.canModify}"
rendered="#{accessGroup ne null}"
valueChangeListener="#{myBean.onSelectionChangeOfAccessGroup}">
<af:setPropertyListener from="#{accessGroup.name}"
to="#{requestScope.selChangedAccessGroupName}"
type="valueChange"/>
</af:selectBooleanCheckbox>
</af:panelGroupLayout>
In the above example, the iterator iterates over the collection of booleans accessGroups. As per the layout in which it is contained, we get n checkboxes vertically aligned for n entries in the collection.
If the user wants to change a particular checkbox selection and do some processing on the value change of that checkbox by depending on the instance of accessGroup's other attributes, it is definitely necessary to have a reference of that accessGroup instance which is impossible to to know during the design time. Hence I used setPropertyListener to capture the accessGroup instance into a requestScope variable "selChangedAccessGroupName". I will use this in my event handling logic to do some processing as per the requirement. Sample code shown below.
myBean.java:
public class myBean implements Serializable{
public void onSelectionChangeOfAccessGroup(valueChangeEvent e){
AccessGroup ag = ADFContext.getCurrent().getRequestScope().get("selChangedAccessGroupName")
if(e.getNewValue){
// Invoke business service method by passing ag.getName() and e.getNewValue
}
}
}
The setPropertyListener from attribute is configured with value to be read and to attribute captures it into a requestScope variable. The type attribute is configured with event when the value need to be captured. This type attribute can be changed to different event types based on the requirement.
af:iterator dynamically creates the multiple component instances of the component defined within in during design time. If we want to do some processing on event handling of a component instance within that, af:setPropertyListener is very useful.
Consider a scenario where we have a list of booleans to be rendered in a UI page. We can use af:iterator as below:
<af:panelGroupLayout id="pgl8" layout="vertical">
<af:iterator id="i1" value="#{pageFlowScope.accessGroups}"
var="accessGroup">
<af:selectBooleanCheckbox text="#{accessGroup.name}"
value="#{accessGroup.selected}"
label=""
id="sbc1" autoSubmit="true"
disabled="#{ !accessGroup.canModify}"
rendered="#{accessGroup ne null}"
valueChangeListener="#{myBean.onSelectionChangeOfAccessGroup}">
<af:setPropertyListener from="#{accessGroup.name}"
to="#{requestScope.selChangedAccessGroupName}"
type="valueChange"/>
</af:selectBooleanCheckbox>
</af:panelGroupLayout>
In the above example, the iterator iterates over the collection of booleans accessGroups. As per the layout in which it is contained, we get n checkboxes vertically aligned for n entries in the collection.
If the user wants to change a particular checkbox selection and do some processing on the value change of that checkbox by depending on the instance of accessGroup's other attributes, it is definitely necessary to have a reference of that accessGroup instance which is impossible to to know during the design time. Hence I used setPropertyListener to capture the accessGroup instance into a requestScope variable "selChangedAccessGroupName". I will use this in my event handling logic to do some processing as per the requirement. Sample code shown below.
myBean.java:
public class myBean implements Serializable{
public void onSelectionChangeOfAccessGroup(valueChangeEvent e){
AccessGroup ag = ADFContext.getCurrent().getRequestScope().get("selChangedAccessGroupName")
if(e.getNewValue){
// Invoke business service method by passing ag.getName() and e.getNewValue
}
}
}
The setPropertyListener from attribute is configured with value to be read and to attribute captures it into a requestScope variable. The type attribute is configured with event when the value need to be captured. This type attribute can be changed to different event types based on the requirement.
In this manner my associate Wesley Virgin's autobiography begins with this shocking and controversial video.
ReplyDeleteYou see, Wesley was in the military-and shortly after leaving-he discovered hidden, "SELF MIND CONTROL" secrets that the CIA and others used to get anything they want.
THESE are the EXACT same methods tons of celebrities (notably those who "come out of nothing") and the greatest business people used to become rich and successful.
You probably know that you use less than 10% of your brain.
That's mostly because most of your brainpower is UNCONSCIOUS.
Maybe that thought has even occurred INSIDE your own head... as it did in my good friend Wesley Virgin's head 7 years back, while riding a non-registered, trash bucket of a vehicle with a suspended driver's license and $3.20 on his banking card.
"I'm so frustrated with going through life paycheck to paycheck! When will I get my big break?"
You've taken part in those thoughts, am I right?
Your own success story is waiting to start. You need to start believing in YOURSELF.
Take Action Now!