2 Replies Latest reply on Oct 11, 2007 8:40 AM by mrmarcondes

    modalPanel problem

      Hi all,

      I have a problem with modalPanel + validation.

      First of all, I'm using:
      - richfaces 3.1.1;
      - myFaces 1.2;
      - jbossAS 4.2.1

      The steps of the problem are illustrated in:
      http://www.megon.com.br/jboss

      1. I have a list of records showed by <rich:dataTable> (code below);
      2. I have a modalPanel to create/ edit/ delete records on the list (code below);
      3. to create a new record I open the modal, input valid data and save the record, the modal is hidden and the new record appears in the list;
      4. if I want to edit a record, I select the record then the backing bean method showEditLimit() is called and the modal appears with the data of the selected record;
      5. but, if in step 3 I put invalid data and click on save button and after that I click on CancelButton and click to Edit a record the modal opens without data.
      6. I saw in debug mode that the backing bean method showEditLimit() was called but the modal is still empty.

      It seems that the reRender doesn't work well if validation modalPanel is called.

      Can anybody help me, please?

      1. code of <rich:dataTable>

      <rich:tabPanel switchType="client" id="tabPainel" height="200">
       <rich:tab label="#{resourceCommonsMessages.group_limit}" name="limit">
       <rich:dataTable
       onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
       onRowClick="this.style.backgroundColor='#FFF8D9'"
       columnClasses="list-column-first, list-column-second, list-column-third, list-column-fourth, list-column-view, list-column-del"
       id="limitsList" rows="4" styleClass="dtgridtab"
       value="#{mcduController.resourceVO.limitList}" rowKeyVar="rowKey" var="resourceLimitVO">
       <f:facet name="header">
       <rich:columnGroup>
       <rich:column>
       <h:outputText value="#{resourceCommonsMessages.field_limit_begin_date}"/>
       </rich:column>
       <rich:column>
       <h:outputText value="#{resourceCommonsMessages.field_limit_end_date}">
       <f:convertDateTime pattern="#{commonsMessages.date_pattern}"/>
       </h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="#{resourceCommonsMessages.field_limit_value}">
       </h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="#{resourceCommonsMessages.field_limit_consume}">
       </h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="#{commonsMessages.button_edit}"/>
       </rich:column>
       <rich:column>
       <h:outputText value="#{commonsMessages.button_remove}"/>
       </rich:column>
       </rich:columnGroup>
       </f:facet>
       <rich:column>
       <h:outputText value="#{resourceLimitVO.beginDate}">
       <f:convertDateTime pattern="#{commonsMessages.date_pattern}"/>
       </h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="#{resourceLimitVO.endDate}"/>
       </rich:column>
       <rich:column>
       <h:outputText value="#{resourceLimitVO.value}">
       <f:convertNumber pattern="#{commonsMessages.double_pattern}"/>
       </h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="#{resourceLimitVO.consume}">
       <f:convertNumber pattern="#{commonsMessages.double_pattern}"/>
       </h:outputText>
       </rich:column>
       <rich:column>
       <a4j:commandButton value="#{commonsMessages.button_edit}" action="#{mcduController.showEditLimit}" onclick="Richfaces.showModalPanel('mpLimit',{width:450, top:200})" reRender="limitScroller,limitsList,limitValue,limitConsume,limitBeginDate,limitEndDate" immediate="true" image="/images/document.gif"/>
       </rich:column>
       <rich:column>
       <a4j:commandButton value="#{commonsMessages.button_remove}" action="#{mcduController.doDeleteLimit}" reRender="limitScroller,limitsList,value,consume,beginDate,endDate" immediate="true" image="/images/close.gif"/>
       </rich:column>
       </rich:dataTable>
      



      2. code of modal
      <a4j:outputPanel>
       <rich:modalPanel id="mpLimit" minHeight="130" minWidth="450" height="130" width="450" zindex="2000">
       <f:facet name="header">
       <h:outputText value="#{resourceCommonsMessages.limit_title}" />
       </f:facet>
       <h:form id="form1">
       <table width="100%" border="0">
       <tr>
       <td width="100">
       <h:outputText value="#{resourceCommonsMessages.field_limit_value}"></h:outputText>
       </td>
       <td>
       <h:inputText id="limitValue" style="width:100%;" value="#{mcduController.resourceLimitVO.value}" label="#{resourceCommonsMessages.field_limit_value}" required="true" converterMessage="#{commonsMessages.double_conversion_error}" requiredMessage="#{commonsMessages.required_message}">
       <f:convertNumber pattern="#{commonsMessages.double_pattern}"/>
       </h:inputText>
       </td>
       <td width="100" align="right">
       <h:outputText value="#{resourceCommonsMessages.field_limit_consume}"></h:outputText>
       </td>
       <td>
       <h:inputText id="limitConsume" style="width:100%;" value="#{mcduController.resourceLimitVO.consume}" label="#{resourceCommonsMessages.field_limit_consume}" required="true" converterMessage="#{commonsMessages.double_conversion_error}" requiredMessage="#{commonsMessages.required_message}">
       <f:convertNumber pattern="#{commonsMessages.double_pattern}"/>
       </h:inputText>
       </td>
       </tr>
       <tr>
       <td width="100">
       <h:outputText value="#{resourceCommonsMessages.field_limit_begin_date}"></h:outputText>
       </td>
       <td>
       <h:inputText id="limitBeginDate" style="width:100%;" value="#{mcduController.resourceLimitVO.beginDate}" required="true" label="#{resourceCommonsMessages.field_limit_begin_date}" converterMessage="#{commonsMessages.date_conversion_error}" requiredMessage="#{commonsMessages.required_message}">
       <f:convertDateTime pattern="#{commonsMessages.date_pattern}"/>
       </h:inputText>
       </td>
       <td width="100" align="right">
       <h:outputText value="#{resourceCommonsMessages.field_limit_end_date}"/>
       </td>
       <td>
       <h:inputText id="limitEndDate" style="width:100%;" value="#{mcduController.resourceLimitVO.endDate}" required="true" label="#{resourceCommonsMessages.field_limit_end_date}" converterMessage="#{commonsMessages.date_conversion_error}" requiredMessage="#{commonsMessages.required_message}">
       <f:convertDateTime pattern="#{commonsMessages.date_pattern}"/>
       </h:inputText>
       </td>
       </tr>
       </table>
       <rich:panel styleClass="mdbuttons">
       <a4j:commandButton value="#{commonsMessages.button_add}" oncomplete="windowCloseLimit();" action="#{mcduController.doSaveLimit}" reRender="limitScroller,limitsList,limitValue,limitConsume,limitBeginDate,limitEndDate" image="/images/ok.gif" title="Adicionar"/>
       <rich:spacer width="20" />
       <a href="#" onclick="form1.reset();Richfaces.hideModalPanel('mpLimit');">
       <h:graphicImage value="/images/cancel.gif"/>
       </a>
       </rich:panel>
       <rich:panel styleClass="messages">
       <a4j:outputPanel ajaxRendered="true">
       <h:messages id="error1" layout="list" showDetail="true" showSummary="false" />
       </a4j:outputPanel>
       </rich:panel>
       </h:form>
       </rich:modalPanel>
      </a4j:outputPanel>
      



      code of backing bean
       public void showEditLimit(){
       setIdResourceLimit(Integer.valueOf(getResourceLimitVO().hashCode()).toString());
       setResourceLimitVO(((ResourceLimitVO) getVO("resourceLimitVO")));
       }
      
      
       public Object getVO(String vo){
       FacesContext context= FacesContext.getCurrentInstance();
       HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
      
       return request.getAttribute(vo);
       }
      
      


      Thanks,
      Marco.