myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walter Mourão" <>
Subject Re: [Trinidad] Is there a way to have a custom JavaScript function be called when a validation error occurs?
Date Fri, 01 Feb 2008 11:40:15 GMT
Hi Richard,
I suppose you're not using the PPR API to show the "Loading..." message. If
so the message should appear only after the client validation. I suggest you
start using the PPR start/stop events. From the developer's guide:

Monitoring AJAX requests

If you want to be notified when the client is busy waiting for an AJAX
response, add a "state change listener" to the request queue:


 Your callback will be passed a single parameter, which will be either
TrRequestQueue.STATE_READY or TrRequestQueue.STATE_BUSY, depending on the
current state of the request queue. The statusIndicator component uses
exactly this mechanism to know when to start and stop spinning its
indicator. You can optionally pass a second parameter to
addStateChangeListener() for the "this" you want active when your callback
is notified.

Sample code:
        <script type="text/javascript">
        // <![CDATA[
            function myCallback(state){
                if(state == TrRequestQueue.STATE_BUSY) {
                    //START OF PPR
                } else if(state == TrRequestQueue.STATE_READY){
                    //END OF PPR

        // ]]>

I hope it helps.

Walter Mourão

2008/1/31, Richard Yee <>:
> Everyone,
> I am showing a "Loading...." message when the user submits a form in my
> MyFaces/Trinidad application by having an onclick handler set the 'display'
> style to be 'inline' for my a tr:outputText tag. This works fine unless
> there is a validation error on the page for a required field. In this case,
> the JavaScript code for Trinidad detects the empty field and the page is not
> submitted. My "Loading..." message is still displayed however. Is there a
> way to hook into the Trinidad JavaScript validation code so that I can have
> one of my JavaScript functions set the display style  back to none in this
> case?
> Thanks,
> Richard
View raw message