You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Koeberl <ch...@porsche.co.at> on 2007/08/03 12:48:39 UTC

[T5] Why is default ValidationTracker in Form marked Persist not Persist("flash")

Hi!

I was wondering why the "_defaultTracker" in the Form component is marked
as @Persist not as @Persist("flash").

In my opinion it should be @Persist("flash")!!

Persisting the ValidationTracker in the session leads to some (usually) 
not wanted
behaviour: the validation is not reset, even though a new object is edited 
with that form.

Here is an example:

Assume you have a page with a form and a TextField. I disabled client 
validation to
see the problem:

        @SuppressWarnings("unused")
        @Component(parameters = "clientValidation = false")
        private Form mainForm;

        @SuppressWarnings("unused")
        @Component(parameters =
        { "value = name", "label = literal:Name", "validate = required, 
maxlength=20" })
        private TextField nameField;

        private String name;
        // getters and setters

When you try to save the form the ValidationTracker tracks the error and 
the error
is displayed to the user. So far, so good.
Next, the user triggers a PageLink ("Cancel edit") to another page. There 
the user 
selects another name and is forwarded to the page with the form again, the 
new name 
is set with setName("xxx"). The form still displays the error and the old 
value of the
previously edited name.

-- 
Chris

Re: [T5] Why is default ValidationTracker in Form marked Persist not Persist("flash")

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 03 Aug 2007 16:07:07 -0300, Howard Lewis Ship <hl...@gmail.com>  
wrote:

> By making it @Persist (i.e. with default), then the container (i.e., your
> page) can set a @Meta to control the default persistence of components  
> below it.  Thus, if you want the default to be "flash", you're in luck.   
> Or, you can inject the Form component, it has methods that overlap
> ValidationDelegate for clearing errors & etc. (it just delegates to its
> ValidationDelegate).

Could you give us an example of how to accomplish this?

Thiago

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


Re: [T5] Why is default ValidationTracker in Form marked Persist not Persist("flash")

Posted by Howard Lewis Ship <hl...@gmail.com>.
By making it @Persist (i.e. with default), then the container (i.e., your
page) can set a @Meta to control the default persistence of components below
it.  Thus, if you want the default to be "flash", you're in luck.  Or, you
can inject the Form component, it has methods that overlap
ValidationDelegate for clearing errors & etc. (it just delegates to its
ValidationDelegate).

On 8/3/07, Christian Koeberl <ch...@porsche.co.at> wrote:
>
> Hi!
>
> I was wondering why the "_defaultTracker" in the Form component is marked
> as @Persist not as @Persist("flash").
>
> In my opinion it should be @Persist("flash")!!
>
> Persisting the ValidationTracker in the session leads to some (usually)
> not wanted
> behaviour: the validation is not reset, even though a new object is edited
> with that form.
>
> Here is an example:
>
> Assume you have a page with a form and a TextField. I disabled client
> validation to
> see the problem:
>
>         @SuppressWarnings("unused")
>         @Component(parameters = "clientValidation = false")
>         private Form mainForm;
>
>         @SuppressWarnings("unused")
>         @Component(parameters =
>         { "value = name", "label = literal:Name", "validate = required,
> maxlength=20" })
>         private TextField nameField;
>
>         private String name;
>         // getters and setters
>
> When you try to save the form the ValidationTracker tracks the error and
> the error
> is displayed to the user. So far, so good.
> Next, the user triggers a PageLink ("Cancel edit") to another page. There
> the user
> selects another name and is forwarded to the page with the form again, the
> new name
> is set with setName("xxx"). The form still displays the error and the old
> value of the
> previously edited name.
>
> --
> Chris
>



-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com