0 Replies Latest reply on Dec 4, 2008 7:53 PM by Robert Traversi

    Problem on rerender of modalPanel

    Robert Traversi Newbie

      I probably lack understanding of some detail abut how these panels work and the life cycle of an entity.  Could somebody help point me in the right direction?


      I am having a problem when I return from a modalPanel.


      I am using a commandButton on the panel to save updates.


      When I return, I get an error during render saying that the id is the wrong type (String instead of Long).  I am reading the managed attribute on the EntityHome bean to determine rendering of the commandButton(s).


      If I remove the rendered attribute it works fine but I have these panels in a number of places within the application and most have different buttons rendered depending on the entityHome state.


      Here are some code snippets if they will help.



              <div class="association" id="commentsesChildren">
              
                  <rich:dataTable value="#{esrsHome.topLevelEsrCommentses}" 
                                 var="esrComments" 
                            rendered="#{not empty esrsHome.esrCommentses}" 
                          rowClasses="rvgRowOne,rvgRowTwo"
                                  id="esrCommentsesTable">
                      <h:column>
                          <f:facet name="header">Comment Thread</f:facet>
                          <rich:tree switchType="client">
                               <rich:treeNodesAdaptor id="cmt" var="cmt" nodes="#{esrComments}">
                          <rich:treeNode>
                               <b>
                               <a:commandLink id="rootCommentLinkA"
                                    action="#{projectTrackingHelper.setTrackingAttributes(cmt.id,cmt.commentText)}"
                                    oncomplete="Richfaces.showModalPanel('editCommentPanel');"
                                    reRender="esrEditCommentsForm">
                                                 #{cmt.commentText}
                               </a:commandLink>
                               </b>
                          </rich:treeNode>
                          <rich:recursiveTreeNodesAdaptor id="rply" var="rply"
                               roots="#{cmt.esrCommentses}" nodes="#{rply.esrCommentses}">
                               <rich:treeNode>
                                    <a:commandLink 
                                         action="#{projectTrackingHelper.setTrackingAttributes(rply.id,rply.commentText)}"
                                         oncomplete="Richfaces.showModalPanel('editCommentPanel');"
                                         reRender="esrEditCommentsForm">
                                                      #{rply.commentText}
                                    </a:commandLink>
                               </rich:treeNode>
                          </rich:recursiveTreeNodesAdaptor>
                     </rich:treeNodesAdaptor>
                    </rich:tree>
                      </h:column>
                  </rich:dataTable>
              </div>
      
      
      
           <!-- Popup for editing Comments. -->
           <rich:modalPanel  id="editCommentPanel" minHeight="320" minWidth="530" 
                       height="320" width="530" zindex="2000">    
      
               <f:facet name="header"> ... </f:facet>
               <f:facet name="controls"> ... </f:facet>
      
               <h:form id="esrEditCommentsForm" enctype="multipart/form-data" styleClass="edit">
                <div id="editPanelStuff">  <!-- Put in to try different reRender locations  -->
                     <s:decorate id="commentDecoration" template="layout/edit.xhtml">
                                    <ui:define name="label">Comment Text</ui:define>
                          <h:inputTextarea id="commentText"
                               cols="80"
                               rows="8"
                               required="true"
                               value="#{esrCommentsHome.commentText}"/>
                     </s:decorate>
      
                     <br/>
                     <div class="actionButtons" style="text-align: left">
                          <h:commandButton
                               id="update"
                               value="Update"
                               action="#{esrCommentsHelper.updateComment}"
                               rendered="#{esrCommentsHome.wired}"
                          />
                          <s:button
                               id="cancelModal"
                               value="Cancel"
                               onclick="#{rich:component('editCommentPanel')}.hide()" />
                     </div>
                </div>
               </h:form>
           </rich:modalPanel>   
      



      Bean:



      @Stateless
      @Name("esrCommentsHelper")
      public class EsrCommentsHelperBean implements EsrCommentsHelper {
           
          @In
          EsrCommentsHome esrCommentsHome;
          public void esrCommentsHelper()
          {
          }
          
          public void updateComment() {
               String newText = esrCommentsHome.getCommentText();
               Long id = esrCommentsHome.getEsrCommentsId();
               esrCommentsHome.clearInstance();
               esrCommentsHome.setId(id);
               esrCommentsHome.find();
               esrCommentsHome.getInstance().setCommentText(newText);
               esrCommentsHome.update();
          }
      }