You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ali Abdel-Aziz Ali <ro...@gmail.com> on 2006/07/26 19:02:40 UTC

Custom Validation new property Problem

Hi All,
I want add property in my custom validator.
I did it but it always return null.
Can any body help?

here are what I did :
in the validatorTag

    private String _methodName = null;

    public void setMethodName(String string) {
            _methodName = string;
    }

    protected Validator createValidator() throws JspException
    {
        ......
         if (_methodName != null)
        {
                if (UIComponentTag.isValueReference(_methodName))
                {
                        ValueBinding vb = facesContext.getApplication
().createValueBinding(_methodName);
                        validator.setMethodName(new String(vb.getValue
(facesContext).toString()));
                }
                else
                {
                        validator.setMethodName(_methodName);
                }
        }

        return validator;
    }

and in the Validator:

     public String getMethodName() {
        return _methodName;
    }

     public void setMethodName(String string) {
            _methodName = string;
    }

and I added it in the tld

but always return null when I try to use it.

-- 
Ali Abdel-Aziz
http://www.aliabdelaziz.com
http://aabdelaziz.blogspot.com

Re: Custom Validation new property Problem

Posted by Ali Abdel-Aziz Ali <ro...@gmail.com>.
I'm so sorry,
I solved it.
I forget to add the new property in the
    public Object saveState(FacesContext context)
    {}
and in
     public void restoreState(FacesContext context, Object state)
    {}


On 7/26/06, Ali Abdel-Aziz Ali <ro...@gmail.com> wrote:
>
> Hi All,
> I want add property in my custom validator.
> I did it but it always return null.
> Can any body help?
>
> here are what I did :
> in the validatorTag
>
>     private String _methodName = null;
>
>     public void setMethodName(String string) {
>             _methodName = string;
>     }
>
>     protected Validator createValidator() throws JspException
>     {
>         ......
>          if (_methodName != null)
>         {
>                 if (UIComponentTag.isValueReference(_methodName))
>                 {
>                         ValueBinding vb = facesContext.getApplication
> ().createValueBinding(_methodName);
>                         validator.setMethodName(new String(vb.getValue
> (facesContext).toString()));
>                 }
>                 else
>                 {
>                         validator.setMethodName(_methodName);
>                 }
>         }
>
>         return validator;
>     }
>
> and in the Validator:
>
>      public String getMethodName() {
>         return _methodName;
>     }
>
>      public void setMethodName(String string) {
>             _methodName = string;
>     }
>
> and I added it in the tld
>
> but always return null when I try to use it.
>
> --
> Ali Abdel-Aziz
> http://www.aliabdelaziz.com
> http://aabdelaziz.blogspot.com
>



-- 
Ali Abdel-Aziz
http://www.aliabdelaziz.com
http://aabdelaziz.blogspot.com