Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
5.4, 5.2
-
None
-
None
Description
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.
Attachments
Issue Links
- relates to
-
TAP5-2156 t:validate=required attribute on t:radiogroup does not cause client-side validation failure when no radio button selected
- Open