<af:commandButton text="Show Popup" id="cb6">
<af:setPropertyListener from="#{'something'}" to="#{pageFlowScope.someVariable}" type="action"/>
<af:showPopupBehavior popupId="p1"/>
</af:commandButton>
However the above fails to initialize the property before showing the popup. Why?
The reason is well documented under 'Cancels Client Events' of the <af:showPopupBehavior> tag doc.
The showPopupBehavior tag cancels the client event defined by the triggerType. Canceling the client event will prevent delivery to the server. This is significant for action events raised by command family components because the server-side action listeners will be ignored. All actionListener method bindings and associated action listeners will not be invoked when the triggerType of "action" is used.
In a nutshell the action event gets cancelled by the showPopupBehavior tag, so your property setter doesn't gets invoked. However there are a couple of workarounds...
1. Try using popupFetchListener for initializing the popup content(instead of <af:setPropertyListener> tag).
<af:popup id="p2" contentDelivery="lazyUncached"
childCreation="deferred"
popupFetchListener="#{TestBean.popupFetchAction}" ...
2. Try opening the popup programmatically (instead of using showPopupBehavior tag). Examples can be found under the tag doc for af:popup. You can safely use <af:setPropertyListener> to initialize properties in this approach.
3. Trigger the showPopupBehavior for 'click' instead of 'action'.
<af:showPopupBehavior popupId="p1" triggerType="click" />
Underlying theory is that 'click' and an 'action' do not cancel each other.
7 comments:
Nice post as usual!
Although in my opinion 1 is not a solution. Reason is if control is disabled and its triggerType="click", it will still raise the component (which in this case obviously we do not want).
Check http://adfhowto.blogspot.com/2010/11/troubleshooting-afshowpopupbehavior.html
Spyros
Thanks Spyros for the input,I was not aware of that. That makes me to drag the first point to the last place :)
Hey thanks man.
Naresh
Welcome!
Thanks..that help to remove the confusion.
Jobinesh,
In my trial I found that triggerType should always be set to "action" if we use "popupFetchListener". And that's what we wanted. Thanks.
Thanks Jobinesh for the post...It helped me in the similar use case.
Post a Comment