1 Reply Latest reply on Nov 30, 2010 6:08 AM by Ilya Shaikovsky

    editable dataTable + error messages

    cyril vidal Newbie

      Dear all,

       

      I wonder if there's an easy way to make editable rich:dataTable and rich:message work together.

      Let me explain my case:

       

      1°) I let the user update some values of specific columns in resultsets of rich:dataTable.

           If the field is in edit mode, an inputText is displayed, surrounded by a decorate element

       

      {code:xml}
      <rich:column  headerClass="left" id="id_col">
           <f:facet name="header">#{messages['userSphinx.email.label']}</f:facet>
                   <a4j:outputPanel id="email_c">
                            <s:decorate id="email_d" template="/layout/field/edit.jspx"  rendered="#{rechercherUserSphinxAction.contains(userSphinx)}">
                                  <h:inputText id="email_b" value="#{userSphinx.email}"  required="true"/>
                            </s:decorate>
                            <h:outputText value="#{userSphinx.email}" rendered="#{!rechercherUserSphinxAction.contains(userSphinx)}"/>
                    </a4j:outputPanel>
      </rich:column>
      {code}

       

      <rich:column  headerClass="left" id="id_col">
           <f:facet name="header">#{messages['userSphinx.email.label']}</f:facet>
                   <a4j:outputPanel id="email_c">
                            <s:decorate id="email_d" template="/layout/field/edit.jspx"  rendered="#{rechercherUserSphinxAction.contains(userSphinx)}">
                                  <h:inputText id="email_b" value="#{userSphinx.email}"  required="true"/>
                            </s:decorate>
                            <h:outputText value="#{userSphinx.email}" rendered="#{!rechercherUserSphinxAction.contains(userSphinx)}"/>
                    </a4j:outputPanel>
      </rich:column>{code}

       

      The edit.jspx includes by itself a rich:message linked to email_b id

       

      {code:xml}

      <rich:message for="email_b"/>

      {code}

       

      2°) If a specific wrong value is entered by the user in the email field, an error is generated by adding an error message to the specific client id linked to the inputText, i.e <b>email_b</b>

       

      {code}

      protected UserSphinx doUpdate() {
        if (getInstance().getEmail().equalsIgnoreCase("toto")){
          getStatusMessages().addToControl("email_b", Severity.ERROR, "email error!");
          return null;
        }
        return getUserSphinxManager().update(getInstance());
      }

      {code}

       

      3°) Unfortuntaley, when the page is rendered, no message is displayte but only the following error trace in the console:

       

      {color:red}

      WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=resF:userSphinxDt:email_d:email_b[severity=(ERROR 2), summary=email error!), detail=(email error!)]

      {color}

       

      4°) As far as I understand, there is a problem in generating the id of the field put in error.

      The MessageRenderer#encodeEnd method use the augmentIdReference(clientId, component); method to calculate the correct html element id, but in this case, omit the number row of the dataTable, which turns to be the real client id.

       

      So we get an error because instead of having such a client id with row index

      resF:userSphinxDt:1:email_d:email_b (row 1)

      or

      resF:userSphinxDt:2:email_d:email_b (row 2)

       

      richfaces calculates the following id resF:userSphinxDt:email_d:email_b which corresponds to nothing in the HTML tree.

       

      5°) Did anybody was successfull in putting all this stuff in work or can anybody give me a suggestion?

       

      Thanks in advance