2 Replies Latest reply on Feb 6, 2009 2:25 PM by crudolf

    h:message inside h:column

    crudolf

      Hello,


      i want to show a message to the user, if he clicked an item out of a dataTable:



      <h:dataTable value="#{list}">
      <h:column>
      
       <h:inputText id="test"/>
       <h:message for="test">
       <s:button action="#{TestComponent.testAction}"
      
      </h:column>
      </h:dataTable>



      The action looks like



      void testAction() {
        StatusMessages.instance().addToControl("test", "Message for the Component with the ID=test");
      }



      But the message does not appear on the side, instead a JBoss warning appears:




      WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=null[severity(INFO 0), summary=(Message for the Component with the ID=test), detail(Message for the Component with the ID=test)]




      Is this a bug of StatusMessages or is there another way to add a message to a component inside of a dataTable?

        • 1. Re: h:message inside h:column
          crudolf

          I could not find a solution so i do this hack:


          I calculate the component ID on the server side and pass the ID to the button:


          <c:set var="messageContainerId" value="#{rich:clientId('test')}"/>
          <s:button action="#{TestComponent.testAction}">
            <f:param name="messageContainerId" value="#{messageContainerId}">
          </s:button>



          Now i can access the id of the component via:


          String messageContainerId= FacesContext.getCurrentInstance().getExternalContext().
          getRequestParameterMap().get("messageContainerId");



          And add a message via the classic JSF way:


          FacesContext.getCurrentInstance().addMessage(messageContainerId, 
          "Message for the Component with the ID=test");



          Now the message is displayed correctly and the sourceId is valid.


          Does anybody now a cleaner and more seam-solution?

          • 2. Re: h:message inside h:column
            crudolf

            Sorry i do not know how to edit a post, so:



            I calculate the component ID on the server side and pass the ID to the button:

            was wrong, i meant:



            I calculate the component ID on the client side and pass the ID to the button: