T5: refreshing page when there is an error

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

T5: refreshing page when there is an error

angelochen
Hi,

I notice that when an error is recorded thru recordError, refreshing the form will not erase the error messages unlike when form was rejected by validator where pressing refresh in the browser can errase the errors and go back to the initial form screen, here is the code
 public void onValidate() throws EncoderException {
 _form.recordError("test error");
 }

if this error is shown in the form, it will be there forever even you restart the browser, any hint?
A.C.
Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Howard Lewis Ship
Form has a clearErrors() method.

On 10/15/07, Angelo Chen <[hidden email]> wrote:

>
>
> Hi,
>
> I notice that when an error is recorded thru recordError, refreshing the
> form will not erase the error messages unlike when form was rejected by
> validator where pressing refresh in the browser can errase the errors and
> go
> back to the initial form screen, here is the code
> public void onValidate() throws EncoderException {
> _form.recordError("test error");
> }
>
> if this error is shown in the form, it will be there forever even you
> restart the browser, any hint?
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind
Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Thiago H de Paula Figueiredo
On Mon, 15 Oct 2007 15:36:26 -0300, Howard Lewis Ship <[hidden email]>  
wrote:

> Form has a clearErrors() method.

This raises again the question on which is the best persistence strategy  
for the ValidationTracker of Form: session or flash. I prefer flash, as it  
makes more sense to me. On the other hand, I think Howard disagrees. :)

--
Thiago H. de Paula Figueiredo
Desenvolvedor, Instrutor e Consultor de Tecnologia
Eteg Tecnologia da Informação Ltda.
http://www.eteg.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Nick Westgate
I agree it should be "Flash". I copied Form and changed it to that.
It should be possible for a user to configure this.

Cheers,
Nick.


Thiago H de Paula Figueiredo wrote:
> On Mon, 15 Oct 2007 15:36:26 -0300, Howard Lewis Ship <[hidden email]>
> wrote:
>
>> Form has a clearErrors() method.
>
> This raises again the question on which is the best persistence strategy
> for the ValidationTracker of Form: session or flash. I prefer flash, as
> it makes more sense to me. On the other hand, I think Howard disagrees. :)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Kristian Marinkovic
we also extended the Form component.... :)

i think "flash" is the correct persistence strategy for Form errors. i
don't see
any use case where form validation messages should be stored in the
session. i think it is a behaviour that is not expected.

we already had 2 developers in our company that - independently of each
other - got stock with this. they had a detail page with some validation
errors
and chose to go back to the master page. there they selected a new article
and set the new object in the detail page (via page injection or via
context
parameter and setupRender). and both where surprised not to see the values

of the new object but the old one with the validation errors.

if more people agree with "flash" as default strategy for the
ValidationTracker
we could add a jira :)...

g,
kris




Nick Westgate <[hidden email]>
16.10.2007 05:04
Bitte antworten an
"Tapestry users" <[hidden email]>


An
Tapestry users <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






I agree it should be "Flash". I copied Form and changed it to that.
It should be possible for a user to configure this.

Cheers,
Nick.


Thiago H de Paula Figueiredo wrote:
> On Mon, 15 Oct 2007 15:36:26 -0300, Howard Lewis Ship <[hidden email]>

> wrote:
>
>> Form has a clearErrors() method.
>
> This raises again the question on which is the best persistence strategy

> for the ValidationTracker of Form: session or flash. I prefer flash, as
> it makes more sense to me. On the other hand, I think Howard disagrees.
:)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Nick Westgate
Go ahead and add a JIRA. A patch to make it configurable would be great. ;-)

Actually I just remembered that it is configurable in that the persistence
strategy is inherited from the Form's container, but it seems most of us
agree that we don't want a default of flash for our pages - only for Form.

Session persistence for the ValidationTracker does make sense if returning
to an edit page via action (not submit) should retain the previous errors.

Cheers,
Nick.


Kristian Marinkovic wrote:

> we also extended the Form component.... :)
>
> i think "flash" is the correct persistence strategy for Form errors. i
> don't see
> any use case where form validation messages should be stored in the
> session. i think it is a behaviour that is not expected.
>
> we already had 2 developers in our company that - independently of each
> other - got stock with this. they had a detail page with some validation
> errors
> and chose to go back to the master page. there they selected a new article
> and set the new object in the detail page (via page injection or via
> context
> parameter and setupRender). and both where surprised not to see the values
>
> of the new object but the old one with the validation errors.
>
> if more people agree with "flash" as default strategy for the
> ValidationTracker
> we could add a jira :)...
>
> g,
> kris
>
>
>
>
> Nick Westgate <[hidden email]>
> 16.10.2007 05:04
> Bitte antworten an
> "Tapestry users" <[hidden email]>
>
>
> An
> Tapestry users <[hidden email]>
> Kopie
>
> Thema
> Re: T5: refreshing page when there is an error
>
>
>
>
>
>
> I agree it should be "Flash". I copied Form and changed it to that.
> It should be possible for a user to configure this.
>
> Cheers,
> Nick.
>
>
> Thiago H de Paula Figueiredo wrote:
>> On Mon, 15 Oct 2007 15:36:26 -0300, Howard Lewis Ship <[hidden email]>
>
>> wrote:
>>
>>> Form has a clearErrors() method.
>> This raises again the question on which is the best persistence strategy
>
>> for the ValidationTracker of Form: session or flash. I prefer flash, as
>> it makes more sense to me. On the other hand, I think Howard disagrees.
> :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

angelochen
In reply to this post by Howard Lewis Ship
Hi Howard,

What is the right spot to use clearErrors()? I have code as follow:
 public void onValidate() throws EncoderException {
        _form.clearErrors();  
        // more validates...
}

if there is a previous error, it will be cleared, but if there is a new error, all the fields are cleared as well, any hints?

Howard Lewis Ship wrote
Form has a clearErrors() method.

On 10/15/07, Angelo Chen <angelochen960@yahoo.com.hk> wrote:
>
>
> Hi,
>
> I notice that when an error is recorded thru recordError, refreshing the
> form will not erase the error messages unlike when form was rejected by
> validator where pressing refresh in the browser can errase the errors and
> go
> back to the initial form screen, here is the code
> public void onValidate() throws EncoderException {
> _form.recordError("test error");
> }
>
> if this error is shown in the form, it will be there forever even you
> restart the browser, any hint?
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


--
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind
Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Nick Westgate
You mean refreshing without a submit, right? So onValidate isn't
called in that case - only when the form submits. You can clear
the form errors in an event handler, but realistically this can
become problematic ...

It's likely that the behaviour you want can be provided by:

(a) copying and changing Form - see (b)

or

(b) deriving from Form and flash persisting the ValidationTracker:

package yourapp.tapestry.components;

import org.apache.tapestry.ValidationTracker;
import org.apache.tapestry.ValidationTrackerImpl;
import org.apache.tapestry.annotations.Persist;

public class Form extends org.apache.tapestry.corelib.components.Form
{
     @Persist("flash")
     private ValidationTracker defaultTracker;

     @Override
     public ValidationTracker getDefaultTracker()
     {
         if (defaultTracker == null)
             defaultTracker = new ValidationTrackerImpl();

         return defaultTracker;
     }

     @Override
     public void setDefaultTracker(ValidationTracker defaultTracker)
     {
         this.defaultTracker = defaultTracker;
     }
}

Cheers,
Nick.


Angelo Chen wrote:

> Hi Howard,
>
> What is the right spot to use clearErrors()? I have code as follow:
>  public void onValidate() throws EncoderException {
>         _form.clearErrors();  
>         // more validates...
> }
>
> if there is a previous error, it will be cleared, but if there is a new
> error, all the fields are cleared as well, any hints?
>
>
> Howard Lewis Ship wrote:
>> Form has a clearErrors() method.
>>
>> On 10/15/07, Angelo Chen <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> I notice that when an error is recorded thru recordError, refreshing the
>>> form will not erase the error messages unlike when form was rejected by
>>> validator where pressing refresh in the browser can errase the errors and
>>> go
>>> back to the initial form screen, here is the code
>>> public void onValidate() throws EncoderException {
>>> _form.recordError("test error");
>>> }
>>>
>>> if this error is shown in the form, it will be there forever even you
>>> restart the browser, any hint?
>>> A.C.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> --
>> Howard M. Lewis Ship
>> Partner and Senior Architect at Feature50
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

angelochen
Hi Nick,

refreshing without a submit was my original question, but after applying clearErrors(), I meant form fields got cleared while the error was displayed under onValidate(), anyway I have tried your approach (b), here is the result:

When I did :
 public void onValidate() throws EncoderException {
      _form.recordError("Email address invalid");
1.
   It displays error, and if I quit the browser and re-open the page, error is gone, good. when I switch to other page then come back to the original page, error is gone, good. when I click 'refresh', error remains, why?

2. I let "t:validate="required,minlength=8" emits some errors into the same form, then click 'refresh', those new errors got erased, but the error in #1 remains, anyway to clear them totally?




Nick Westgate wrote
You mean refreshing without a submit, right? So onValidate isn't
called in that case - only when the form submits. You can clear
the form errors in an event handler, but realistically this can
become problematic ...

It's likely that the behaviour you want can be provided by:

(a) copying and changing Form - see (b)

or

(b) deriving from Form and flash persisting the ValidationTracker:

package yourapp.tapestry.components;

import org.apache.tapestry.ValidationTracker;
import org.apache.tapestry.ValidationTrackerImpl;
import org.apache.tapestry.annotations.Persist;

public class Form extends org.apache.tapestry.corelib.components.Form
{
     @Persist("flash")
     private ValidationTracker defaultTracker;

     @Override
     public ValidationTracker getDefaultTracker()
     {
         if (defaultTracker == null)
             defaultTracker = new ValidationTrackerImpl();

         return defaultTracker;
     }

     @Override
     public void setDefaultTracker(ValidationTracker defaultTracker)
     {
         this.defaultTracker = defaultTracker;
     }
}

Cheers,
Nick.


Angelo Chen wrote:
> Hi Howard,
>
> What is the right spot to use clearErrors()? I have code as follow:
>  public void onValidate() throws EncoderException {
>         _form.clearErrors();  
>         // more validates...
> }
>
> if there is a previous error, it will be cleared, but if there is a new
> error, all the fields are cleared as well, any hints?
>
>
> Howard Lewis Ship wrote:
>> Form has a clearErrors() method.
>>
>> On 10/15/07, Angelo Chen <angelochen960@yahoo.com.hk> wrote:
>>>
>>> Hi,
>>>
>>> I notice that when an error is recorded thru recordError, refreshing the
>>> form will not erase the error messages unlike when form was rejected by
>>> validator where pressing refresh in the browser can errase the errors and
>>> go
>>> back to the initial form screen, here is the code
>>> public void onValidate() throws EncoderException {
>>> _form.recordError("test error");
>>> }
>>>
>>> if this error is shown in the form, it will be there forever even you
>>> restart the browser, any hint?
>>> A.C.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> --
>> Howard M. Lewis Ship
>> Partner and Senior Architect at Feature50
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Nick Westgate
Hmm, I'm seeing the same thing, although I only have an old T5.0.5 project
to play with at the moment. This will take some looking into.

Kris are you getting this behaviour?

Cheers,
Nick.


Angelo Chen wrote:

> Hi Nick,
>
> refreshing without a submit was my original question, but after applying
> clearErrors(), I meant form fields got cleared while the error was displayed
> under onValidate(), anyway I have tried your approach (b), here is the
> result:
>
> When I did :
>  public void onValidate() throws EncoderException {
>       _form.recordError("Email address invalid");
> 1.
>    It displays error, and if I quit the browser and re-open the page, error
> is gone, good. when I switch to other page then come back to the original
> page, error is gone, good. when I click 'refresh', error remains, why?
>
> 2. I let "t:validate="required,minlength=8" emits some errors into the same
> form, then click 'refresh', those new errors got erased, but the error in #1
> remains, anyway to clear them totally?
>
>
>
>
>
> Nick Westgate wrote:
>> You mean refreshing without a submit, right? So onValidate isn't
>> called in that case - only when the form submits. You can clear
>> the form errors in an event handler, but realistically this can
>> become problematic ...
>>
>> It's likely that the behaviour you want can be provided by:
>>
>> (a) copying and changing Form - see (b)
>>
>> or
>>
>> (b) deriving from Form and flash persisting the ValidationTracker:
>>
>> package yourapp.tapestry.components;
>>
>> import org.apache.tapestry.ValidationTracker;
>> import org.apache.tapestry.ValidationTrackerImpl;
>> import org.apache.tapestry.annotations.Persist;
>>
>> public class Form extends org.apache.tapestry.corelib.components.Form
>> {
>>      @Persist("flash")
>>      private ValidationTracker defaultTracker;
>>
>>      @Override
>>      public ValidationTracker getDefaultTracker()
>>      {
>>          if (defaultTracker == null)
>>              defaultTracker = new ValidationTrackerImpl();
>>
>>          return defaultTracker;
>>      }
>>
>>      @Override
>>      public void setDefaultTracker(ValidationTracker defaultTracker)
>>      {
>>          this.defaultTracker = defaultTracker;
>>      }
>> }
>>
>> Cheers,
>> Nick.
>>
>>
>> Angelo Chen wrote:
>>> Hi Howard,
>>>
>>> What is the right spot to use clearErrors()? I have code as follow:
>>>  public void onValidate() throws EncoderException {
>>>         _form.clearErrors();  
>>>         // more validates...
>>> }
>>>
>>> if there is a previous error, it will be cleared, but if there is a new
>>> error, all the fields are cleared as well, any hints?
>>>
>>>
>>> Howard Lewis Ship wrote:
>>>> Form has a clearErrors() method.
>>>>
>>>> On 10/15/07, Angelo Chen <[hidden email]> wrote:
>>>>> Hi,
>>>>>
>>>>> I notice that when an error is recorded thru recordError, refreshing
>>>>> the
>>>>> form will not erase the error messages unlike when form was rejected by
>>>>> validator where pressing refresh in the browser can errase the errors
>>>>> and
>>>>> go
>>>>> back to the initial form screen, here is the code
>>>>> public void onValidate() throws EncoderException {
>>>>> _form.recordError("test error");
>>>>> }
>>>>>
>>>>> if this error is shown in the form, it will be there forever even you
>>>>> restart the browser, any hint?
>>>>> A.C.
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217
>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>> --
>>>> Howard M. Lewis Ship
>>>> Partner and Senior Architect at Feature50
>>>>
>>>> Creator Apache Tapestry and Apache HiveMind
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Kristian Marinkovic
i'm using 5.0.6-SNAPSHOT and exprience some strange behaviour
on properties with @Persist("flash"). if i hit ctrl+r (page reload) the
properties are not set back properly and therefore their value remains.

... but i have to check whether this is an error on my side

i'll report back when i finished my sample form and did some testing

g,
kris




Nick Westgate <[hidden email]>
16.10.2007 13:37
Bitte antworten an
"Tapestry users" <[hidden email]>


An
Tapestry users <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






Hmm, I'm seeing the same thing, although I only have an old T5.0.5 project
to play with at the moment. This will take some looking into.

Kris are you getting this behaviour?

Cheers,
Nick.


Angelo Chen wrote:
> Hi Nick,
>
> refreshing without a submit was my original question, but after applying
> clearErrors(), I meant form fields got cleared while the error was
displayed
> under onValidate(), anyway I have tried your approach (b), here is the
> result:
>
> When I did :
>  public void onValidate() throws EncoderException {
>       _form.recordError("Email address invalid");
> 1.
>    It displays error, and if I quit the browser and re-open the page,
error
> is gone, good. when I switch to other page then come back to the
original
> page, error is gone, good. when I click 'refresh', error remains, why?
>
> 2. I let "t:validate="required,minlength=8" emits some errors into the
same
> form, then click 'refresh', those new errors got erased, but the error
in #1

> remains, anyway to clear them totally?
>
>
>
>
>
> Nick Westgate wrote:
>> You mean refreshing without a submit, right? So onValidate isn't
>> called in that case - only when the form submits. You can clear
>> the form errors in an event handler, but realistically this can
>> become problematic ...
>>
>> It's likely that the behaviour you want can be provided by:
>>
>> (a) copying and changing Form - see (b)
>>
>> or
>>
>> (b) deriving from Form and flash persisting the ValidationTracker:
>>
>> package yourapp.tapestry.components;
>>
>> import org.apache.tapestry.ValidationTracker;
>> import org.apache.tapestry.ValidationTrackerImpl;
>> import org.apache.tapestry.annotations.Persist;
>>
>> public class Form extends org.apache.tapestry.corelib.components.Form
>> {
>>      @Persist("flash")
>>      private ValidationTracker defaultTracker;
>>
>>      @Override
>>      public ValidationTracker getDefaultTracker()
>>      {
>>          if (defaultTracker == null)
>>              defaultTracker = new ValidationTrackerImpl();
>>
>>          return defaultTracker;
>>      }
>>
>>      @Override
>>      public void setDefaultTracker(ValidationTracker defaultTracker)
>>      {
>>          this.defaultTracker = defaultTracker;
>>      }
>> }
>>
>> Cheers,
>> Nick.
>>
>>
>> Angelo Chen wrote:
>>> Hi Howard,
>>>
>>> What is the right spot to use clearErrors()? I have code as follow:
>>>  public void onValidate() throws EncoderException {
>>>         _form.clearErrors();
>>>         // more validates...
>>> }
>>>
>>> if there is a previous error, it will be cleared, but if there is a
new

>>> error, all the fields are cleared as well, any hints?
>>>
>>>
>>> Howard Lewis Ship wrote:
>>>> Form has a clearErrors() method.
>>>>
>>>> On 10/15/07, Angelo Chen <[hidden email]> wrote:
>>>>> Hi,
>>>>>
>>>>> I notice that when an error is recorded thru recordError, refreshing
>>>>> the
>>>>> form will not erase the error messages unlike when form was rejected
by
>>>>> validator where pressing refresh in the browser can errase the
errors
>>>>> and
>>>>> go
>>>>> back to the initial form screen, here is the code
>>>>> public void onValidate() throws EncoderException {
>>>>> _form.recordError("test error");
>>>>> }
>>>>>
>>>>> if this error is shown in the form, it will be there forever even
you
>>>>> restart the browser, any hint?
>>>>> A.C.
>>>>> --
>>>>> View this message in context:
>>>>>
http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217

>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>
---------------------------------------------------------------------

>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>> --
>>>> Howard M. Lewis Ship
>>>> Partner and Senior Architect at Feature50
>>>>
>>>> Creator Apache Tapestry and Apache HiveMind
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Kristian Marinkovic
i experience the same form behaviour. when i do a
ctrl+r on the page wih the error message displayed
it wont disappear although the onValidate method is
not called and the ValidationTracker has "flash" scope...

i must admit i dont understand why this happens, i've to
dig deeper..... maybe some more coffee!?

... but the message will disappear if you clean it on
cleanupRender

void cleanupRender() {
    form.clearErrors();
}

g,
kris






Kristian Marinkovic <[hidden email]>
16.10.2007 13:53
Bitte antworten an
"Tapestry users" <[hidden email]>


An
"Tapestry users" <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






i'm using 5.0.6-SNAPSHOT and exprience some strange behaviour
on properties with @Persist("flash"). if i hit ctrl+r (page reload) the
properties are not set back properly and therefore their value remains.

... but i have to check whether this is an error on my side

i'll report back when i finished my sample form and did some testing

g,
kris




Nick Westgate <[hidden email]>
16.10.2007 13:37
Bitte antworten an
"Tapestry users" <[hidden email]>


An
Tapestry users <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






Hmm, I'm seeing the same thing, although I only have an old T5.0.5 project
to play with at the moment. This will take some looking into.

Kris are you getting this behaviour?

Cheers,
Nick.


Angelo Chen wrote:
> Hi Nick,
>
> refreshing without a submit was my original question, but after applying
> clearErrors(), I meant form fields got cleared while the error was
displayed
> under onValidate(), anyway I have tried your approach (b), here is the
> result:
>
> When I did :
>  public void onValidate() throws EncoderException {
>       _form.recordError("Email address invalid");
> 1.
>    It displays error, and if I quit the browser and re-open the page,
error
> is gone, good. when I switch to other page then come back to the
original
> page, error is gone, good. when I click 'refresh', error remains, why?
>
> 2. I let "t:validate="required,minlength=8" emits some errors into the
same
> form, then click 'refresh', those new errors got erased, but the error
in #1

> remains, anyway to clear them totally?
>
>
>
>
>
> Nick Westgate wrote:
>> You mean refreshing without a submit, right? So onValidate isn't
>> called in that case - only when the form submits. You can clear
>> the form errors in an event handler, but realistically this can
>> become problematic ...
>>
>> It's likely that the behaviour you want can be provided by:
>>
>> (a) copying and changing Form - see (b)
>>
>> or
>>
>> (b) deriving from Form and flash persisting the ValidationTracker:
>>
>> package yourapp.tapestry.components;
>>
>> import org.apache.tapestry.ValidationTracker;
>> import org.apache.tapestry.ValidationTrackerImpl;
>> import org.apache.tapestry.annotations.Persist;
>>
>> public class Form extends org.apache.tapestry.corelib.components.Form
>> {
>>      @Persist("flash")
>>      private ValidationTracker defaultTracker;
>>
>>      @Override
>>      public ValidationTracker getDefaultTracker()
>>      {
>>          if (defaultTracker == null)
>>              defaultTracker = new ValidationTrackerImpl();
>>
>>          return defaultTracker;
>>      }
>>
>>      @Override
>>      public void setDefaultTracker(ValidationTracker defaultTracker)
>>      {
>>          this.defaultTracker = defaultTracker;
>>      }
>> }
>>
>> Cheers,
>> Nick.
>>
>>
>> Angelo Chen wrote:
>>> Hi Howard,
>>>
>>> What is the right spot to use clearErrors()? I have code as follow:
>>>  public void onValidate() throws EncoderException {
>>>         _form.clearErrors();
>>>         // more validates...
>>> }
>>>
>>> if there is a previous error, it will be cleared, but if there is a
new

>>> error, all the fields are cleared as well, any hints?
>>>
>>>
>>> Howard Lewis Ship wrote:
>>>> Form has a clearErrors() method.
>>>>
>>>> On 10/15/07, Angelo Chen <[hidden email]> wrote:
>>>>> Hi,
>>>>>
>>>>> I notice that when an error is recorded thru recordError, refreshing
>>>>> the
>>>>> form will not erase the error messages unlike when form was rejected

by
>>>>> validator where pressing refresh in the browser can errase the
errors
>>>>> and
>>>>> go
>>>>> back to the initial form screen, here is the code
>>>>> public void onValidate() throws EncoderException {
>>>>> _form.recordError("test error");
>>>>> }
>>>>>
>>>>> if this error is shown in the form, it will be there forever even
you
>>>>> restart the browser, any hint?
>>>>> A.C.
>>>>> --
>>>>> View this message in context:
>>>>>
http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217


>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>
---------------------------------------------------------------------

>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>> --
>>>> Howard M. Lewis Ship
>>>> Partner and Senior Architect at Feature50
>>>>
>>>> Creator Apache Tapestry and Apache HiveMind
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Kristian Marinkovic
hi nick,

if you debug your (our) alternative form component you
will see that the ValidationTracker mytracker is NOT null
if you just refresh the page (breakpoint at getDefaultTracker).
and contains the old values.

i suppose "flash" does not cleanup the objects correctly
and leaves them in the session. or maybe there is some
sideeffect with components and parameters... need more test


public class Form extends org.apache.tapestry.corelib.components.Form {
    @Persist("flash")
    private ValidationTracker mytracker;
 
    @Override
    public ValidationTracker getDefaultTracker() {
        if(mytracker == null)
            mytracker = new ValidationTrackerImpl();
        return mytracker;
    }

g,
kris



Kristian Marinkovic <[hidden email]>
16.10.2007 15:05
Bitte antworten an
"Tapestry users" <[hidden email]>


An
"Tapestry users" <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






i experience the same form behaviour. when i do a
ctrl+r on the page wih the error message displayed
it wont disappear although the onValidate method is
not called and the ValidationTracker has "flash" scope...

i must admit i dont understand why this happens, i've to
dig deeper..... maybe some more coffee!?

... but the message will disappear if you clean it on
cleanupRender

void cleanupRender() {
    form.clearErrors();
}

g,
kris






Kristian Marinkovic <[hidden email]>
16.10.2007 13:53
Bitte antworten an
"Tapestry users" <[hidden email]>


An
"Tapestry users" <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






i'm using 5.0.6-SNAPSHOT and exprience some strange behaviour
on properties with @Persist("flash"). if i hit ctrl+r (page reload) the
properties are not set back properly and therefore their value remains.

... but i have to check whether this is an error on my side

i'll report back when i finished my sample form and did some testing

g,
kris




Nick Westgate <[hidden email]>
16.10.2007 13:37
Bitte antworten an
"Tapestry users" <[hidden email]>


An
Tapestry users <[hidden email]>
Kopie

Thema
Re: T5: refreshing page when there is an error






Hmm, I'm seeing the same thing, although I only have an old T5.0.5 project
to play with at the moment. This will take some looking into.

Kris are you getting this behaviour?

Cheers,
Nick.


Angelo Chen wrote:
> Hi Nick,
>
> refreshing without a submit was my original question, but after applying
> clearErrors(), I meant form fields got cleared while the error was
displayed
> under onValidate(), anyway I have tried your approach (b), here is the
> result:
>
> When I did :
>  public void onValidate() throws EncoderException {
>       _form.recordError("Email address invalid");
> 1.
>    It displays error, and if I quit the browser and re-open the page,
error
> is gone, good. when I switch to other page then come back to the
original
> page, error is gone, good. when I click 'refresh', error remains, why?
>
> 2. I let "t:validate="required,minlength=8" emits some errors into the
same
> form, then click 'refresh', those new errors got erased, but the error
in #1

> remains, anyway to clear them totally?
>
>
>
>
>
> Nick Westgate wrote:
>> You mean refreshing without a submit, right? So onValidate isn't
>> called in that case - only when the form submits. You can clear
>> the form errors in an event handler, but realistically this can
>> become problematic ...
>>
>> It's likely that the behaviour you want can be provided by:
>>
>> (a) copying and changing Form - see (b)
>>
>> or
>>
>> (b) deriving from Form and flash persisting the ValidationTracker:
>>
>> package yourapp.tapestry.components;
>>
>> import org.apache.tapestry.ValidationTracker;
>> import org.apache.tapestry.ValidationTrackerImpl;
>> import org.apache.tapestry.annotations.Persist;
>>
>> public class Form extends org.apache.tapestry.corelib.components.Form
>> {
>>      @Persist("flash")
>>      private ValidationTracker defaultTracker;
>>
>>      @Override
>>      public ValidationTracker getDefaultTracker()
>>      {
>>          if (defaultTracker == null)
>>              defaultTracker = new ValidationTrackerImpl();
>>
>>          return defaultTracker;
>>      }
>>
>>      @Override
>>      public void setDefaultTracker(ValidationTracker defaultTracker)
>>      {
>>          this.defaultTracker = defaultTracker;
>>      }
>> }
>>
>> Cheers,
>> Nick.
>>
>>
>> Angelo Chen wrote:
>>> Hi Howard,
>>>
>>> What is the right spot to use clearErrors()? I have code as follow:
>>>  public void onValidate() throws EncoderException {
>>>         _form.clearErrors();
>>>         // more validates...
>>> }
>>>
>>> if there is a previous error, it will be cleared, but if there is a
new

>>> error, all the fields are cleared as well, any hints?
>>>
>>>
>>> Howard Lewis Ship wrote:
>>>> Form has a clearErrors() method.
>>>>
>>>> On 10/15/07, Angelo Chen <[hidden email]> wrote:
>>>>> Hi,
>>>>>
>>>>> I notice that when an error is recorded thru recordError, refreshing
>>>>> the
>>>>> form will not erase the error messages unlike when form was rejected


by
>>>>> validator where pressing refresh in the browser can errase the
errors
>>>>> and
>>>>> go
>>>>> back to the initial form screen, here is the code
>>>>> public void onValidate() throws EncoderException {
>>>>> _form.recordError("test error");
>>>>> }
>>>>>
>>>>> if this error is shown in the form, it will be there forever even
you
>>>>> restart the browser, any hint?
>>>>> A.C.
>>>>> --
>>>>> View this message in context:
>>>>>
http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217



>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>
---------------------------------------------------------------------

>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>> --
>>>> Howard M. Lewis Ship
>>>> Partner and Senior Architect at Feature50
>>>>
>>>> Creator Apache Tapestry and Apache HiveMind
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

Nick Westgate
Yes, I did that too, and also copied all the Form classes
and modified the ValidationTracker persistence directly.

Between requests the form cannot be caching anything unless
the pooling is not cleaning up properly, or else the flash
persist must be broken somehow. Unfortunately, I don't have
time to debug this right now though.

The cleanupRender answers Angelo's original question. ;-)

Cheers,
Nick.


Kristian Marinkovic wrote:

> hi nick,
>
> if you debug your (our) alternative form component you
> will see that the ValidationTracker mytracker is NOT null
> if you just refresh the page (breakpoint at getDefaultTracker).
> and contains the old values.
>
> i suppose "flash" does not cleanup the objects correctly
> and leaves them in the session. or maybe there is some
> sideeffect with components and parameters... need more test
>
>
> public class Form extends org.apache.tapestry.corelib.components.Form {
>     @Persist("flash")
>     private ValidationTracker mytracker;
>  
>     @Override
>     public ValidationTracker getDefaultTracker() {
>         if(mytracker == null)
>             mytracker = new ValidationTrackerImpl();
>         return mytracker;
>     }
>
> g,
> kris
>
>
>
> Kristian Marinkovic <[hidden email]>
> 16.10.2007 15:05
> Bitte antworten an
> "Tapestry users" <[hidden email]>
>
>
> An
> "Tapestry users" <[hidden email]>
> Kopie
>
> Thema
> Re: T5: refreshing page when there is an error
>
>
>
>
>
>
> i experience the same form behaviour. when i do a
> ctrl+r on the page wih the error message displayed
> it wont disappear although the onValidate method is
> not called and the ValidationTracker has "flash" scope...
>
> i must admit i dont understand why this happens, i've to
> dig deeper..... maybe some more coffee!?
>
> ... but the message will disappear if you clean it on
> cleanupRender
>
> void cleanupRender() {
>     form.clearErrors();
> }
>
> g,
> kris
>
>
>
>
>
>
> Kristian Marinkovic <[hidden email]>
> 16.10.2007 13:53
> Bitte antworten an
> "Tapestry users" <[hidden email]>
>
>
> An
> "Tapestry users" <[hidden email]>
> Kopie
>
> Thema
> Re: T5: refreshing page when there is an error
>
>
>
>
>
>
> i'm using 5.0.6-SNAPSHOT and exprience some strange behaviour
> on properties with @Persist("flash"). if i hit ctrl+r (page reload) the
> properties are not set back properly and therefore their value remains.
>
> ... but i have to check whether this is an error on my side
>
> i'll report back when i finished my sample form and did some testing
>
> g,
> kris
>
>
>
>
> Nick Westgate <[hidden email]>
> 16.10.2007 13:37
> Bitte antworten an
> "Tapestry users" <[hidden email]>
>
>
> An
> Tapestry users <[hidden email]>
> Kopie
>
> Thema
> Re: T5: refreshing page when there is an error
>
>
>
>
>
>
> Hmm, I'm seeing the same thing, although I only have an old T5.0.5 project
> to play with at the moment. This will take some looking into.
>
> Kris are you getting this behaviour?
>
> Cheers,
> Nick.
>
>
> Angelo Chen wrote:
>> Hi Nick,
>>
>> refreshing without a submit was my original question, but after applying
>> clearErrors(), I meant form fields got cleared while the error was
> displayed
>> under onValidate(), anyway I have tried your approach (b), here is the
>> result:
>>
>> When I did :
>>  public void onValidate() throws EncoderException {
>>       _form.recordError("Email address invalid");
>> 1.
>>    It displays error, and if I quit the browser and re-open the page,
> error
>> is gone, good. when I switch to other page then come back to the
> original
>> page, error is gone, good. when I click 'refresh', error remains, why?
>>
>> 2. I let "t:validate="required,minlength=8" emits some errors into the
> same
>> form, then click 'refresh', those new errors got erased, but the error
> in #1
>> remains, anyway to clear them totally?
>>
>>
>>
>>
>>
>> Nick Westgate wrote:
>>> You mean refreshing without a submit, right? So onValidate isn't
>>> called in that case - only when the form submits. You can clear
>>> the form errors in an event handler, but realistically this can
>>> become problematic ...
>>>
>>> It's likely that the behaviour you want can be provided by:
>>>
>>> (a) copying and changing Form - see (b)
>>>
>>> or
>>>
>>> (b) deriving from Form and flash persisting the ValidationTracker:
>>>
>>> package yourapp.tapestry.components;
>>>
>>> import org.apache.tapestry.ValidationTracker;
>>> import org.apache.tapestry.ValidationTrackerImpl;
>>> import org.apache.tapestry.annotations.Persist;
>>>
>>> public class Form extends org.apache.tapestry.corelib.components.Form
>>> {
>>>      @Persist("flash")
>>>      private ValidationTracker defaultTracker;
>>>
>>>      @Override
>>>      public ValidationTracker getDefaultTracker()
>>>      {
>>>          if (defaultTracker == null)
>>>              defaultTracker = new ValidationTrackerImpl();
>>>
>>>          return defaultTracker;
>>>      }
>>>
>>>      @Override
>>>      public void setDefaultTracker(ValidationTracker defaultTracker)
>>>      {
>>>          this.defaultTracker = defaultTracker;
>>>      }
>>> }
>>>
>>> Cheers,
>>> Nick.
>>>
>>>
>>> Angelo Chen wrote:
>>>> Hi Howard,
>>>>
>>>> What is the right spot to use clearErrors()? I have code as follow:
>>>>  public void onValidate() throws EncoderException {
>>>>         _form.clearErrors();
>>>>         // more validates...
>>>> }
>>>>
>>>> if there is a previous error, it will be cleared, but if there is a
> new
>>>> error, all the fields are cleared as well, any hints?
>>>>
>>>>
>>>> Howard Lewis Ship wrote:
>>>>> Form has a clearErrors() method.
>>>>>
>>>>> On 10/15/07, Angelo Chen <[hidden email]> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I notice that when an error is recorded thru recordError, refreshing
>>>>>> the
>>>>>> form will not erase the error messages unlike when form was rejected
>
>
> by
>>>>>> validator where pressing refresh in the browser can errase the
> errors
>>>>>> and
>>>>>> go
>>>>>> back to the initial form screen, here is the code
>>>>>> public void onValidate() throws EncoderException {
>>>>>> _form.recordError("test error");
>>>>>> }
>>>>>>
>>>>>> if this error is shown in the form, it will be there forever even
> you
>>>>>> restart the browser, any hint?
>>>>>> A.C.
>>>>>> --
>>>>>> View this message in context:
>>>>>>
> http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13214217
>
>
>
>>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>>
> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>>
>>>>> --
>>>>> Howard M. Lewis Ship
>>>>> Partner and Senior Architect at Feature50
>>>>>
>>>>> Creator Apache Tapestry and Apache HiveMind
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: refreshing page when there is an error

smithfox
In reply to this post by Nick Westgate

Has this JIRA been solved in 5.0.7??

<quote author="Nick Westgate">
Go ahead and add a JIRA. A patch to make it configurable would be great. ;-)

Actually I just remembered that it is configurable in that the persistence
strategy is inherited from the Form's container, but it seems most of us
agree that we don't want a default of flash for our pages - only for Form.

Session persistence for the ValidationTracker does make sense if returning
to an edit page via action (not submit) should retain the previous errors.

Cheers,
Nick.