Validation: custom messages for errors

Hello,

I have been discovering the JSF validation possibilities. I know how to set a message via validator attribute and I have also found how to change the predefined messages such as javax.faces.component.UIInput.REQUIRED.

But I would like to have the redefined messages "variable". Concretely, I want to check an <h:inputText id="inputName"... whether it is empty and if so I want to print a message like: "enter the name". Similarly for other fields.>

[480 byte] By [honzaa] at [2007-11-27 2:11:50]
# 1
In JSF 1.2 you can use the 'requiredMessage' attribute. In JSF 1.1 you have to customize the validators and facesmessages.
BalusCa at 2007-7-12 2:05:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thank you for the response.

I use JSF 1.1. I am not sure what you mean by the "customize the validators".

I have such a validator:

public void checkName(FacesContext context, UIComponent component, Object value) throws ValidatorException

{

if (value.toString().trim().length() <= 0)

{

// adding the message...

}

}

But this method is not called if the field is empty. As I understand it, the validator method is not called if there is no input. (I have the required attribute empty.)

honzaa at 2007-7-12 2:05:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...