You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Onno Scheffers <on...@AtomicDigitalStudios.com> on 2005/09/04 18:02:17 UTC

ValidationDelegate writeSuffix

In Tapestry 3 I used to write my own ValidationDelegate, implementing 
the writeSuffix method to render a '*' behind each required field in a 
form or an error-message if that field was in error.

As was discussed before on this list, in Tapestry 4 the writeSuffix 
method is now called for all sort of stuff, and it will have a 
null-value for the validator parameters when called for TextField, 
TextArea, etc. This breaks my previous solution, because I need access 
to the validator to see if it is required.

I was wondering if there's an alternative way in Tapestry 4 to have each required field render either a '*' or an error-message behind it without having to subclass the existing components?

Regards,

Onno



>> - When I implement my own ValidationDelegate the writeSuffix method
>> always gets null as a validator parameter. Is that supposed to happen?
>> Or does that have to do with my previous question?

> The writeSuffix method is getting invoked for all sorts of stuff now,
> not just ValidFields.  For TextField, TextArea, etc., the validator
> parameter will be null.



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


Re: ValidationDelegate writeSuffix

Posted by Howard Lewis Ship <hl...@gmail.com>.
Kent,

Nice to see someone's been paying attention :-)

Howard


On 9/6/05, Kent Tong <ke...@cpttm.org.mo> wrote:
> Onno Scheffers <onno <at> AtomicDigitalStudios.com> writes:
> 
> > Hey thanks Kent.... where did that come from? It wasn't in there in T4B3.
> 
> Right, it's there since beta 4 if I remember correctly.
> 
> > Just bought your e-book btw. Been planning to do so for a while and you
> > just gave me yet another reason to do so :oP
> 
> Thanks!
> 
> > BTW. I noticed that entering '0' in a required numeric TextField makes
> > the TextField empty. Probably because of the null -> 0 -> null
> > tranformation?
> > All other numeric values are maintained, except for '0'.
> 
> Right. Try:
> 
> <binding name="translator" value="translator:number,omitZero=false"/>
> 
> --
> Author of an e-Book for learning Tapestry (http://www.agileskills2.org/EWDT)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: ValidationDelegate writeSuffix

Posted by Kent Tong <ke...@cpttm.org.mo>.
Onno Scheffers <onno <at> AtomicDigitalStudios.com> writes:

> Hey thanks Kent.... where did that come from? It wasn't in there in T4B3.

Right, it's there since beta 4 if I remember correctly.

> Just bought your e-book btw. Been planning to do so for a while and you 
> just gave me yet another reason to do so :oP

Thanks!

> BTW. I noticed that entering '0' in a required numeric TextField makes 
> the TextField empty. Probably because of the null -> 0 -> null 
> tranformation?
> All other numeric values are maintained, except for '0'.

Right. Try:

<binding name="translator" value="translator:number,omitZero=false"/>

--
Author of an e-Book for learning Tapestry (http://www.agileskills2.org/EWDT)


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


Re: ValidationDelegate writeSuffix

Posted by Onno Scheffers <on...@AtomicDigitalStudios.com>.
Kent Tong wrote:

>How about:
>
>public void writeSuffix(IMarkupWriter writer, 
>    IRequestCycle cycle, FormComponent component, IValidator validator) {
>  if (component.isRequired()) {
>    ...
>  }
>}
>  
>

Hey thanks Kent.... where did that come from? It wasn't in there in T4B3.
That should teach me to download the latest api-docs as well when I 
switch to the latest beta-release.
Just bought your e-book btw. Been planning to do so for a while and you 
just gave me yet another reason to do so :oP

BTW. I noticed that entering '0' in a required numeric TextField makes 
the TextField empty. Probably because of the null -> 0 -> null 
tranformation?
All other numeric values are maintained, except for '0'.

Regards,

Onno


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


Re: ValidationDelegate writeSuffix

Posted by Kent Tong <ke...@cpttm.org.mo>.
Onno Scheffers <onno <at> AtomicDigitalStudios.com> writes:

> 
> In Tapestry 3 I used to write my own ValidationDelegate, implementing 
> the writeSuffix method to render a '*' behind each required field in a 
> form or an error-message if that field was in error.
> 
> As was discussed before on this list, in Tapestry 4 the writeSuffix 
> method is now called for all sort of stuff, and it will have a 
> null-value for the validator parameters when called for TextField, 
> TextArea, etc. This breaks my previous solution, because I need access 
> to the validator to see if it is required.
> 
> I was wondering if there's an alternative way in Tapestry 4 to have each
required field render either a '*' or
> an error-message behind it without having to subclass the existing components?

How about:

public void writeSuffix(IMarkupWriter writer, 
    IRequestCycle cycle, FormComponent component, IValidator validator) {
  if (component.isRequired()) {
    ...
  }
}

--
Author of an e-Book for learning Tapestry (http://www.agileskills2.org/EWDT)


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