Re: T5: @Validate on RadioGroup
https://issues.apache.org/jira/browse/TAP5-1513 On Wed, Apr 13, 2011 at 9:46 AM, Adam Zimowski zimowsk...@gmail.com wrote: Taha - You are correct, I was wrong. 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. Adam On Wed, Apr 13, 2011 at 7:25 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Adam Hi Adam On Wed, Apr 13, 2011 at 5:19 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha, You are still not getting the point... Why so direct, having a bad day? Please tell me how am I not getting the point when I clearly wrote that: Sorry if it appeared rude, that was certainly not my intention (In my defense, English is not my first language). I think it should have been you are missing the point :) t:radiogroup validate=required Works. The validate parameter is not null with the above, and the Radio group works as expected, as shown in RadioGroup processSubmission(): if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); I think you are missing the point. I realized that validate parameter in RadioGroup is null when @Validate on the bean is present and so validation does not get triggered. If this is a bug, which we both seem to agree, rather than stating the obvious, I would be interested (due to lack of expertise in Tapestry) where in the source does Tapestry read a @Validate annotation off a bean field, and interprets it accordingly. That I mentioned in my last mail The RadioGroup does not seem to be the problem, and the if statement it contains to test nullability of the validate parameter is not the issue, either. RadioGroup is the problem as it does not contain defaultValidate(){ return defaultProvider.defaultValidatorBinding(value, resources); } If it was there the defaultProvider(as I already mentioned in my previous mail) with indirectly take care of the case where validate @Parameter is null Regards, Adam Sorry again regards Taha On Wed, Apr 13, 2011 at 6:30 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: You are still not getting the point... 1. fieldValidationSupport,validate is the service responsible for validating a field. It requries a FieldValidator which is passed as a parameter to it. If this @Parameter validate is null, as is the case with RadioGroup, fieldValidationSupport is never called as the source shows if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); 2. In other components like Select, if @Parameter validate is not provided a default is chosen. The default is provided by ComponentDefaultProvider which in turn calls FieldValidatorDefaultProvider which uses FieldValidatorSource for creating default validators based on the field annotations and type. in case of Select we have default validate like this Binding defaultValidate() { return defaultProvider.defaultValidatorBinding(value, resources); } so if we don't provide a validate, the default is chosen Now in a RadioGroup as the code does not use a default in case @Parameter validate is not provided, the field annotations are not taken into consideration regards Taha On Wed, Apr 13, 2011 at 4:24 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha - I agree with you it seems to be a bug, and I (think) I get what you are saying. However, I am having a hard time seeing why the bug would be in RadioGroup processSubmission() or anywhere in the RadioGroup class for that matter. Rather, it seems the bug (if exists) is deeper in the chain, where the @Validate annotation is read off of a bean and applied to a RadioGroup. I believe this because RadioGroup *does* behave correctly if TML defines: t:radiogroup validate=required but now when the @Validate(required) is on the bean. Adam On Wed, Apr 13, 2011 at 5:35 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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
Re: T5: @Validate on RadioGroup
Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski zimowsk...@gmail.com wrote: I have a bean where @Validate(required) does not work on a radiogroup, but t:radiogroup validate=required ... does. Other @Validate annotated fields (TextField's) work. My companyType is purposely set to null by default, as I do not want any radio pre-selected, thus it shall be required. Is @Validate in the context I have defined supposed to work on the radio group as well? /** * @author Adam Zimowski */ public class RegisterUiBean { @Validate(required) private String email; @Validate(required) private String emailRetype; @Validate(required) private String password; @Validate(required) private String passwordRetype; @Validate(required) private CompanyType companyType; public RegisterUiBean() { } public String getEmail() { return email; } public void setEmail(String aEmail) { email = aEmail; } public String getEmailRetype() { return emailRetype; } public void setEmailRetype(String aEmailRetype) { emailRetype = aEmailRetype; } public String getPassword() { return password; } public void setPassword(String aPassword) { password = aPassword; } public String getPasswordRetype() { return passwordRetype; } public void setPasswordRetype(String aPasswordRetype) { passwordRetype = aPasswordRetype; } 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; } } div class=kk-hdrRegistration Information/div div class=kk-row div class=kk-labelt:label for=r_email1/ :/div div class=kk-fieldt:textfield t:id=r_email1 value=registration.email//div t:error class=literal:kk-error for=r_email1/ /div div class=kk-row div class=kk-labelt:label for=r_email2/ :/div div class=kk-fieldt:textfield t:id=r_email2 value=registration.emailRetype//div t:error class=literal:kk-error for=r_email2/ /div div class=kk-row div class=kk-labelt:label for=r_pass1/ :/div div class=kk-fieldt:textfield t:id=r_pass1 value=registration.password//div t:error class=literal:kk-error for=r_pass1/ /div div class=kk-row div class=kk-labelt:label for=r_pass2/ :/div div class=kk-fieldt:textfield t:id=r_pass2 value=registration.passwordRetype//div t:error class=literal:kk-error for=r_pass2/ /div div class=kk-row div class=kk-labelt:label for=r_type/ :/div div class=kk-field t:radiogroup t:id=r_type value=registration.companyType validate=required 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 /div Adam - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: @Validate on RadioGroup
it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski zimowsk...@gmail.com wrote: I have a bean where @Validate(required) does not work on a radiogroup, but t:radiogroup validate=required ... does. Other @Validate annotated fields (TextField's) work. My companyType is purposely set to null by default, as I do not want any radio pre-selected, thus it shall be required. Is @Validate in the context I have defined supposed to work on the radio group as well? /** * @author Adam Zimowski */ public class RegisterUiBean { @Validate(required) private String email; @Validate(required) private String emailRetype; @Validate(required) private String password; @Validate(required) private String passwordRetype; @Validate(required) private CompanyType companyType; public RegisterUiBean() { } public String getEmail() { return email; } public void setEmail(String aEmail) { email = aEmail; } public String getEmailRetype() { return emailRetype; } public void setEmailRetype(String aEmailRetype) { emailRetype = aEmailRetype; } public String getPassword() { return password; } public void setPassword(String aPassword) { password = aPassword; } public String getPasswordRetype() { return passwordRetype; } public void setPasswordRetype(String aPasswordRetype) { passwordRetype = aPasswordRetype; } 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; } } div class=kk-hdrRegistration Information/div div class=kk-row div class=kk-labelt:label for=r_email1/ :/div div class=kk-fieldt:textfield t:id=r_email1 value=registration.email//div t:error class=literal:kk-error for=r_email1/ /div div class=kk-row div class=kk-labelt:label for=r_email2/ :/div div class=kk-fieldt:textfield t:id=r_email2 value=registration.emailRetype//div t:error class=literal:kk-error for=r_email2/ /div div class=kk-row div class=kk-labelt:label for=r_pass1/ :/div div class=kk-fieldt:textfield t:id=r_pass1 value=registration.password//div t:error class=literal:kk-error for=r_pass1/ /div div class=kk-row div class=kk-labelt:label for=r_pass2/ :/div div class=kk-fieldt:textfield t:id=r_pass2 value=registration.passwordRetype//div t:error class=literal:kk-error for=r_pass2/ /div div class=kk-row div class=kk-labelt:label for=r_type/ :/div div class=kk-field t:radiogroup t:id=r_type value=registration.companyType validate=required 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
Re: T5: @Validate on RadioGroup
Hi Taha - I agree with you it seems to be a bug, and I (think) I get what you are saying. However, I am having a hard time seeing why the bug would be in RadioGroup processSubmission() or anywhere in the RadioGroup class for that matter. Rather, it seems the bug (if exists) is deeper in the chain, where the @Validate annotation is read off of a bean and applied to a RadioGroup. I believe this because RadioGroup *does* behave correctly if TML defines: t:radiogroup validate=required but now when the @Validate(required) is on the bean. Adam On Wed, Apr 13, 2011 at 5:35 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski zimowsk...@gmail.com wrote: I have a bean where @Validate(required) does not work on a radiogroup, but t:radiogroup validate=required ... does. Other @Validate annotated fields (TextField's) work. My companyType is purposely set to null by default, as I do not want any radio pre-selected, thus it shall be required. Is @Validate in the context I have defined supposed to work on the radio group as well? /** * @author Adam Zimowski */ public class RegisterUiBean { @Validate(required) private String email; @Validate(required) private String emailRetype; @Validate(required) private String password; @Validate(required) private String passwordRetype; @Validate(required) private CompanyType companyType; public RegisterUiBean() { } public String getEmail() { return email; } public void setEmail(String aEmail) { email = aEmail; } public String getEmailRetype() { return emailRetype; } public void setEmailRetype(String aEmailRetype) { emailRetype = aEmailRetype; } public String getPassword() { return password; } public void setPassword(String aPassword) { password = aPassword; } public String getPasswordRetype() { return passwordRetype; } public void setPasswordRetype(String aPasswordRetype) { passwordRetype = aPasswordRetype; } 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; } } div class=kk-hdrRegistration Information/div div class=kk-row div class=kk-labelt:label for=r_email1/ :/div div class=kk-fieldt:textfield t:id=r_email1 value=registration.email//div t:error class=literal:kk-error for=r_email1/ /div div class=kk-row div class=kk-labelt:label for=r_email2/ :/div div class=kk-fieldt:textfield t:id=r_email2 value=registration.emailRetype//div t:error class=literal:kk-error for=r_email2/ /div div class=kk-row div class=kk-labelt:label for=r_pass1/ :/div div class=kk-fieldt:textfield t:id=r_pass1 value=registration.password//div t:error class=literal:kk-error for=r_pass1/ /div div class=kk-row div class=kk-labelt:label for=r_pass2/ :/div div class=kk-fieldt:textfield
Re: T5: @Validate on RadioGroup
You are still not getting the point... 1. fieldValidationSupport,validate is the service responsible for validating a field. It requries a FieldValidator which is passed as a parameter to it. If this @Parameter validate is null, as is the case with RadioGroup, fieldValidationSupport is never called as the source shows if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); 2. In other components like Select, if @Parameter validate is not provided a default is chosen. The default is provided by ComponentDefaultProvider which in turn calls FieldValidatorDefaultProvider which uses FieldValidatorSource for creating default validators based on the field annotations and type. in case of Select we have default validate like this Binding defaultValidate() { return defaultProvider.defaultValidatorBinding(value, resources); } so if we don't provide a validate, the default is chosen Now in a RadioGroup as the code does not use a default in case @Parameter validate is not provided, the field annotations are not taken into consideration regards Taha On Wed, Apr 13, 2011 at 4:24 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha - I agree with you it seems to be a bug, and I (think) I get what you are saying. However, I am having a hard time seeing why the bug would be in RadioGroup processSubmission() or anywhere in the RadioGroup class for that matter. Rather, it seems the bug (if exists) is deeper in the chain, where the @Validate annotation is read off of a bean and applied to a RadioGroup. I believe this because RadioGroup *does* behave correctly if TML defines: t:radiogroup validate=required but now when the @Validate(required) is on the bean. Adam On Wed, Apr 13, 2011 at 5:35 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski zimowsk...@gmail.com wrote: I have a bean where @Validate(required) does not work on a radiogroup, but t:radiogroup validate=required ... does. Other @Validate annotated fields (TextField's) work. My companyType is purposely set to null by default, as I do not want any radio pre-selected, thus it shall be required. Is @Validate in the context I have defined supposed to work on the radio group as well? /** * @author Adam Zimowski */ public class RegisterUiBean { @Validate(required) private String email; @Validate(required) private String emailRetype; @Validate(required) private String password; @Validate(required) private String passwordRetype; @Validate(required) private CompanyType companyType; public RegisterUiBean() { } public String getEmail() { return email; } public void setEmail(String aEmail) { email = aEmail; } public String getEmailRetype() { return emailRetype; } public void setEmailRetype(String aEmailRetype) { emailRetype = aEmailRetype; } public String getPassword() { return password; } public void setPassword(String aPassword) { password = aPassword; } public String getPasswordRetype() { return passwordRetype; } public void setPasswordRetype(String aPasswordRetype) { passwordRetype = aPasswordRetype; } public CompanyType getCompanyType() { return companyType; }
Re: T5: @Validate on RadioGroup
Hi Taha, You are still not getting the point... Why so direct, having a bad day? Please tell me how am I not getting the point when I clearly wrote that: t:radiogroup validate=required Works. The validate parameter is not null with the above, and the Radio group works as expected, as shown in RadioGroup processSubmission(): if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); I think you are missing the point. I realized that validate parameter in RadioGroup is null when @Validate on the bean is present and so validation does not get triggered. If this is a bug, which we both seem to agree, rather than stating the obvious, I would be interested (due to lack of expertise in Tapestry) where in the source does Tapestry read a @Validate annotation off a bean field, and interprets it accordingly. The RadioGroup does not seem to be the problem, and the if statement it contains to test nullability of the validate parameter is not the issue, either. Regards, Adam On Wed, Apr 13, 2011 at 6:30 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: You are still not getting the point... 1. fieldValidationSupport,validate is the service responsible for validating a field. It requries a FieldValidator which is passed as a parameter to it. If this @Parameter validate is null, as is the case with RadioGroup, fieldValidationSupport is never called as the source shows if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); 2. In other components like Select, if @Parameter validate is not provided a default is chosen. The default is provided by ComponentDefaultProvider which in turn calls FieldValidatorDefaultProvider which uses FieldValidatorSource for creating default validators based on the field annotations and type. in case of Select we have default validate like this Binding defaultValidate() { return defaultProvider.defaultValidatorBinding(value, resources); } so if we don't provide a validate, the default is chosen Now in a RadioGroup as the code does not use a default in case @Parameter validate is not provided, the field annotations are not taken into consideration regards Taha On Wed, Apr 13, 2011 at 4:24 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha - I agree with you it seems to be a bug, and I (think) I get what you are saying. However, I am having a hard time seeing why the bug would be in RadioGroup processSubmission() or anywhere in the RadioGroup class for that matter. Rather, it seems the bug (if exists) is deeper in the chain, where the @Validate annotation is read off of a bean and applied to a RadioGroup. I believe this because RadioGroup *does* behave correctly if TML defines: t:radiogroup validate=required but now when the @Validate(required) is on the bean. Adam On Wed, Apr 13, 2011 at 5:35 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski zimowsk...@gmail.com wrote: I have a bean where @Validate(required) does not work on a radiogroup, but t:radiogroup validate=required ... does. Other @Validate annotated fields (TextField's) work. My companyType is purposely set to null by default, as I do not want any radio pre-selected, thus it shall be required. Is @Validate in the context I have defined supposed to work on the radio group as well? /** * @author Adam Zimowski */ public class RegisterUiBean { @Validate(required) private String email; @Validate(required) private String emailRetype; @Validate(required) private String password; @Validate(required) private String
Re: T5: @Validate on RadioGroup
Hi Adam Hi Adam On Wed, Apr 13, 2011 at 5:19 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha, You are still not getting the point... Why so direct, having a bad day? Please tell me how am I not getting the point when I clearly wrote that: Sorry if it appeared rude, that was certainly not my intention (In my defense, English is not my first language). I think it should have been you are missing the point :) t:radiogroup validate=required Works. The validate parameter is not null with the above, and the Radio group works as expected, as shown in RadioGroup processSubmission(): if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); I think you are missing the point. I realized that validate parameter in RadioGroup is null when @Validate on the bean is present and so validation does not get triggered. If this is a bug, which we both seem to agree, rather than stating the obvious, I would be interested (due to lack of expertise in Tapestry) where in the source does Tapestry read a @Validate annotation off a bean field, and interprets it accordingly. That I mentioned in my last mail The RadioGroup does not seem to be the problem, and the if statement it contains to test nullability of the validate parameter is not the issue, either. RadioGroup is the problem as it does not contain defaultValidate(){ return defaultProvider.defaultValidatorBinding(value, resources); } If it was there the defaultProvider(as I already mentioned in my previous mail) with indirectly take care of the case where validate @Parameter is null Regards, Adam Sorry again regards Taha On Wed, Apr 13, 2011 at 6:30 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: You are still not getting the point... 1. fieldValidationSupport,validate is the service responsible for validating a field. It requries a FieldValidator which is passed as a parameter to it. If this @Parameter validate is null, as is the case with RadioGroup, fieldValidationSupport is never called as the source shows if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); 2. In other components like Select, if @Parameter validate is not provided a default is chosen. The default is provided by ComponentDefaultProvider which in turn calls FieldValidatorDefaultProvider which uses FieldValidatorSource for creating default validators based on the field annotations and type. in case of Select we have default validate like this Binding defaultValidate() { return defaultProvider.defaultValidatorBinding(value, resources); } so if we don't provide a validate, the default is chosen Now in a RadioGroup as the code does not use a default in case @Parameter validate is not provided, the field annotations are not taken into consideration regards Taha On Wed, Apr 13, 2011 at 4:24 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha - I agree with you it seems to be a bug, and I (think) I get what you are saying. However, I am having a hard time seeing why the bug would be in RadioGroup processSubmission() or anywhere in the RadioGroup class for that matter. Rather, it seems the bug (if exists) is deeper in the chain, where the @Validate annotation is read off of a bean and applied to a RadioGroup. I believe this because RadioGroup *does* behave correctly if TML defines: t:radiogroup validate=required but now when the @Validate(required) is on the bean. Adam On Wed, Apr 13, 2011 at 5:35 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski
Re: T5: @Validate on RadioGroup
Taha - You are correct, I was wrong. 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. Adam On Wed, Apr 13, 2011 at 7:25 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Adam Hi Adam On Wed, Apr 13, 2011 at 5:19 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha, You are still not getting the point... Why so direct, having a bad day? Please tell me how am I not getting the point when I clearly wrote that: Sorry if it appeared rude, that was certainly not my intention (In my defense, English is not my first language). I think it should have been you are missing the point :) t:radiogroup validate=required Works. The validate parameter is not null with the above, and the Radio group works as expected, as shown in RadioGroup processSubmission(): if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); I think you are missing the point. I realized that validate parameter in RadioGroup is null when @Validate on the bean is present and so validation does not get triggered. If this is a bug, which we both seem to agree, rather than stating the obvious, I would be interested (due to lack of expertise in Tapestry) where in the source does Tapestry read a @Validate annotation off a bean field, and interprets it accordingly. That I mentioned in my last mail The RadioGroup does not seem to be the problem, and the if statement it contains to test nullability of the validate parameter is not the issue, either. RadioGroup is the problem as it does not contain defaultValidate(){ return defaultProvider.defaultValidatorBinding(value, resources); } If it was there the defaultProvider(as I already mentioned in my previous mail) with indirectly take care of the case where validate @Parameter is null Regards, Adam Sorry again regards Taha On Wed, Apr 13, 2011 at 6:30 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: You are still not getting the point... 1. fieldValidationSupport,validate is the service responsible for validating a field. It requries a FieldValidator which is passed as a parameter to it. If this @Parameter validate is null, as is the case with RadioGroup, fieldValidationSupport is never called as the source shows if (validate != null) fieldValidationSupport.validate(rawValue, resources, validate); 2. In other components like Select, if @Parameter validate is not provided a default is chosen. The default is provided by ComponentDefaultProvider which in turn calls FieldValidatorDefaultProvider which uses FieldValidatorSource for creating default validators based on the field annotations and type. in case of Select we have default validate like this Binding defaultValidate() { return defaultProvider.defaultValidatorBinding(value, resources); } so if we don't provide a validate, the default is chosen Now in a RadioGroup as the code does not use a default in case @Parameter validate is not provided, the field annotations are not taken into consideration regards Taha On Wed, Apr 13, 2011 at 4:24 PM, Adam Zimowski zimowsk...@gmail.com wrote: Hi Taha - I agree with you it seems to be a bug, and I (think) I get what you are saying. However, I am having a hard time seeing why the bug would be in RadioGroup processSubmission() or anywhere in the RadioGroup class for that matter. Rather, it seems the bug (if exists) is deeper in the chain, where the @Validate annotation is read off of a bean and applied to a RadioGroup. I believe this because RadioGroup *does* behave correctly if TML defines: t:radiogroup validate=required but now when the @Validate(required) is on the bean. Adam On Wed, Apr 13, 2011 at 5:35 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: it is the @Parameter validate in RadioGroup that is required not @Validate as that is never checked in case @Parameter validate is not given in a RadioGroup ... Please read my answer again :) It seems to be bug!! regards Taha On Wed, Apr 13, 2011 at 3:40 PM, Adam Zimowski zimowsk...@gmail.com wrote: Thanks Taha, but I did supply @Validate(required) annotation and validation did not happen. Adam On Tue, Apr 12, 2011 at 8:15 PM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi 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,
Re: T5: @Validate on RadioGroup
Hi 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. regards Taha On Wed, Apr 13, 2011 at 2:19 AM, Adam Zimowski zimowsk...@gmail.com wrote: I have a bean where @Validate(required) does not work on a radiogroup, but t:radiogroup validate=required ... does. Other @Validate annotated fields (TextField's) work. My companyType is purposely set to null by default, as I do not want any radio pre-selected, thus it shall be required. Is @Validate in the context I have defined supposed to work on the radio group as well? /** * @author Adam Zimowski */ public class RegisterUiBean { @Validate(required) private String email; @Validate(required) private String emailRetype; @Validate(required) private String password; @Validate(required) private String passwordRetype; @Validate(required) private CompanyType companyType; public RegisterUiBean() { } public String getEmail() { return email; } public void setEmail(String aEmail) { email = aEmail; } public String getEmailRetype() { return emailRetype; } public void setEmailRetype(String aEmailRetype) { emailRetype = aEmailRetype; } public String getPassword() { return password; } public void setPassword(String aPassword) { password = aPassword; } public String getPasswordRetype() { return passwordRetype; } public void setPasswordRetype(String aPasswordRetype) { passwordRetype = aPasswordRetype; } 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; } } div class=kk-hdrRegistration Information/div div class=kk-row div class=kk-labelt:label for=r_email1/ :/div div class=kk-fieldt:textfield t:id=r_email1 value=registration.email//div t:error class=literal:kk-error for=r_email1/ /div div class=kk-row div class=kk-labelt:label for=r_email2/ :/div div class=kk-fieldt:textfield t:id=r_email2 value=registration.emailRetype//div t:error class=literal:kk-error for=r_email2/ /div div class=kk-row div class=kk-labelt:label for=r_pass1/ :/div div class=kk-fieldt:textfield t:id=r_pass1 value=registration.password//div t:error class=literal:kk-error for=r_pass1/ /div div class=kk-row div class=kk-labelt:label for=r_pass2/ :/div div class=kk-fieldt:textfield t:id=r_pass2 value=registration.passwordRetype//div t:error class=literal:kk-error for=r_pass2/ /div div class=kk-row div class=kk-labelt:label for=r_type/ :/div div class=kk-field t:radiogroup t:id=r_type value=registration.companyType validate=required 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 /div Adam - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org