incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Winer" <awi...@gmail.com>
Subject Re: Validation message
Date Thu, 15 Jun 2006 21:42:03 GMT
Arnaud,

I can't repro a problem.  I just tried:

  public void validate(
    FacesContext pContext, UIComponent pToValidate, Object pValue)
  {
    if(pValue.toString().length() > 10)
    {
      FacesMessage errMsg = new FacesMessage("That's too long!");
      throw new ValidatorException(errMsg);
    }
   }

... and:

    <af:panelForm>
        <af:inputText label="Label"
                            validator="#{data.validate}" value="Some value"/>
    </af:panelForm>

... and got the expected error message with the input component.  What
input component are you using?

-- Adam





On 6/14/06, Arnaud MERGEY <amergey@sunopsis.com> wrote:
> Hi,
>
> In panel form my inputText reference a validation method with
> "validator" attribute.
> If validation failed my method throw a
> javax.faces.validator.ValidatorException.
>
> my code:
> /public void validate(FacesContext pContext, UIComponent pToValidate,
> Object pValue)
>     {
>         if(mMaxLength>0)
>         {
>             if(pValue.toString().length()>mMaxLength)
>             {
>                 FacesMessage errMsg =
> JSFService.getFacesMessage(pContext,JSFService.MESSAGE_ID_VALIDATOR_LENGTH,new
> Object[]{Integer.toString(mMaxLength)});
>                 throw new ValidatorException(errMsg);
>             }
>         }
>     }/
>
> In my page when form is redisplayed error message is not displayed in
> the inputText not validated but is displayed in <af:messages/>
>
> In my backing bean if I throw exception in the setter, the error message
> is displayed automatically in the right inputText
>
> How can I do that with validator ? (for some reasons, validation must be
> done in external method, not in the setter).
>
> In the docs /input components typically support automatically showing
> their own messages, including a tip and the error message/.
>
> thanks
> Arnaud
>
>

Mime
View raw message