cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Madu" <andrewm...@gmail.com>
Subject Re: form-template onSubmit issue
Date Tue, 11 Jul 2006 06:53:13 GMT
After a few hours sleep! I have refined my dojo code, which is still not
playing ball. What gives here?:

<script>

dojo.require("cocoon.ajax.BUHandler");

function formProcessing() {
    alert("Your details are being processed. Please wait");
}

function getResults() {
    var proto_Type = cocoon.ajax.BUHandler.prototype;
    dojo.event.connect(proto_Type, "processResponse", "formProcessing");
}

dojo.addOnLoad(getResults);
</script>

In my form I simply do:

<ft:form-template onsubmit="getReseults()" method="post"ajax="true">
</ft:form-template>

Nothing happens! The form submits ok, but I am not getting a message back
saying "Your details are being processed. Please wait". Any ideas?

regards

Andrew

On 10/07/06, Andrew Madu <andrewmadu@gmail.com> wrote:
>
> Sorry the code should have read:
>
> function testForm() {
> dojo.addOnLoad(function() {
>
>     dojo.require("cocoon.ajax.BUHandler");
>     dojo.event.connect(cocoon.ajax.BUHandler.prototype, "processResponse",
>
>     function() {
>         alert("Page has been updated!")
>     })
> });
> }
>
> regards
>
> Andrew
>
>
> On 10/07/06, Andrew Madu <andrewmadu@gmail.com> wrote:
> >
> > Hi Simone,
> > in fact I would appreciate some help with this if possible. I have
> > implemented ajax=true in my form and upadated my sitemap to take account of
> > ajax process calls. The problem I am having now is the in the implementation
> > of the javascript. OnSumit I call a function and do away with
> > forms_onsubmit(); which is defined in forms-field-styling.xsl right? Now
> > my code is as follows:
> >
> > function testForm() {
> >
> >     dojo.require("cocoon.ajax.BUHandler");
> >     dojo.event.connect(cocoon.ajax.BUHandler.prototype,"processResponse",
> >
> >     function() {alert("Page has been updated!")}
> > }
> > dojo.addOnLoad(testForm());
> >
> > But when I try to subit the form, onSubmit("testForm") nothing happens,
> > the form does not submit! What am I not doing right here?
> >
> > regards
> >
> > Andrew
> >
> > On 10/07/06, Simone Gianni < s.gianni@thebug.it> wrote:
> >
> > > Hi Andrew,
> > > validation is carried server side, not client side, so there is no way
> > > to give a client side feedback when the form validated correctly,
> > > since
> > > that information (the fact that the validation was ok) is on the
> > > server.
> > >
> > > The possible approaches for this kind of situations are the following
> > > :
> > > - Ajax=false : Show something at client side *always* when the form is
> > > submitted, like "Your form is being processed", if the form has some
> > > validation errors the page will be reloaded with validation errors
> > > inside, otherwise the rest of the flow will go on as expected while
> > > the
> > > user is looking at the javascript thing, until a new page arrives.
> > > This
> > > can be done quite simply attaching a client side onSubmit event to the
> > > form.
> > > - Ajax=true : The same tecnique with ajax = true is still valid, but
> > > you
> > > have to intercept the ajax call instead of the form submit/page
> > > reloading. There is a mail in dev, written by Sylvain Wallez answering
> > > me, on how to intercept ajax calls with dojo AOP .. the mail was about
> > > doing test with selenium, but the concept is the same.
> > > - Both ajax=true and false : if the user has to wait because the flow
> > > is
> > > going to do a lot of work (like, retrieve tons of stuff from a
> > > database
> > > etc..) then the solution is a bit more complex, since the HTTP
> > > protocol
> > > does not have a push system, cocoon flow cannot do a
> > > sendPage("waitplease"), then do other stuff, then another
> > > sendPage("results"). So the trick could be :
> > > ... set a session attribute acting as a semaphore
> > > ... do a sendPage("waitplease")
> > > ... the wait please page will use a javascript timer to "poll" the
> > > session attribute every 5 seconds or so
> > > ... while it's still true the same page will be redisplayed, otherwise
> > > the next continuation will be called.
> > > ... the flow, after the sendPage("waitplease") will do all the long
> > > running stuff
> > > ... at the end will clear the session attribute
> > >
> > > The last solution is quite complicated, but will achieve what you
> > > need.
> > >
> > > Hope this helps,
> > > Simone
> > >
> > > Andrew Madu wrote:
> > >
> > > > Ok guys,
> > > > this is really bugging! me now. In a nutshell here is what I want to
> > > do:
> > > >
> > > > 1. on submitting a form (cform with fd:javascript validation) which
> > > > has been validated correctly, show a message to the user that the
> > > form
> > > > is being processed. The form in question is a credit card validation
> > > > page which when validated calls a paypal api which checks the credit
> > > > card details and returns various values based upon whether the check
> > >
> > > > was successful or not. All of that works fine! What I can't get my
> > > > head around at the moment is how to send a message to the user
> > > stating
> > > > that their details are being processed, as the the process can take
> > > > around 9-15 seconds to process, although paypal say anywhere upwards
> > > > of 30 seconds is possible. So rather than having a user sitting at a
> > > > page which looks like it is doing nothing, it would be nice to
> > > display
> > > > a message saying something is happening.
> > > >
> > > > I thought of setting a session variable in the fd:javascript section
> > > > only when a return type of true is reported and then in my jk file
> > > > doing something like:
> > > >
> > > >             <jx:if test="${cocoon.session.getAttribute
> > > > ('processingDetails') == true}">
> > > >                 <tr>
> > > >                   <td colspan="2">Your details are being
> > > > processing......</td>
> > > >                 </tr>
> > > >             </jx:if>
> > > >
> > > > but of course once the form has been valaidated as true the page is
> > > > not re-written again so that code will never be displayed. Only if
> > > the
> > > > validation failed would it be displayed. So, how to return a message
> > > > to a user once a cform with required fields has been successfully
> > > > validated? Any ideas?
> > > >
> > > > regards
> > > >
> > > > Andrew
> > > >
> > > > On 10/07/06, *Zhu Di* <flutina@gmail.com <mailto: flutina@gmail.com
> > > >>
> > > > wrote:
> > > >
> > > >     I am not quite sure am I answer your question or not...I had
> > > done
> > > >     the similar work, but I didn't touch resources/forms-lib.js and
> > > >     resources/forms-field-styling.xsl those kind of files.
> > > >
> > > >     when click submit button, call a java script to validate the
> > > >     input, I use the regular expression for validation, which is
> > > very
> > > >     powerful.
> > > >
> > > >     and if the validation checking is successful, then continue,
> > > >     otherwise give a alert.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >     2006/7/10, Andrew Madu <andrewmadu@gmail.com
> > > >     <mailto:andrewmadu@gmail.com >>:
> > > >
> > > >         Hi Christofer,
> > > >         I think you will find that the javascript in
> > > >         resources/forms-lib.js is very much client side. Either that
> > > >         or the cocoon developers have devised a way to make
> > > statements
> > > >         like document.body.appendChild(element) work server-side!
> > > ;-)
> > > >
> > > >         Any ideas anyone?
> > > >
> > > >         regards
> > > >
> > > >
> > > >         Andrew
> > > >
> > > >         On 10/07/06, *Christofer Dutz* < dutz@c-ware.de
> > > >         <mailto: dutz@c-ware.de>> wrote:
> > > >
> > > >             Hi Andrew
> > > >
> > > >
> > > >
> > > >             How about some print-statements?
> > > >
> > > >             As far as I know the java-script is executed
> > > server-side,
> > > >             so an alert will not work. If you do a "print(case)"
> > > this
> > > >             should output to your console the value of case.
> > > >
> > > >
> > > >
> > > >             Regards,
> > > >
> > > >                 Christofer
> > > >
> > > >
> > > >
> > > >
> > > ------------------------------------------------------------------------
> > > >
> > > >             *Von:* Andrew Madu [mailto: andrewmadu@gmail.com
> > > >             <mailto: andrewmadu@gmail.com>]
> > > >             *Gesendet:* Montag, 10. Juli 2006 09:52
> > > >             *An:* users@cocoon.apache.org <mailto:users@cocoon.apache.org
> > > >
> > > >             *Betreff:* ft:form-template onSubmit issue
> > > >
> > > >
> > > >
> > > >             Hi,
> > > >             I have a cform which has javascript validation on some
> > > >             form fields (widgets):
> > > >
> > > >             <fd:javascript>
> > > >               if (case) {
> > > >                 return true;
> > > >               } else {
> > > >                 return false;
> > > >               }
> > > >             </fd:javascript>
> > > >
> > > >             <fd:widgets>
> > > >             </fd:widgets>
> > > >
> > > >             Basically what I want to happen is that when <form>
is
> > > >             returned a value of 'true' to indicate that all form
> > > >             fields have been validated successfully a javascript
> > > >             function is carried out, for example an alert is
> > > triggered
> > > >             alert("success").
> > > >
> > > >             I have edited both resources/forms-lib.js and
> > > >             resources/forms- field-styling.xsl and absolutely
> > > nothing
> > > >             is happening. Firstly how can I determine in javascript
> > > >             whether true has been returned to the form after it has
> > > >             been submitted? I have tried a check on
> > > >             document.Form.submitted and had no joy with that. Any
> > > ideas?
> > > >
> > > >             regards
> > > >
> > > >             Andrew
> > > >
> > > >
> > > >
> > > >
> > > --
> > > Simone Gianni
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> > >
> > >
> >
>

Mime
View raw message