8 Replies Latest reply on Nov 16, 2007 4:13 AM by syvalta

    rich:message and validation error string

      Hi,
      I'm trying to get a friendly and custom messge for my inputs fields, and found a problem that can't resolve yet.

      My code looks like this:

      <h:outputText styleClass="rsLabel" value="Username" />
      <h:inputText id="idUsername" styleClass="rsInput" value="#{login.username}"
       required="true" size="15" maxlength="10" label="Username">
       <f:validateLength maximum="10" minimum="1"/>
      </h:inputText>
      <rich:message for="idUsername" tooltip="true">
       <f:facet name="passedMarker">
       <h:graphicImage value="/images/ajax/passed.gif" />
       </f:facet>
       <f:facet name="errorMarker">
       <h:graphicImage value="/images/ajax/error.gif" />
       </f:facet>
      </rich:message>
      


      All works fine, but my problem is that when happend a validator error, I get something like:
      Username: Validation Error: Value is required.

      And I want that error message show only:
      Username: Value is required.

      How can I void string "Validation Error" and ":" separator?.

        • 1. Re: rich:message and validation error string
          j-pro

          You need to edit validatorMessages.properties file, placed in %JBOSS_HOME%\server\default\conf dir (I assume you're using JBoss). In my case if there is such error, message just shows: "Value is required." For that I have in validatorMessages.properties:

          javax.faces.component.UIInput.REQUIRED=Value is required.


          I'm sure, you'll find some more interesting messages and methods in this file ;)

          • 2. Re: rich:message and validation error string

            Thanks J-Pro!!!.

            I'm using Apache Tomcat, but now I'll investigated if there is something like "validatorMessages.properties".

            • 3. Re: rich:message and validation error string
              j-pro

              By the way, I've found interesting if validation messages will be as tooltips, but after I've made as you:

              <h:panelGroup>
               <h:inputText id="employeeFirstNameEdit" required="true" value="#{amBean.employee.lastName}"/>
               <rich:message for="employeeFirstNameEdit" tooltip="true">
               <f:facet name="passedMarker">
               <h:graphicImage value="images/valid_ok.gif" />
               </f:facet>
               <f:facet name="errorMarker">
               <h:graphicImage value="/images/valid_err.gif" />
               </f:facet>
               </rich:message>
              </h:panelGroup>


              I have no changes on my page... messages are shown just as it was before, with simple "<rich:message for="employeeFirstNameEdit"/>" - without tooltips and without any pictures(I've made it of course).

              But in HTML source I see all that as:
              <td>
               <input type="text" value="" name="employeeTab_editForm:employeeFirstNameEdit" id="employeeTab_editForm:employeeFirstNameEdit">
               <span class="rich-message" id="employeeTab_editForm:j_id56">
               <span class="rich-message-marker">
               <img src="/HRD/images/valid_err.gif">
               </span>
               <span title="Value is required." class="rich-message-label">
              
               Value is requ?????ired.
              
               </span>
               </span>
              </td>


              Do you have it working right?

              • 4. Re: rich:message and validation error string

                Mmm... you 're right, tooltip doesn't work. I'm getting same behavor with tooltip="true" than tooltip="false"...
                I try it days ago and forget remove this from my code!!! :P

                • 5. Re: rich:message and validation error string
                  ilya_shaikovsky

                  To the first post - showDetail = false should remove detailed description from message.

                  • 6. Re: rich:message and validation error string

                    Hi ilya,
                    If I set to false showDetail at message tag, I get an empty message. I want only remove string "Validation Error:" from "Password: Validation Error: Value is required.".
                    Or...redefine full string...

                    • 7. Re: rich:message and validation error string
                      dmitry.demyankov

                       

                      "arielfernando" wrote:
                      ...redefine full string...

                      Use requiredMessage attribute of h:inputText

                      • 8. Re: rich:message and validation error string
                        syvalta

                        rich:message seems to prepend the label (or id if label is not defined) of the component it is printed for to the message outputted. Can this be prevented somehow? In my case it's clear from the positioning to which component the error relates to, so the label is not needed.