You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Marilen Corciovei <le...@nemesisit.rdsnet.ro> on 2004/03/24 03:09:34 UTC

Validation and the delegate

Hi, I have just started on a new application with Tapestry (using
3.0beta4 this time). I have encountered a few problems. Maybe some of
you can explain to me the proper usage in the following case.

The page is a complex form containing a few ValidFields which use a
delegate to record the errors. My delegate extends the
ValidationDelegate class. I am trying to add a few other error messages
to the Delegate for some extended data validation (for instance "the
password and the confirmation password are not equal").

public void formSubmit(IRequestCycle cycle) {
        ValidationDelegate delegate =
(ValidationDelegate)getBeans().getBean("delegate");

        if(!getPassword().equals(getConfirm())){
                delegate.setFormComponent(null);
                delegate.record(new ValidatorException("Parola nu este
confirmata"));
        }

        if(!delegate.getHasErrors()){
                    ... process
        }
}

My problem is that I do not know where I should clear this error. I
tried to do that in the detach() function yet this results in error. 

Any assistance, hint appreciated
Len


Marilen Aretius Corciovei
Independent J2EE, Linux consultant
http://nemesisit.rdsnet.ro/len
http://www.nemesisit.ro

Re: Validation and the delegaten

Posted by Marilen Corciovei <le...@nemesisit.rdsnet.ro>.
Thank you very much, I realy think the bean lifecycle is the key to my
problem. For some unknown reason even if it defaults to render the bean
seems to be kept after the page rendered until the next request. I will
investigate further.

Thanks again, Len

On Wed, 2004-03-24 at 04:37, Erik Hatcher wrote:

> Why do you need to clear the error?  I'm not quite sure what you mean 
> by "clear" in this case - wouldn't you just redisplay the entry page 
> with the error messages hilighted?  What is your <bean> lifecycle set 
> to?  I think I use page for mine.
> 
> 	Erik
> 
> On Mar 23, 2004, at 9:09 PM, Marilen Corciovei wrote:
> 
> > Hi, I have just started on a new application with Tapestry (using
> > 3.0beta4 this time). I have encountered a few problems. Maybe some of
> > you can explain to me the proper usage in the following case.
> >
> > The page is a complex form containing a few ValidFields which use a
> > delegate to record the errors. My delegate extends the
> > ValidationDelegate class. I am trying to add a few other error messages
> > to the Delegate for some extended data validation (for instance "the
> > password and the confirmation password are not equal").
> >
> > public void formSubmit(IRequestCycle cycle) {
> >         ValidationDelegate delegate =
> > (ValidationDelegate)getBeans().getBean("delegate");
> >
> >         if(!getPassword().equals(getConfirm())){
> >                 delegate.setFormComponent(null);
> >                 delegate.record(new ValidatorException("Parola nu este
> > confirmata"));
> >         }
> >
> >         if(!delegate.getHasErrors()){
> >                     ... process
> >         }
> > }
> >
> > My problem is that I do not know where I should clear this error. I
> > tried to do that in the detach() function yet this results in error.
> >
> > Any assistance, hint appreciated
> > Len
> >
> >
> > Marilen Aretius Corciovei
> > Independent J2EE, Linux consultant
> > http://nemesisit.rdsnet.ro/len
> > http://www.nemesisit.ro
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 

Resin xml parsers (was Validation and the delegate)

Posted by Marilen Corciovei <le...@nemesisit.rdsnet.ro>.
I finally tracked the problem to this post:
http://www.caucho.com/support/resin-interest/0205/0112.html. It seems
the default attribute is ignored so the solution was to add 

<bean name="delegate" class="ro.nit.components.NitValidationDelegate"
lifecycle="request"/>

Len

Marilen Aretius Corciovei
Independent J2EE, Linux consultant
http://nemesisit.rdsnet.ro/len
http://www.nemesisit.ro

On Wed, 2004-03-24 at 05:02, Marilen Corciovei wrote:

> Hi Erik,
> 
> The problem is Resin (3.0.6 in my case) specific. The delegate bean is
> not destroyed when the page finishes rendering. I deployed the
> application in tomcat and everything works as desired.
> 
> Output on after 2 page submits:
> 
> resin:
> delegate = ro.nit.components.NitValidationDelegate@fccada
> delegate = ro.nit.components.NitValidationDelegate@fccada
> 
> tomcat:
> delegate = ro.nit.components.NitValidationDelegate@c26ede
> delegate = ro.nit.components.NitValidationDelegate@1710be
> 
> Any suggestions?
> 
> Len
> 
> On Wed, 2004-03-24 at 04:37, Erik Hatcher wrote:
> 
> > Why do you need to clear the error?  I'm not quite sure what you mean 
> > by "clear" in this case - wouldn't you just redisplay the entry page 
> > with the error messages hilighted?  What is your <bean> lifecycle set 
> > to?  I think I use page for mine.
> > 
> > 	Erik
> > 
> > On Mar 23, 2004, at 9:09 PM, Marilen Corciovei wrote:
> > 
> > > Hi, I have just started on a new application with Tapestry (using
> > > 3.0beta4 this time). I have encountered a few problems. Maybe some of
> > > you can explain to me the proper usage in the following case.
> > >
> > > The page is a complex form containing a few ValidFields which use a
> > > delegate to record the errors. My delegate extends the
> > > ValidationDelegate class. I am trying to add a few other error messages
> > > to the Delegate for some extended data validation (for instance "the
> > > password and the confirmation password are not equal").
> > >
> > > public void formSubmit(IRequestCycle cycle) {
> > >         ValidationDelegate delegate =
> > > (ValidationDelegate)getBeans().getBean("delegate");
> > >
> > >         if(!getPassword().equals(getConfirm())){
> > >                 delegate.setFormComponent(null);
> > >                 delegate.record(new ValidatorException("Parola nu este
> > > confirmata"));
> > >         }
> > >
> > >         if(!delegate.getHasErrors()){
> > >                     ... process
> > >         }
> > > }
> > >
> > > My problem is that I do not know where I should clear this error. I
> > > tried to do that in the detach() function yet this results in error.
> > >
> > > Any assistance, hint appreciated
> > > Len
> > >
> > >
> > > Marilen Aretius Corciovei
> > > Independent J2EE, Linux consultant
> > > http://nemesisit.rdsnet.ro/len
> > > http://www.nemesisit.ro
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > 
> > 

Re: Validation and the delegate (problem is resin specific)

Posted by Marilen Corciovei <le...@nemesisit.rdsnet.ro>.
Hi Erik,

The problem is Resin (3.0.6 in my case) specific. The delegate bean is
not destroyed when the page finishes rendering. I deployed the
application in tomcat and everything works as desired.

Output on after 2 page submits:

resin:
delegate = ro.nit.components.NitValidationDelegate@fccada
delegate = ro.nit.components.NitValidationDelegate@fccada

tomcat:
delegate = ro.nit.components.NitValidationDelegate@c26ede
delegate = ro.nit.components.NitValidationDelegate@1710be

Any suggestions?

Len

On Wed, 2004-03-24 at 04:37, Erik Hatcher wrote:

> Why do you need to clear the error?  I'm not quite sure what you mean 
> by "clear" in this case - wouldn't you just redisplay the entry page 
> with the error messages hilighted?  What is your <bean> lifecycle set 
> to?  I think I use page for mine.
> 
> 	Erik
> 
> On Mar 23, 2004, at 9:09 PM, Marilen Corciovei wrote:
> 
> > Hi, I have just started on a new application with Tapestry (using
> > 3.0beta4 this time). I have encountered a few problems. Maybe some of
> > you can explain to me the proper usage in the following case.
> >
> > The page is a complex form containing a few ValidFields which use a
> > delegate to record the errors. My delegate extends the
> > ValidationDelegate class. I am trying to add a few other error messages
> > to the Delegate for some extended data validation (for instance "the
> > password and the confirmation password are not equal").
> >
> > public void formSubmit(IRequestCycle cycle) {
> >         ValidationDelegate delegate =
> > (ValidationDelegate)getBeans().getBean("delegate");
> >
> >         if(!getPassword().equals(getConfirm())){
> >                 delegate.setFormComponent(null);
> >                 delegate.record(new ValidatorException("Parola nu este
> > confirmata"));
> >         }
> >
> >         if(!delegate.getHasErrors()){
> >                     ... process
> >         }
> > }
> >
> > My problem is that I do not know where I should clear this error. I
> > tried to do that in the detach() function yet this results in error.
> >
> > Any assistance, hint appreciated
> > Len
> >
> >
> > Marilen Aretius Corciovei
> > Independent J2EE, Linux consultant
> > http://nemesisit.rdsnet.ro/len
> > http://www.nemesisit.ro
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 

Re: Validation and the delegate

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Why do you need to clear the error?  I'm not quite sure what you mean 
by "clear" in this case - wouldn't you just redisplay the entry page 
with the error messages hilighted?  What is your <bean> lifecycle set 
to?  I think I use page for mine.

	Erik

On Mar 23, 2004, at 9:09 PM, Marilen Corciovei wrote:

> Hi, I have just started on a new application with Tapestry (using
> 3.0beta4 this time). I have encountered a few problems. Maybe some of
> you can explain to me the proper usage in the following case.
>
> The page is a complex form containing a few ValidFields which use a
> delegate to record the errors. My delegate extends the
> ValidationDelegate class. I am trying to add a few other error messages
> to the Delegate for some extended data validation (for instance "the
> password and the confirmation password are not equal").
>
> public void formSubmit(IRequestCycle cycle) {
>         ValidationDelegate delegate =
> (ValidationDelegate)getBeans().getBean("delegate");
>
>         if(!getPassword().equals(getConfirm())){
>                 delegate.setFormComponent(null);
>                 delegate.record(new ValidatorException("Parola nu este
> confirmata"));
>         }
>
>         if(!delegate.getHasErrors()){
>                     ... process
>         }
> }
>
> My problem is that I do not know where I should clear this error. I
> tried to do that in the detach() function yet this results in error.
>
> Any assistance, hint appreciated
> Len
>
>
> Marilen Aretius Corciovei
> Independent J2EE, Linux consultant
> http://nemesisit.rdsnet.ro/len
> http://www.nemesisit.ro


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