3 Replies Latest reply on Aug 25, 2008 1:35 PM by Veljko Vujcic

    how to target s:message

    Veljko Vujcic Newbie


      i'm developing an app which uses facelets templates in a similar fashion like in seam examples.

      this is edit.xhtml

          <div class="prop">
              <s:label styleClass="name #{invalid?'errors':''}">
                  <ui:insert name="label"/>
                  <s:span styleClass="required" rendered="#{required}"></s:span>
              <s:span styleClass="value #{invalid?'errors':''}">
              <s:span styleClass="error">
                  <h:graphicImage value="/img/error.png" rendered="#{invalid}" styleClass="errors"/>
                  <s:message styleClass="errors"/>

      and this is my point of interest

      <s:decorate id="d1" template="layout/edit.xhtml">
           <ui:define name="label">
           <h:outputFormat id="o1" ... />

      now, when user hits submit first i want to check the validity of some data and throw a message if something is wrong. so let's say the submit button calls for a method:

      public String validateAndSave() {
           if(somethingIsWrong) {
                FacesContext context = FacesContext.getCurrentInstance();
                FacesMessage message = new FacesMessage("i won't let you do this");
                context.addMessage("frmMain:d1:o1", message);
                return null;
           //do the job

      this won't work. now my question is: how do i target s:message? also, one detail from edit.xhtml: what is #{invalid}? it only looks like a seam component, but there's no way to access it from the beans. how can i manually turn it on?

      thanks a lot, veljko