1 Reply Latest reply on Dec 12, 2007 11:18 AM by asookazian

    modalPanel best practice data passing question

    asookazian

      So I need to submit a form with input text in a rich:modalPanel. When I reference the fields of the dataTable in the main form of the facelet in which the modalPanel exists I get -1 for rowIndex and the other values are null in the SFSB method.

      <!-- note and row data submit -->
       <rich:modalPanel id="mpNoteAndEmployeeSubmit" minHeight="200" minWidth="450"
       height="500" width="500" zindex="2000">
      
       <f:facet name="header">
       <a4j:form id="a4jHeaderForm3">
       <h:outputText id="headerText3" value=""/>
       </a4j:form>
       </f:facet>
      
       <a4j:form id="a4jMainForm3">
       <h:panelGrid columns="2" style="vertical-align:middle">
       <h:outputText id="description3" value=""/>
       <BR/>
      
       <h:inputTextarea id="noteText3" value="#{noteAction.noteText}" rows="6" cols="50">
       <a4j:support event="onkeyup" reRender="out3" />
       </h:inputTextarea>
      
       <h:panelGroup id="out3">
       <a4j:commandButton id="submit3" value="submit" actionListener="#{noteAction.submit}" oncomplete="clickDataTableSubmit();Richfaces.hideModalPanel('mpNoteAndEmployeeSubmit')"
       rendered="#{not empty noteAction.noteText2}">
       <f:attribute name="rowIndex" value="#{myAuditList.getRowIndex()}"/>
       <f:attribute name="siteId" value="#{myRow[0].id.siteId}"/>
       <f:attribute name="employeeNumber" value="#{myRow[0].id.employeeNumber}"/>
       <f:attribute name="modalPanelName" value="mpNoteAndEmployeeSubmit"/>
       </a4j:commandButton>
       </h:panelGroup>
      
       <BR/>
      
       <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mpNoteAndEmployeeSubmit');unselectCurrentRadioButton()"/>
       </h:panelGrid>
       </a4j:form>
       </rich:modalPanel>


      Should I set global JS variables before the modalPanel opens and use js functions with f:attribute, pass params via the showModalPanel call, or use Seam remoting (currently using Seam remoting as I just recently found out that f:param does not work with h:commandButton, only h:commandLink. Now I know I can use f:attribute with h:commandButton).

      What's the recommendation here?

        • 1. Re: modalPanel best practice data passing question
          asookazian

          Here's the SFSB code:

          //submit method called from adminSecurityAudit.xhtml modalPanel a4j:form's
           public void submit(ActionEvent event) {
          
           UIComponent component = event.getComponent();
           Map<String, Object> attrs = component.getAttributes();
          
           int attrsSize = attrs.size();
          
           Integer rowIndex = (Integer)attrs.get("rowIndex");
           Integer siteId = (Integer)attrs.get("siteId");
           Integer employeeNumber = (Integer)attrs.get("employeeNumber");
           String modalPanelName = (String)attrs.get("modalPanelName");
          
           log.info("*** attrsSize = " + attrsSize);
           log.info("rowIndex = " + rowIndex + " *** siteId = " + siteId +
           " *** employeeNumber = " + employeeNumber);
          
           //in the case of yes/no/yes (with user entering selection for adjLimit RB last, check to make sure if the secLevel RB is No. If it's Yes (i.e. yes/yes/yes), don't proceed.
          
           if ( !( this.getIcomsAccountApproved() == true && this.getSecurityLevelApproved() == true && this.getAdjustmentLimitApproved() == true ) ) {
          
           if ( !modalPanelName.equalsIgnoreCase("mpEmployeeSubmit") ) { // in case of yes/no/yes, prevent insertion of blank note for the 3rd RB (adjLimit)
           //create a new instance of TblSecurityAuditNote entity bean
          
           TblSecurityAuditNote note = new TblSecurityAuditNote(siteId, employeeNumber, colName, noteText, new Date());
          
           //TO DO: remove hard-coding of the name-number mapping
           Integer colNum = convertColName(colName);
           Integer rowNum = rowIndex==null?0:rowIndex; //TO DO: add exception handling here in case null or empty string (throw application exception)
          
           TblSecurityAuditNote[] myNoteArray = noteList.get(rowNum);
           myNoteArray[colNum] = note;
          
           noteList.set(rowNum, myNoteArray);
          
           noteText = "";
           }
           }
          
           }