Hi Adam,

I 'have find what is responsible of my problem, but I can't explain why.

In my  commandButton
<af:commandButton text="Save" action="navigate"
                           partialSubmit="true" />

If I remove partialSubmit="true", I have expected error message with the input component.

Is it normal ?

Thanks,
Arnaud

Adam Winer a écrit :
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 <[EMAIL PROTECTED]> 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




Reply via email to