You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Adam Zimowski (JIRA)" <ji...@apache.org> on 2011/04/26 16:59:03 UTC
[jira] [Created] (TAP5-1513) @Validate on RadioGroup not applied
@Validate on RadioGroup not applied
-----------------------------------
Key: TAP5-1513
URL: https://issues.apache.org/jira/browse/TAP5-1513
Project: Tapestry 5
Issue Type: Bug
Components: tapestry-core
Affects Versions: 5.2.5
Reporter: Adam Zimowski
Priority: Minor
Given some bean with property which is mapped to a radio group, and a @Validate("required") annotation on it, Tapestry is not reading the @Validate annotation for such property.
Complete Thread: http://tapestry.1045711.n5.nabble.com/T5-Validate-on-RadioGroup-td4299105.html
Example:
public class RegisterUiBean {
@Validate("required")
private CompanyType companyType;
public CompanyType getCompanyType() {
return companyType;
}
public void setCompanyType(CompanyType aCompanyType) {
companyType = aCompanyType;
}
public CompanyType getCorporation() {
return CompanyType.Corporation;
}
public CompanyType getFederalGov() {
return CompanyType.FederalGovernment;
}
public CompanyType getStateGov() {
return CompanyType.StateGovernment;
}
public CompanyType getIndividual() {
return CompanyType.Individual;
}
}
<t:radiogroup t:id="r_type" value="registration.companyType">
<t:radio t:id="corporation" value="registration.corporation"/>
<t:label for="corporation"/>
<t:radio t:id="federalGovernment" value="registration.federalGov"/>
<t:label for="federalGovernment"/>
<t:radio t:id="stateGovernment" value="registration.stateGov"/>
<t:label for="stateGovernment"/>
<t:radio t:id="individual" value="registration.individual"/>
<t:label for="individual"/>
</t:radiogroup>
Page:
@Persist
@Property
private RegisterUiBean registration;
Taha said:
I compared the code from RadioGroup with that of Select and found the
following difference
In Select if parameter 'validate' is not given a default is chosen and so it
is never null. Validation is performed
in processSubmission() method by the line
fieldValidationSupport.validate(selectedValue, resources, validate);
In RadioGroup however, there is no defaultValidate(){} and so validate can
be null. Now the validation here is done by the line
if (validate != null)
fieldValidationSupport.validate(rawValue, resources, validate);
so when the validate parameter is not supplied, validation does not happen.
Given above information, I patched up RadioGroup by adding:
Binding defaultValidate()
{
return defaultProvider.defaultValidatorBinding("value", resources);
}
and now the @Validate annotation on my bean enum property is read in
correctly. So this is the bug in RadioGroup, which is missing the
above as you pointed out.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira