After 4 hours of banging my head against the wall, I figured it out:

    <component id="usernameField" type="TextField">
        <binding name="value" value="user.username"/>
        <binding name="validators" value="validators:required"/>
        <binding name="displayName" value="message:user.username"/>
    </component>

I had:

    <component id="usernameField" type="TextField">
        <binding name="value" value="user.username"/>
        <binding name="validator" value="validators:required"/>
        <binding name="displayName" value="message:user.username"/>
    </component>

validator vs. validators.  IMO, Tapestry/Hivemind should thrown an
exception when you try to bind a name to a property that doesn't
exist.  Spring does this.

Matt



On 3/30/06, Mike Snare <[EMAIL PROTECTED]> wrote:
> If you're migrating to 4.0, get Kent Tong's book: Enjoying Web
> Development with Tapestry.  It covers 4.0.
>
> The first 4 chapters are free in pdf form (just google it) and chapter
> 3 deals with validation.
>
> -Mike
>
> On 3/30/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
> > http://jakarta.apache.org/tapestry/tapestry/ComponentReference/Form.html
> >
> > Try the form delegate parameter.
> >
> > For more, look at
> > http://jakarta.apache.org/tapestry/UsersGuide/validation.html .
> >
> > On 3/30/06, Matt Raible <[EMAIL PROTECTED]> wrote:
> > >
> > > Thanks - that appears to work. However, now I've discovered that
> > > validation doesn't work at all.  In Tapestry 3.0.3, I was using a
> > > custom ValidationDelegate that I found in Tapestry in Action.
> > > Unfortunately, it doesn't seem to work in Tapestry 4.  I'm setting it
> > > in my page-specification using:
> > >
> > > <bean name="delegate" class="org.appfuse.webapp.action.Validator"/>
> > >
> > > Is there a different way to set this in 4.0?
> > >
> > > The other problem I have with this Validator in 4.0 is there's now a
> > > nested <label> inside the <label> I'm writing.  Is it possible to set
> > > the "required" class on the <label> that Tapestry writes?
> > >
> > > public class Validator extends ValidationDelegate {
> > >     private static final long serialVersionUID = 6658594142293597652L;
> > >
> > >     public void writeLabelPrefix(IFormComponent component,
> > >                                  IMarkupWriter writer, IRequestCycle
> > > cycle) {
> > >         writer.begin("label");
> > >
> > >         if (isInError(component)) {
> > >             writer.attribute("class", "error");
> > >         } else {
> > >             writer.attribute("class", "required");
> > >         }
> > >
> > >         writer.print(" * ");
> > >     }
> > >
> > >     public void writeLabelSuffix(IFormComponent component,
> > >                                  IMarkupWriter writer, IRequestCycle
> > > cycle) {
> > >         Locale locale = cycle.getEngine().getLocale();
> > >         String marker = (locale.equals(Locale.FRENCH)) ? " :" : ":";
> > >         writer.print(marker);
> > >         writer.end();
> > >     }
> > >
> > >     public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
> > >                                 IFormComponent component, IValidator
> > > validator) {
> > >         if (isInError()) {
> > >             writer.attribute("class", "error");
> > >         }
> > >     }
> > >
> > >     public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
> > >                             IFormComponent component, IValidator
> > > validator) {
> > >         if (isInError(component)) {
> > >             writer.printRaw("&nbsp;");
> > >             writer.begin("img");
> > >
> > >             String ctxPath = cycle.getInfrastructure().getContextPath();
> > >             writer.attribute("src", ctxPath + "/images/iconWarning.gif");
> > >             writer.attribute("class", "validationWarning");
> > >             writer.attribute("alt",
> > > cycle.getPage().getMessages().getMessage("icon.warning"));
> > >             writer.end();
> > >
> > >             writer.printRaw("&nbsp;");
> > >
> > >             IFieldTracking tracking = getComponentTracking();
> > >             IRender render = tracking.getErrorRenderer();
> > >             String error = "";
> > >
> > >             if (render instanceof RenderString) {
> > >                 error = ((RenderString) render).getString();
> > >             }
> > >
> > >             writer.begin("span");
> > >             writer.attribute("class", "fieldError");
> > >             writer.printRaw(error);
> > >             writer.end();
> > >         }
> > >     }
> > > }
> > >
> > > Thanks,
> > >
> > > Matt
> > >
> > >
> > >
> > > On 3/30/06, Mike Snare <[EMAIL PROTECTED]> wrote:
> > > > try replacing
> > > >
> > > > value="\\d{5}(-\\d{4})?"
> > > >
> > > > with
> > > >
> > > > value="literal:\\d{5}(-\\d{4})?"
> > > >
> > > > See if that works.
> > > >
> > > > -Mike
> > > >
> > > > On 3/30/06, Matt Raible <[EMAIL PROTECTED]> wrote:
> > > > > This worked in 3.0.3:
> > > > >
> > > > >    <bean name="zipValidator"
> > > > > class="org.apache.tapestry.valid.PatternValidator">
> > > > >        <set name="patternString" value="\\d{5}(-\\d{4})?"/>
> > > > >        <set name="required" value="true"/>
> > > > >        <set name="patternNotMatchedMessage" value="message:errors.zip
> > > "/>
> > > > >        <set name="clientScriptingEnabled" value="true"/>
> > > > >    </bean>
> > > > >
> > > > > But this doesn't work in 4.0:
> > > > >
> > > > > Unable to read OGNL expression '<parsed OGNL expression>' of
> > > > > [EMAIL PROTECTED]: Error initializing property
> > > > > patternString of bean 'zipValidator' (of component signup): Unable to
> > > > > parse OGNL expression '\\d{5}(-\\d{4})?': Malformed OGNL expression:
> > > > > \\d{5}(-\\d{4})?
> > > > >
> > > > > Any idea how to fix this?  How did the regular expression syntax
> > > change?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Matt
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tacos/Tapestry, team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind.  http://opennotion.com
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to