You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rudolf Baloun <Ru...@atron.de> on 2005/08/03 09:40:37 UTC
IValidation in ValidationDelegate does not work
Hi,
i use tapestry 4 beta 3.
I got these Class, page, html:
public class MyValidationDelegate extends ValidationDelegate {
public void writerLabelPrefix(IFormComponent component,
IMarkupWriter writer, IRequestCycle cycle) {
if(isInError(component)){
writer.begin("font");
writer.attribute("color", "#FF0000");
}
}
public void writeLabelSuffix(IFormComponent component, IMarkupWriter
writer, IRequestCycle cycle){
if(isInError(component)){
writer.end();
}
}
public void writeAttributes(IMarkupWriter writer, IRequestCycle
cycle, IFormComponent component, IValidator validator){
if(isInError()){
writer.attribute("style", "BACKGROUND: yellow");
}
}
public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component, IValidator validator){
if(validator != null && validator.isRequired()){
writer.printRaw(" ");
writer.begin("font");
writer.attribute("color", "black");
writer.print("*");
writer.end("font");
}
}}
page:
....
<bean name="delegate" class="xx.yy.zz.MyValidationDelegate"/>
<bean name="required" class="org.apache.tapestry.valid.StringValidator"
lifecycle="render">
<set name="required" value="true"/>
<set name="minimumLength" value="3"/>
<set name="requiredMessage" value="This field is required!"/>
<set name="minimumLengthMessage" value="To Short!"/>
</bean>
....
html:
....
<form jwcid="@Form" delegate="ognl:beans.delegate">
.... // here are the fields
</form>
...
This worked nice with tapestry 3.0.
After the update to Tapestry 4.0beta3 i got an problem with the method:
public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component, IValidator validator){
if(validator != null && validator.isRequired()){
writer.printRaw(" ");
writer.begin("font");
writer.attribute("color", "black");
writer.print("*");
writer.end("font");
}
}
The validator is always null?? does anyone see why?
Is it a bug in tapestry 4 beta 3?
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: IValidation in ValidationDelegate does not work
Posted by Rudolf Baloun <Ru...@atron.de>.
Hi,
i found this solution too (that was my workaround).
But WHY does Tapestry need the last parameter (IValidator validator) in
"public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component, IValidator validator)"
What can i do with the "validator"?? its always "null" in tapestry 4 beta 3.
Does these parameter just exist to keep tapestry 4 beta3 compatible to
Version 3.0?
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: IValidation in ValidationDelegate does not work
Posted by "Scott F. Walter" <sc...@vivare.com>.
Rudolf Baloun wrote:
> Hi,
>
> i use tapestry 4 beta 3.
> I got these Class, page, html:
>
>
> public class MyValidationDelegate extends ValidationDelegate {
> public void writerLabelPrefix(IFormComponent component,
> IMarkupWriter writer, IRequestCycle cycle) {
> if(isInError(component)){
> writer.begin("font");
> writer.attribute("color", "#FF0000");
> }
> }
> public void writeLabelSuffix(IFormComponent component,
> IMarkupWriter writer, IRequestCycle cycle){
> if(isInError(component)){
> writer.end();
> }
> }
> public void writeAttributes(IMarkupWriter writer, IRequestCycle
> cycle, IFormComponent component, IValidator validator){
> if(isInError()){
> writer.attribute("style", "BACKGROUND: yellow");
> }
> }
> public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
> IFormComponent component, IValidator validator){
> if(validator != null && validator.isRequired()){
> writer.printRaw(" ");
> writer.begin("font");
> writer.attribute("color", "black");
> writer.print("*");
> writer.end("font");
> }
> }}
>
> page:
> ....
> <bean name="delegate" class="xx.yy.zz.MyValidationDelegate"/>
> <bean name="required"
> class="org.apache.tapestry.valid.StringValidator"
> lifecycle="render">
> <set name="required" value="true"/>
> <set name="minimumLength" value="3"/>
> <set name="requiredMessage" value="This field is required!"/>
> <set name="minimumLengthMessage" value="To Short!"/>
> </bean>
> ....
>
> html:
> ....
> <form jwcid="@Form" delegate="ognl:beans.delegate">
> .... // here are the fields
> </form>
> ...
>
>
> This worked nice with tapestry 3.0.
> After the update to Tapestry 4.0beta3 i got an problem with the method:
>
> public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
> IFormComponent component, IValidator validator){
> if(validator != null && validator.isRequired()){
> writer.printRaw(" ");
> writer.begin("font");
> writer.attribute("color", "black");
> writer.print("*");
> writer.end("font");
> }
> }
>
> The validator is always null?? does anyone see why?
> Is it a bug in tapestry 4 beta 3?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
Well it's not a bug, the old way of getting the validator is not
backwards compatible with 3.0 code. I had to dig deep to fingure this
out and posted a how-to at the Tapestry wiki, here is the link:
http://wiki.apache.org/jakarta-tapestry/CheckingForRequiredValidator
Send a reply to the maiiling list if you still have questions after
looking at the wiki entry.
--
Scott F. Walter Scott F. Walter
Principal Consultant
Vivare, Inc.
E: scott.walter@vivare.com
E: scott@scottwalter.com
Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org