tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Lewis" <br...@maine.rr.com>
Subject Re: Do I really need to clear the validationDelegate?
Date Mon, 18 Aug 2003 12:24:46 GMT
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" <hkrishnaswamy@comcast.net>
To: "Tapestry users" <tapestry-user@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
> 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message