You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Christian Dutaret (JIRA)" <ji...@apache.org> on 2014/09/17 15:39:33 UTC

[jira] [Commented] (TAP5-1513) @Validate on RadioGroup not applied

    [ https://issues.apache.org/jira/browse/TAP5-1513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14137217#comment-14137217 ] 

Christian Dutaret commented on TAP5-1513:
-----------------------------------------

Seems to me the bug is still present in 5.4-beta-22
No validation occur on a RadioGroup component backed by an enum property annotated with @Validate or JSR-303 annotation

> @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
>            Reporter: Adam Zimowski
>            Priority: Minor
>              Labels: bulk-close-candidate
>
> 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 was sent by Atlassian JIRA
(v6.3.4#6332)