You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Madhav Bhargava <Ma...@infosys.com> on 2008/12/30 11:14:01 UTC

How to get hold of the event queue in JSF?

Hi All,

I am using Sun JSF RI 1.1_02, Tomahawk -1.1.6, tomahawk-sandbox-1.1.6, richfaces-3.1.6

I have a page where there is are 2 drop downs:
<t:selectOneMenu id="provTypCd" style="width:163"
                value="#{durMaintenanceController.provTypCd}">

                <f:selectItems id="selitms1"
                                value="#{durMaintenanceController.providerList}"></f:selectItems>
                <a4j:support event="onchange"
                                actionListener="#{durMaintenanceController.fetchRtsMdl}"
                                reRender="rtsMdlkey,percentageVal,descrptn,texterlMdsLmt1,Limit1,texterlMdsLmt2,Limit2-AboveLimit1,
                                                texterlMdsLmt3,Limit3-AboveLimit2,texterlMdsLmt4,Limit4-AboveLimit3,texterlMdsLmt5,Limit5-AboveLimit4,
                                                texterlMdsLmt6,Limit6-AboveLimit5,texterlMinPctAbv6"></a4j:support>
</t:selectOneMenu>

<t:selectOneMenu id="rtsMdlkey" style="width:163"
                value="#{durMaintenanceController.strdMdlKey}">

                <f:selectItems id="selitms21"
                                value="#{durMaintenanceController.earlyRefillAppliesList}"></f:selectItems>
                <a4j:support event="onchange"
                                actionListener="#{durMaintenanceController.fetchEarlyRefillValues}"
                                reRender="percentageVal,descrptn,texterlMdsLmt1,Limit1,texterlMdsLmt2,Limit2-AboveLimit1,
                                                                texterlMdsLmt3,Limit3-AboveLimit2,texterlMdsLmt4,Limit4-AboveLimit3,texterlMdsLmt5,Limit5-AboveLimit4,
                                                                texterlMdsLmt6,Limit6-AboveLimit5,texterlMinPctAbv6">
                </a4j:support>
</t:selectOneMenu>

And there are 2 input text boxes: (Note: I am not using required="true" because there is a problem with Sun JSF RI with the way they handle messages on validation errors)
<t:inputText id="percentageVal" size="23" align="left"
                forceId="true" value="#{durMaintenanceController.lkupPercentage}"
                maxlength="5">
                <f:converter converterId="com.wellpoint.benefitbuilder.NullConverter" />
                <custom:requiredValidator />
                <custom:validateDoubleRange minimum="0" maximum="100" />
</t:inputText>

<t:inputText id="descrptn" size="23" align="left" maxlength="100"
                forceId="true" value="#{durMaintenanceController.description}">
                <f:converter
                                converterId="com.wellpoint.benefitbuilder.NullConverter" />
                <custom:requiredValidator />
</t:inputText>

Now on change of the second drop down I need to refresh the values in the text boxes but not validate them. However I only need to validate them when an input button is clicked. Now I enclosed these text boxes in a <s:subForm> component. After which the validation errors were gone when the page got submitted using ajax4jsf support but since the subForm component was not submitted the processModelUpdates was not called for the components within the subForm. Upon re-render of a4j:support then show the older values.

I guess I will not be able to use s:subForm along with a4j:support. Is there any way I can get access to eventQueue so that I can check what are the events queued by the end of apply request phase. Looking at the events I can check in my validators whether to validate the field or not. That is the only solution that comes to mind right now.

However I am stuck because I do not know how to get hold of the event queue. Can anyone throw some light?

Thanks,
Madhav

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Re: How to get hold of the event queue in JSF?

Posted by Simon Kitching <sk...@apache.org>.
Madhav Bhargava schrieb:
>
> However I am stuck because I do not know how to get hold of the event
> queue. Can anyone throw some light?
>
I won't comment on the general approach; I haven't got time at the
moment to understand all of that.

Specifically about the event queue:

The event-queue is held on the UIViewRoot class as a private member.
The UIComponent.queueEvent method will add objects to the queue.

The UIViewRoot then removes the events from the queue at the appropriate
time and calls
   event.getComponent().broadcast(event)
on each as it is removed.

But I'm not aware of any way to "peek" at the event queue.

The events do "bubble up" from the component that queued it to the
UIViewRoot, so if you placed some other component in the ancestry that
overrides the queueEvent method, then it will see the event being
queued. Not very elegant though.

Otherwise I think you'll need to try to solve your problem by some other
way.

Regards,
Simon

-- 
-- Emails in "mixed" posting style will be ignored
-- (http://en.wikipedia.org/wiki/Posting_style)