<t:zone t:id="myZone" id="myZone">
<t:form t:zone="myZone" t:id="form">
<t:errors />
<p><label for="field">Required, minLength=3, maxLength=10</label>
<br/><t:textfield t:value="foo" t:id="field"
t:validate="required, minLength=3, maxLength=10"/>
</p>
<p><label for="field2">Required, min=3, max=6, number</label>
<br/><t:textfield t:value="dummy" t:id="field2"
t:validate="required, min=3, max=6"/>
</p>
<p><label for="field3">Required, email (will not produce any client side
validation, because default Tapestry validator does not handle it))</label>
<br/><t:textfield t:value="email" t:id="field3"
t:validate="required, email" />
</p>
<p><label for="field4">Required, regular expression (.*foo.*)</label>
<br/><t:textfield t:value="regexp" t:id="field4"
t:validate="required, regexp=.*foo.*"/>
</p>
<p>
<t:submit t:id="submit" />
</p>
</t:form>
<p>
<t:if t:test="dataToDisplay">
You have submitted : ${foo}, ${dummy}, ${email}, ${regexp}
</t:if>
</p>
</t:zone>
public class DocsValidation
{
@Property
private String foo;
@Property
private Integer dummy;
@Property
private String email;
@Property
private String regexp;
@InjectComponent
private Zone myZone;
@OnEvent(value=EventConstants.SUCCESS)
public Object onSuccess(){
return myZone.getBody();
}
@OnEvent(value=EventConstants.FAILURE)
public Object onFailure(){
return myZone.getBody();
}
public Boolean getDataToDisplay(){
return InternalUtils.isNonBlank(foo) && InternalUtils.isNonBlank(email) &&
InternalUtils.isNonBlank(regexp);
}
}