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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>
>>> --
>>> Howard M. Lewis Ship
>>> Partner and Senior Architect at Feature50
>>>
>>> Creator Apache Tapestry and Apache HiveMind
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/T5%3A-refreshing-page-when-there-is-an-error-tf4627982.html#a13230141
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]