3 Replies Latest reply on Jan 1, 2007 9:01 PM by a m

    Validation Error Messages...

    Tony Herstell Master

      Getting a validation message raised in an Action to appear in the GUI next to the right field?

      if (usernameExists) {
       //facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_WARN, "username", "user_create_username_exists");
       facesMessages.addFromResourceBundle("submitAttempt", "user_create_username_exists");
       return null;
      } else {
      







      <div align="right">
       <ice:outputLabel for="username" value="#{messages.label_username}"/>
      </div>
      <s:decorate>
       <ice:inputText id="username" value="#{user.username}"
       required="true" title="#{messages.hint_username}" /> <!-- partialSubmit="true" - Don't use yet as something eats the input focus [Bug with IceFaces team]-->
      </s:decorate>
      <ice:outputText value="#{messages.tag_mandatory}" styleClass="mandatory" />
      <ice:outputText value=""/>
      <div align="left">
       <ice:message errorClass="error" for="username" />
      </div>
      <ice:outputText value=""/>
      



      <ice:panelGrid columns="2" width="100%">
       <div align="right">
       <ice:commandButton action="#{userRegistrationManager.cancel}" value="#{messages.button_cancel}" immediate="true" type="submit" />
       <ice:commandButton id="submitAttempt" type="submit" value="#{messages.button_create}" action="#{userRegistrationManager.processUserDetails}" styleClass="button" /> <!-- disabled="#{!user.readyForSubmission}" -->
       </div>
      </ice:panelGrid>
      
      <ice:panelGrid columns="1">
       <ice:message infoClass="error" for="submitAttempt" />
      </ice:panelGrid>
      



      In the above code segment I want to see the error message with the username (as per the commented out line) field as apposed to the button... however how do you make it appear?


      The severtity appears to have no effect.


        • 1. Re: Validation Error Messages...
          Tony Herstell Master

          Anyone any ideas on this one?

          • 2. Re: Validation Error Messages...
            a m Newbie

            i have a similar problem. h:message shows the validation messages correctly but s:message just doesn't work.
            i followed exactly this tutorial: http://docs.jboss.com/seam/1.1GA/reference/en/html/validation.html
            but when the page reloads theres no text on the page. the console of the as shows this:

            sourceId=j_id7:passwort[severity=(ERROR 2), summary=(j_id7:passwort: Validierungs-Fehler: Wert wird benötigt.), detail=(j_id7:passwort: Validierungs-Fehler: Wert wird benötigt.)]
            sourceId=j_id7:benutzername[severity=(ERROR 2), summary=(j_id7:benutzername: Validierungs-Fehler: Wert wird benötigt.), detail=(j_id7:benutzername: Validierungs-Fehler: Wert wird benötigt.)];|WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
            


            my configuration is seam 1.1, jsf 1.2, facelets 1.1.1 on sun as 9.0

            the template client which needs validation
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:f="http://java.sun.com/jsf/core">
            
             <body>
            
             <ui:composition template="maintemplate.xhtml">
             <ui:define name="title">
             Einloggen
             </ui:define>
            
             <ui:define name="body">
             <div>
             <h:messages globalOnly="true"/>
             </div>
            
             <h:form>
             <f:facet name="afterInvalidField">
             <s:messages/>
             </f:facet>
             <s:validateAll>
             Benutzername
             <s:decorate>
             <h:inputText id="benutzername" value="#{benutzer.benutzername}" required="true"/>
             </s:decorate>
             Passwort
             <s:decorate>
             <h:inputSecret id="passwort" value="#{benutzer.passwort}" required="true"/>
             </s:decorate>
             <h:commandButton type="submit" value="Einloggen" action="#{lokaleinloggen.einloggen}"/>
             </s:validateAll>
             </h:form>
             </ui:define>
            
             </ui:composition>
            
             </body>
            </html>
            


            the template:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:f="http://java.sun.com/jsf/core">
            
             <head>
             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
             <title>Projektplaner/SVN-System</title>
             <link href="css/default.css" rel="stylesheet" type="text/css" />
             </head>
            
             <body>
             <img src="pics/fhlogo.gif"/>
             <div class="title">
             <span class="title">
             Projektplaner
             </span>
             <span class="title2nd">
             <ui:insert name="title"></ui:insert>
             </span>
             </div>
             <p>
             <ui:insert name="body"></ui:insert>
             </p>
             </body>
            
            </html>
            


            • 3. Re: Validation Error Messages...
              a m Newbie

              oh damn i forgot to include the seam-ui.jar in the war project