You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jun Tsai <ju...@gmail.com> on 2008/06/04 06:00:43 UTC
Re: Form AJAX submission with Zone component appears to break if form validation is added.
I have the same problem.
2008/5/13 Eric Rogers <pu...@gmail.com>:
> 5.0.12 Snapshot
>
> If I have a page containing a form and an associated zone component to
> update, everything works as expected. However, when I add validation to a
> field on the form, the submission for the form is treated as regular
> submission, and not one handled through AJAX. More specifically, looking
> at
> the tapestry.js script, it appears that when the page is loaded, the form's
> onsubmit event handler is at first bound properly. However, the
> Tapestry.FormEventManager appears to rebind the onsubmit event to its own
> handleSubmit function, completely ignoring the previous event handler.
>
> I am just wondering if this is working as intended and whether or not
> anyone
> else has encountered this. If not, would this be classified as a bug? I
> have included some test code below.
>
> Thanks,
>
> Eric
>
> Test.tml:
>
> <t:Zone t:id="statusZone"/>
>
> <t:Form t:Zone="statusZone">
>
> <t:TextField t:id="name" t:value="name"/>
>
> <t:Submit/>
>
> </t:Form>
>
>
> Test.java:
>
> public class Test {
>
> private String name;
>
> //if we remove @Validate("required"), everything works as expected.
> @Validate("required")
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> Object onSuccess() {
> JSONObject response = new JSONObject();
> response.put("content", "test me");
> return new JSONStreamResponse(response);
> }
> }
>
--
regards,
Jun Tsai
Re: Form AJAX submission with Zone component appears to break if form
validation is added.
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 04 Jun 2008 01:00:43 -0300, Jun Tsai <ju...@gmail.com> wrote:
> I have the same problem.
Any T5 event handler method that is fired by AJAX must return a Block or
Zone containing the new zone content, so you have to return your Zone in
your validation method when validation fails. ;)
Use something like (not tested), even when you only use T5 validation:
@OnEvent(component="form", value=Form.VALIDATE_FORM)
public Object validate() {
// validation logic
if (request.isXHR() && form.getHasErrors()) {
return zone;
}
else {
return null;
}
}
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org