You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ur...@bluemail.ch on 2005/10/25 23:44:56 UTC
User defined message for component
Hello I would like to use my own error message
I use <h:message for="nickname">
<h:inputText id="nickname" value="#{Register.nickname}" required="true" size="10"
maxlength="24"/>
<h:message for="nickname"/>
This generates the error message "nickname": Value is required. I would like
to replace this with my own message.
My recipe:
1) In faces-config.xml config file I have the entry
<faces-config>
<application>
<message-bundle>org.partneragency.web.validatormessage</message-bundle>
</application>
...
</faces-config>
2) In validatormessage.properties I add the entry
nickname=nickname must be set
This does not work.
Re: User defined message for component
Posted by Mike Kienenberger <mk...@gmail.com>.
This is guesswork, but I came across message keys in the JSF 1.2 spec
earlier today.
I think you might be able to use this entry instead:
javax.faces.component.UIInput.REQUIRED={0} must be set
The original value was
javax.faces.component.UIInput.REQUIRED={0}: Validation Error: Value is required
Unfortunately, the ability to specify required message keys at the tag
level (requiredMessage=.....) isn't available until JSF 1.2.
Also note that you can define
<h:outputLabel for="nickname">
<h:outputText value="nickname"/>
</h:outputLabel>
and whatever the value of the outputLabel is will be used for {0} in
your message key. This is probably more useful when the id can't
contain the display value (ie, "Last Name" instead of "lastname").
-Mike
On 10/25/05, urswagner@bluemail.ch <ur...@bluemail.ch> wrote:
>
> Hello I would like to use my own error message
> I use <h:message for="nickname">
>
> <h:inputText id="nickname" value="#{Register.nickname}" required="true" size="10"
> maxlength="24"/>
> <h:message for="nickname"/>
>
> This generates the error message "nickname": Value is required. I would like
> to replace this with my own message.
>
> My recipe:
>
> 1) In faces-config.xml config file I have the entry
>
> <faces-config>
> <application>
> <message-bundle>org.partneragency.web.validatormessage</message-bundle>
> </application>
> ...
> </faces-config>
>
> 2) In validatormessage.properties I add the entry
> nickname=nickname must be set
>
> This does not work.
>
>
>