You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bryan Lewis <br...@maine.rr.com> on 2003/08/17 17:10:08 UTC
Do I really need to clear the validationDelegate?
I have a simple form including a date field, a ValidField.
(Page specification shown below.)
It starts out fine... if the user enters a date with a syntax error, we stay
on the same page. The user sees the red asterisks, corrects the data
and re-submits. The problem is, the page remembers the previous error...
delegate.getHasErrors() still returns true.
I've worked around the problem by doing delegate.clear() in detach(),
but that doesn't feel right. I've searched the list, source, and docs, and
nobody else seems to need that... I suspect I'm missing something.
.page:
<bean name="delegate"
class="org.apache.tapestry.valid.ValidationDelegate"/>
<bean name="dateValidator"
class="org.apache.tapestry.valid.DateValidator">
<set-property name="required" expression="false"/>
<set-property name="maximum" expression="new java.util.Date()"/>
</bean>
<component id="dateField" type="ValidField">
<binding name="value" expression="data.lastPasswordDate"/>
<binding name="validator" expression="beans.dateValidator"/>
</component>
.java:
public void detach()
{
validationDelegate.clear(); // forget previous error
super.detach();
}
Re: Do I really need to clear the validationDelegate?
Posted by Harish Krishnaswamy <hk...@comcast.net>.
The default value for lifecycle is "request". Another doc-snippet from
the dtd.
Beans that have the "request" lifecycle may be stored into a pool
for later re-use (in the same or different page).
-Harish
Harish Krishnaswamy wrote:
> Beans have a lifecycle in Tapestry and it is configurable via the
> lifecycle attribute of the <bean.../> element. The following is a
> doc-snippet from the dtd.
>
> Attributes:
> name: the name of the bean
> class: the Java class to instantiate
> lifecycle: when the reference to the bean should be discard
> "none" no lifecycle, the bean is created and returned, but not
> stored
> "request" the bean is retained until the end of the request cycle
> "page" the bean is retained for the lifespan of the page
> "render" the bean is retained until the end of the current page
> render
>
> -Harish
>
> Bryan Lewis wrote:
>
>> I have a simple form including a date field, a ValidField.
>> (Page specification shown below.)
>>
>> It starts out fine... if the user enters a date with a syntax error,
>> we stay
>> on the same page. The user sees the red asterisks, corrects the data
>> and re-submits. The problem is, the page remembers the previous
>> error...
>> delegate.getHasErrors() still returns true.
>>
>> I've worked around the problem by doing delegate.clear() in detach(),
>> but that doesn't feel right. I've searched the list, source, and
>> docs, and
>> nobody else seems to need that... I suspect I'm missing something.
>>
>> .page:
>> <bean name="delegate"
>> class="org.apache.tapestry.valid.ValidationDelegate"/>
>>
>> <bean name="dateValidator"
>> class="org.apache.tapestry.valid.DateValidator">
>> <set-property name="required" expression="false"/>
>> <set-property name="maximum" expression="new
>> java.util.Date()"/>
>> </bean>
>>
>> <component id="dateField" type="ValidField">
>> <binding name="value" expression="data.lastPasswordDate"/>
>> <binding name="validator" expression="beans.dateValidator"/>
>> </component>
>>
>> .java:
>> public void detach()
>> {
>> validationDelegate.clear(); // forget previous error
>> super.detach();
>> }
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
RE: Do I really need to clear the validationDelegate?
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
>
> The more ya know, the easier it gets. Pretty soon I won't
> have any code left, just bindings. :-)
>
Tapestry: Java-less Web Components :-)
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
Re: Do I really need to clear the validationDelegate?
Posted by Bryan Lewis <br...@maine.rr.com>.
Thanks, I wasn't aware of that. But the problem turned out to be my misundertanding of how to allocate the delegate... I didn't need to bother with that in my code. I was doing:
public IValidationDelegate getValidationDelegate()
{
if (validationDelegate == null) { // doh! reusing the old one
validationDelegate = new ValidationDelegate();
}
return validationDelegate;
}
The Workbench's Fields example showed me the light -- call getBeans().getBean("delegate") when I need it, and let Tapestry handle the lifecycle for me.
The more ya know, the easier it gets. Pretty soon I won't have any code left, just bindings. :-)
----- Original Message -----
From: "Harish Krishnaswamy" <hk...@comcast.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Sunday, August 17, 2003 10:47 PM
Subject: Re: Do I really need to clear the validationDelegate?
> Beans have a lifecycle in Tapestry and it is configurable via the
> lifecycle attribute of the <bean.../> element. The following is a
> doc-snippet from the dtd.
>
> Attributes:
> name: the name of the bean
> class: the Java class to instantiate
> lifecycle: when the reference to the bean should be discard
> "none" no lifecycle, the bean is created and returned, but not stored
> "request" the bean is retained until the end of the request cycle
> "page" the bean is retained for the lifespan of the page
> "render" the bean is retained until the end of the current page render
>
> -Harish
>
> Bryan Lewis wrote:
>
> >I have a simple form including a date field, a ValidField.
> >(Page specification shown below.)
> >
> >It starts out fine... if the user enters a date with a syntax error, we stay
> >on the same page. The user sees the red asterisks, corrects the data
> >and re-submits. The problem is, the page remembers the previous error...
> >delegate.getHasErrors() still returns true.
> >
> >I've worked around the problem by doing delegate.clear() in detach(),
> >but that doesn't feel right. I've searched the list, source, and docs, and
> >nobody else seems to need that... I suspect I'm missing something.
> >
> > .page:
> > <bean name="delegate"
> >class="org.apache.tapestry.valid.ValidationDelegate"/>
> >
> > <bean name="dateValidator"
> >class="org.apache.tapestry.valid.DateValidator">
> > <set-property name="required" expression="false"/>
> > <set-property name="maximum" expression="new java.util.Date()"/>
> > </bean>
> >
> > <component id="dateField" type="ValidField">
> > <binding name="value" expression="data.lastPasswordDate"/>
> > <binding name="validator" expression="beans.dateValidator"/>
> > </component>
> >
> > .java:
> > public void detach()
> > {
> > validationDelegate.clear(); // forget previous error
> > super.detach();
> > }
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
Re: Do I really need to clear the validationDelegate?
Posted by Harish Krishnaswamy <hk...@comcast.net>.
Beans have a lifecycle in Tapestry and it is configurable via the
lifecycle attribute of the <bean.../> element. The following is a
doc-snippet from the dtd.
Attributes:
name: the name of the bean
class: the Java class to instantiate
lifecycle: when the reference to the bean should be discard
"none" no lifecycle, the bean is created and returned, but not stored
"request" the bean is retained until the end of the request cycle
"page" the bean is retained for the lifespan of the page
"render" the bean is retained until the end of the current page render
-Harish
Bryan Lewis wrote:
>I have a simple form including a date field, a ValidField.
>(Page specification shown below.)
>
>It starts out fine... if the user enters a date with a syntax error, we stay
>on the same page. The user sees the red asterisks, corrects the data
>and re-submits. The problem is, the page remembers the previous error...
>delegate.getHasErrors() still returns true.
>
>I've worked around the problem by doing delegate.clear() in detach(),
>but that doesn't feel right. I've searched the list, source, and docs, and
>nobody else seems to need that... I suspect I'm missing something.
>
> .page:
> <bean name="delegate"
>class="org.apache.tapestry.valid.ValidationDelegate"/>
>
> <bean name="dateValidator"
>class="org.apache.tapestry.valid.DateValidator">
> <set-property name="required" expression="false"/>
> <set-property name="maximum" expression="new java.util.Date()"/>
> </bean>
>
> <component id="dateField" type="ValidField">
> <binding name="value" expression="data.lastPasswordDate"/>
> <binding name="validator" expression="beans.dateValidator"/>
> </component>
>
> .java:
> public void detach()
> {
> validationDelegate.clear(); // forget previous error
> super.detach();
> }
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>