[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: Required field decoration
From:       Stephane Decleire <sdecleire () cariboo-networks ! com>
Date:       2006-04-30 21:08:30
Message-ID: 4455274E.3060006 () cariboo-networks ! com
[Download RAW message or body]


Thanks a lot Ryan, it works !

Ryan Holmes wrote:

> Instead of:
> if (validator != null && validator.isRequired())
>
> try:
> if (component.isRequired())
>
> "component" will never be null, so you don't have to worry about the 
> null check.
>
> Also, make sure you are setting the "delegate" parameter of your form 
> component to an instance of your custom IValidationDelegate. For 
> instance, your page spec could have the following:
>
>    <component id="form" type="Form">
>        <binding name="delegate" value="validationDelegate" />
>    </component>
>
> with this method in your page class:
>
>  @Bean(MyValidationDelegate.class)
>  public abstract IValidationDelegate getValidationDelegate();
>
> You can also configure both in the page spec, both in the page class, 
> etc. I tend to use the combination above because I usually have a base 
> class for "edit" pages and want to use the same validation delegate 
> for every form (whereas my form component specs may change from page 
> to page).
>
> -Ryan
>
> Stephane Decleire wrote:
>
>> Hi,
>>
>> I've tried to reuse in my T4 application the way HLS has implemented 
>> required field decoration with an "*" in his book "Tapestry In Action" :
>>
>> My field is set "required" in my registration.page :
>>
>>    <component id="firstname" type="TextField">
>>        <binding name="value" value="firstname"/>
>>        <binding name="displayName" value="message:firstname-label"/>
>>        <binding name="validators" 
>> value="validators:required,maxLength=30"/>
>>    </component>
>>
>> And i've subclassed the ValidationDelegate by surcharging the 
>> writeSuffix function :
>>
>>    public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, 
>> IFormComponent component, IValidator validator) {
>>        if (validator != null && validator.isRequired()) {
>>            writer.printRaw("&nbsp;");
>>            writer.begin("span");
>>            writer.attribute("class", "required-marker");
>>            writer.print("*");
>>            writer.end();
>>        }
>>    }
>>
>> But my required marker is never visible on my form ...
>> Any idea is welcome.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>

-- 
Stéphane Decleire

05 56 57 99 20
06 63 78 69 06



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic