You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Markus Joschko <ma...@gmail.com> on 2008/08/17 20:00:17 UTC

t:errors in a zone

Hi all,
is the error handling for a form within a zone working?
I have a form configured in a zone like this:

	<div id="formzone" class="t-zone">
	  <form t:id="registerForm" zone="formzone" >
            <t:errors banner="literal:"/>
           .....

On the server I have an onValidateForm method which adds a custom
error to the form and
returns false to prevent event bubbling.
Now I would expect the form to be updated with the serverside error.
However that is not the case.
The server response is nearly empty:

    ({});
 /* !eval(new String('(' + json + ');)) */

Anything I do wrong?
Regards,
 Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t:errors in a zone

Posted by Markus Joschko <ma...@gmail.com>.
Thanks. Now I got the zone handling straight. That means at least I
see something in the response. However it is not rendered.
And despite mentioned in the response, the init method of the tapestry
script is never called (I set a firebug breakpoint there).
Is that a bug? See the response body below:

    ({script: "Tapestry.init({\"validate\":[[\"firstName:11be6aeee06\",[[\"required\",\"You
must provide
 a value for First Name.\"],[\"maxlength\",\"You may provide at most
20 characters for First Name.\"
,20],[\"regexp\",\"First Name can only consist of
letters.\",\"\\\\w*\"]]]],\"linkZone\":[[\"form:11be6aeee06
\",\"register\"]]});\n", content: "<form
action=\"/pagesms-web/profile/index.form.form\" id=\"form:11be6aeee06
\" method=\"post\" name=\"form:11be6aeee06\"><div
class=\"t-invisible\"><input name=\"t:formdata\" type
=\"hidden\"  value=\"H4sIAAAAAAAAALWSv0pDMRjFY0FUuqigIoJUrFAFc8G2Sx1ERdtKKYWizuntd2v03iRNor0ddPI5fAH/jI4idHDzFcQHcBFx0cH0j2KHSi10CiTfye
/wnXP1ggYrM2haSO5QF6w0K4KfcLj0MBSp5lJJlOCyhIkg9gFgTQQoLatxbHMJLi2Y0xOcAdMKbwBhWw1VOCdBEAn7o9ngpX87HUDIF5UQmu3IwS7nwsBwt7CMmQ
+vvApnMTl5udYvQPQ+cp6Kvl2jJmAJRToDzIsAqas/i0t2i8q1lK3l5UEfiy12QiVnnhnYGQuUn6LWcgANZNDwN0aj8cwhOSGWS1jJymtJWWnVFxqNOFQqnSUeVObRXB1n
/QZsuNw+UgkNvnYouEVjNP6n0QJRgNcL5pLYersuaTpc2K0FnycePhu2gjZnWnK3ji2jMzTUm5P1zox/9mgVP644FGlKGe1m2LMeb947CWwdI
+Bbbqm+W2ReXt3p6HU1Ee/ehlrK/4XKo5HscYDAAA=\"></div><div
class=\"t-beaneditor\"><div class=\"t-beaneditor-row\"><label
for=\"firstName:11be6aeee06\" id=\"firstName:11be6aeee06:label\">First
Name</label><input id=\"firstName:11be6aeee06\" name=\"firstName\"
type=\"text\" value=\"dfsadf\"><img alt=\"\" class=\"t-error-icon
t-invisible\" id=\"firstName:11be6aeee06:icon\"
src=\"/pagesms-web/assets/tapestry/5.0.15-SNAPSHOT/field-error-marker.gif\"></div><div
class=\"t-beaneditor-row\"><input class=\"t-beaneditor-submit\"
type=\"submit\" value=\"Register\"></div></div></form>"});
 /* !eval(new String('(' + json + ');)) */



On Sun, Aug 17, 2008 at 10:58 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Sun, 17 Aug 2008 15:00:17 -0300, Markus Joschko
> <ma...@gmail.com> escreveu:
>
>> Hi all,
>> is the error handling for a form within a zone working?
>> I have a form configured in a zone like this:
>>
>>        <div id="formzone" class="t-zone">
>>          <form t:id="registerForm" zone="formzone" >
>>            <t:errors banner="literal:"/>
>>           .....
>
> In you onValidateFromForm() method, you should return the zone when there
> are validation errors and the request is XHR (AJAX).
>
> The code below is not tested, but you can get the idea anyway (I hope):
>
> @Component
> private Zone formzone;
>
> @Inject
> private Request request;
>
> Object onValidateFromForm() {
>
>        // ... do your validation
>
>        if (form.getHasErrors() && request.isXHR() {
>                return formzone;
>        }
>        else {
>                return null;
>        }
>
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t:errors in a zone

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sun, 17 Aug 2008 15:00:17 -0300, Markus Joschko  
<ma...@gmail.com> escreveu:

> Hi all,
> is the error handling for a form within a zone working?
> I have a form configured in a zone like this:
>
> 	<div id="formzone" class="t-zone">
> 	  <form t:id="registerForm" zone="formzone" >
>             <t:errors banner="literal:"/>
>            .....

In you onValidateFromForm() method, you should return the zone when there  
are validation errors and the request is XHR (AJAX).

The code below is not tested, but you can get the idea anyway (I hope):

@Component
private Zone formzone;

@Inject
private Request request;

Object onValidateFromForm() {

	// ... do your validation

	if (form.getHasErrors() && request.isXHR() {
		return formzone;
	}
	else {
		return null;
	}

}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org