0 Replies Latest reply on Feb 27, 2010 3:12 AM by kalpana prakasam

    How to display the appropriate message (info or warn) in s:decorate?

    kalpana prakasam Novice
              

      I am actually checking for availability of a login name and would like to show the info image or warn image with an appropriate message.

       

                  <s:decorate id="loginIdField" template="/layout/edit.xhtml">
                     
      <ui:define name="label">Desired Login Name</ui:define>
                     
      <a:region>
                         
      <h:inputText id="loginId" required="true" value="#{userHome.instance.loginId}"/>
                         
      <s:message warnStyle="color: red" infoStyle="color: green"/>
                         
      <div class="actionButtons">
                             
      <a:commandButton id="submit" value="Check Availability"
                                 
      action="#{userHome.isUnique(userHome.instance.loginId)}" reRender="loginIdField"/>
                         
      </div>
                     
      </a:region>
                 
      </s:decorate>

      Code to add appropriate messages in the bean.

       

          if (!unique) {
              statusMessages
                     
      .addToControlFromResourceBundle(
                             
      "loginId",
                              WARN
      ,
                             
      "LoginIdNotUnique",
                             
      new Object[] { inputLoginId });
         
      } else {
              statusMessages
      .addToControlFromResourceBundle("loginId", INFO,
                     
      "LoginIdUnique",
                     
      new Object[] { inputLoginId });
         
      }

      edit.xhtml

       

      <ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                      
      xmlns:ui="http://java.sun.com/jsf/facelets"
                      
      xmlns:h="http://java.sun.com/jsf/html"
                      
      xmlns:f="http://java.sun.com/jsf/core"
                      
      xmlns:rich="http://richfaces.org/rich"
                      
      xmlns:s="http://jboss.com/products/seam/taglib">

         
      <div class="prop">

             
      <s:label styleClass="name #{invalid?'errors':''}">
                 
      <ui:insert name="label"/>
                 
      <s:span styleClass="required" rendered="#{required}">*</s:span>
             
      </s:label>
             
      <div style="clear: both"/>

             
      <span class="value #{invalid?'errors':''}">
                 
      <s:validateAll>
                     
      <ui:insert/>
                 
      </s:validateAll>
             
      </span>

             
      <span class="error">
                 
      <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors"/>
                 
      <s:message styleClass="errors"/>
             
      </span>

         
      </div>

      </ui:composition>