You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Damar Thapa <th...@gmail.com> on 2006/11/02 15:27:41 UTC
Help in writing Validator
Hi,
I have one <h:inputText> field that I would like to validate against
the availability of that entry in the database -- accept only if the
input text is in the database. Can somebody in list list give me some
pointers on this?
Thanks,
With regards,
Damar Thapa
Re: Help in writing Validator
Posted by Damar Thapa <th...@gmail.com>.
Hi Cagatay,
Thanks for your pointers. I will look at the options.
With regards,
Damar
On 11/2/06, Cagatay Civici <ca...@gmail.com> wrote:
> Hi,
>
> There are several choices, you may try to write a validator method in your
> managed bean and do a method binding to it via the validator attribute like;
>
> <h:inputText validator="#{beanname.validatormethod }" />
>
> public void validateCode(FacesContext facesContext, UIComponent component,
> Object value) {
> //throw new ValidationException if you think value is not valid
> }
>
> Also for better reusing, you can write your own validator and bind it to the
> inputText by the <f:validator />
>
> http://publib.boulder.ibm.com/infocenter/radhelp/v6r0m1/index.jsp?topic=/com.ibm.etools.jsf.doc/topics/tjsfcrvalidator.html
>
> In addition you can create it's own tag for your validator like in;
>
> http://www.jsffaq.com/Wiki.jsp?page=HowToCreateTheCustomValidator
>
> Cagatay
>
>
> On 11/2/06, Damar Thapa <th...@gmail.com> wrote:
> > Hi,
> >
> > I have one <h:inputText> field that I would like to validate against
> > the availability of that entry in the database -- accept only if the
> > input text is in the database. Can somebody in list list give me some
> > pointers on this?
> >
> > Thanks,
> >
> > With regards,
> >
> > Damar Thapa
> >
>
>
--
With regards,
Damar Thapa
Re: Help in writing Validator
Posted by Cagatay Civici <ca...@gmail.com>.
Hi,
There are several choices, you may try to write a validator method in your
managed bean and do a method binding to it via the validator attribute like;
<h:inputText validator="#{beanname.validatormethod}" />
public void validateCode(FacesContext facesContext, UIComponent component,
Object value) {
//throw new ValidationException if you think value is not valid
}
Also for better reusing, you can write your own validator and bind it to the
inputText by the <f:validator />
http://publib.boulder.ibm.com/infocenter/radhelp/v6r0m1/index.jsp?topic=/com.ibm.etools.jsf.doc/topics/tjsfcrvalidator.html
In addition you can create it's own tag for your validator like in;
http://www.jsffaq.com/Wiki.jsp?page=HowToCreateTheCustomValidator
Cagatay
On 11/2/06, Damar Thapa <th...@gmail.com> wrote:
>
> Hi,
>
> I have one <h:inputText> field that I would like to validate against
> the availability of that entry in the database -- accept only if the
> input text is in the database. Can somebody in list list give me some
> pointers on this?
>
> Thanks,
>
> With regards,
>
> Damar Thapa
>