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 <[EMAIL PROTECTED]> 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* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> 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 _javascript_ 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 <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED] >>:
>
> 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* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> 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: [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>]
> *Gesendet:* Montag, 10. Juli 2006 09:52
> *An:* [email protected] <mailto:[email protected]>
> *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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
