Re: Validators of field
On Sun, 29 Apr 2012 17:52:48 -0300, Dimitris Zenios wrote: Nobody else want to do such kind of things?I dont think what i am trying to achieve is something special.There must be a way I don't think there's a direct way of doing what you want, as each validator has a hook for adding attributes or elements to the label and the form field itself. So you can file a JIRA asking for the validators to add a CSS class automatically to both the field and label. Or, better yet, some new per-thread service that stores the validations applied to the fields. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Validators of field
All fields in tapestry have a FieldValidator property @Parameter(defaultPrefix = BindingConstants.VALIDATE) private FieldValidator validate; This will either be an instance of FieldValidatorImpl for a single validator or CompositeFieldValidator if there is more than one validator on a field. There is no public API to get the list of validators for a field and it will get messy if you try to inspect the FieldValidator using reflection. I would approach this by overriding or decorating the FieldValidatorSource service to store the information you want in the environment. Take a look at FieldValidatorSourceImpl for inspiration http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/internal/services/FieldValidatorSourceImpl.html http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/services/Environment.html
Re: Validators of field
Nobody else want to do such kind of things?I dont think what i am trying to achieve is something special.There must be a way On Sat, Apr 28, 2012 at 12:59 AM, Dimitris Zenios wrote: > Anyone? > > On Fri, Apr 27, 2012 at 9:04 PM, Dimitris Zenios > wrote: >> Ok let me explain the problem. >> >> I am following >> http://tawus.wordpress.com/2011/08/01/tapestry-mixins-classtransformations/ >> page in order to add an asterisk(*) in all labels that have a filed of >> required.The main problem though is that even though the field has the >> isRequired method to tell me if its required,it does not apply when >> using javax.validations and NotNull with tapestry-bean-validation.The >> only way i can think of that fixes this problem right now is to check >> manually what validators are attached on the field and decide from >> there what you can do.Even though the isRequired method is good i >> think it will be better to also know what validators are currently >> attached to the Field >> >> Regards >> Dimitris Zenios >> >> On Fri, Apr 27, 2012 at 8:08 PM, Thiago H. de Paula Figueiredo >> wrote: >>> On Fri, 27 Apr 2012 12:09:56 -0300, Dimitris Zenios >>> wrote: >>> How can i find what validators are attached on a field? >>> >>> >>> Unless you've set the validators yourself (validate parameter of many form >>> field components), the ones that are attached automatically can be checked >>> by putting a breakpoint at the createDefaultValidator() method of >>> FieldValidatorDefaultSourceImpl. >>> >>> -- >>> Thiago H. de Paula Figueiredo >>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and >>> instructor >>> Owner, Ars Machina Tecnologia da Informação Ltda. >>> http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Validators of field
Anyone? On Fri, Apr 27, 2012 at 9:04 PM, Dimitris Zenios wrote: > Ok let me explain the problem. > > I am following > http://tawus.wordpress.com/2011/08/01/tapestry-mixins-classtransformations/ > page in order to add an asterisk(*) in all labels that have a filed of > required.The main problem though is that even though the field has the > isRequired method to tell me if its required,it does not apply when > using javax.validations and NotNull with tapestry-bean-validation.The > only way i can think of that fixes this problem right now is to check > manually what validators are attached on the field and decide from > there what you can do.Even though the isRequired method is good i > think it will be better to also know what validators are currently > attached to the Field > > Regards > Dimitris Zenios > > On Fri, Apr 27, 2012 at 8:08 PM, Thiago H. de Paula Figueiredo > wrote: >> On Fri, 27 Apr 2012 12:09:56 -0300, Dimitris Zenios >> wrote: >> >>> How can i find what validators are attached on a field? >> >> >> Unless you've set the validators yourself (validate parameter of many form >> field components), the ones that are attached automatically can be checked >> by putting a breakpoint at the createDefaultValidator() method of >> FieldValidatorDefaultSourceImpl. >> >> -- >> Thiago H. de Paula Figueiredo >> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and >> instructor >> Owner, Ars Machina Tecnologia da Informação Ltda. >> http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Validators of field
Ok let me explain the problem. I am following http://tawus.wordpress.com/2011/08/01/tapestry-mixins-classtransformations/ page in order to add an asterisk(*) in all labels that have a filed of required.The main problem though is that even though the field has the isRequired method to tell me if its required,it does not apply when using javax.validations and NotNull with tapestry-bean-validation.The only way i can think of that fixes this problem right now is to check manually what validators are attached on the field and decide from there what you can do.Even though the isRequired method is good i think it will be better to also know what validators are currently attached to the Field Regards Dimitris Zenios On Fri, Apr 27, 2012 at 8:08 PM, Thiago H. de Paula Figueiredo wrote: > On Fri, 27 Apr 2012 12:09:56 -0300, Dimitris Zenios > wrote: > >> How can i find what validators are attached on a field? > > > Unless you've set the validators yourself (validate parameter of many form > field components), the ones that are attached automatically can be checked > by putting a breakpoint at the createDefaultValidator() method of > FieldValidatorDefaultSourceImpl. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and > instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Validators of field
On Fri, 27 Apr 2012 12:09:56 -0300, Dimitris Zenios wrote: How can i find what validators are attached on a field? Unless you've set the validators yourself (validate parameter of many form field components), the ones that are attached automatically can be checked by putting a breakpoint at the createDefaultValidator() method of FieldValidatorDefaultSourceImpl. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org