webtier@glassfish.java.net

Re: Validation error message missing id of erroneous h:inputText

From: <webtier_at_javadesktop.org>
Date: Thu, 11 Feb 2010 12:02:07 PST

Good question! Allow me to elucidate:

To get JSF to prepend the offending form input element id, you must override the default bean validator message template. To do that, you must first load an application message bundle in faces-config.xml:

        <application>
          <message-bundle>
            my.package.bundlefile
          </message-bundle>
        </application>

In bundlefile.properties, you override the message template like so:

  # override the default BeanValidator message from javax.faces.Messages
  javax.faces.validator.BeanValidator.MESSAGE={1} {0}
    

>> While I'm on the topic, is there a way to substitute my own label for the form-id:element-id that appears in h:messages?

Why yes. Yes, you can! Just use the label attribute of the h:inputText et. al. Of course, for consistency, you can get the label value from a resource bundle just like you do for h:outputLabel.

Happy coding!
[Message sent by forum member 'markroy' (mroy_at_nuwave-tech.com)]

http://forums.java.net/jive/thread.jspa?messageID=386213