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(" ");
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]