1 Reply Latest reply on Nov 15, 2007 7:11 PM by asookazian

    how to dynamically alter a rich:modalPanel?

    asookazian

      Hi, I need to support three different versions of basically the same rich:modalPanel due to variations on use case (happy path, alternate path, etc). One to submit a note, one to submit a note and submit the dataTable row data, and one for both. Is it possible to dynamically re-construct the tags/structure of the rich:modalPanel? I have done this before using UIComponent class and other classes in a backing bean or session bean. I got feedback from Seam dev in Seam forum that this is a bad practice b/c the presentation layer is not creeping into business layer.

      so how should I handle this? I'd rather not deal with 3 different modalPanel's because the id's need to be unique for all components and it becomes difficult to code for (e.g. noteText reference rather than noteText1, noteText2, etc) and you need to add a lot of conditional statements to handle it. any advice appreciated. thx.

      <rich:modalPanel id="mpNote" minHeight="200" minWidth="450"
       height="500" width="500" zindex="2000">
      
       <f:facet name="header">
       <a4j:form id="a4jHeaderForm1">
       <h:outputText id="headerText1" value=""/>
       </a4j:form>
       </f:facet>
      
       <a4j:form id="a4jMainForm1">
       <h:panelGrid columns="2" style="vertical-align:middle">
       <h:outputText id="description1" value=""/>
       <BR/>
       <h:inputTextarea id="noteText1" value="#{noteAction.noteText}" rows="6" cols="50"/>
       <!-- hidden variables are null/empty in NoteAction submit method, using Seam remoting -->
      
       <h:inputHidden id="rowIndex1" value="noteAction.rowIndex"/>
       <h:inputHidden id="colName1" value="noteAction.colName"/>
       <h:inputHidden id="securityAuditRowNum1" value="#{mainForm:dataTable1:myAuditList.getRowIndex()}"/>
       <a4j:commandButton value="submit" action="#{noteAction.submit}" onclick="showNoteGraphic();Richfaces.hideModalPanel('mpNote')"/>
      
       <BR/>
       <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mp');unselectCurrentRadioButton()"/>
       </h:panelGrid>
       </a4j:form>
       </rich:modalPanel>
      
       <rich:modalPanel id="mpEmployeeSubmit" minHeight="200" minWidth="450"
       height="500" width="500" zindex="2000">
      
       <f:facet name="header">
       <a4j:form id="a4jHeaderForm2">
       <h:outputText id="headerText2" value=""/>
       </a4j:form>
       </f:facet>
      
       <a4j:form id="a4jMainForm2">
       <h:panelGrid columns="2" style="vertical-align:middle">
       <h:outputText id="description2" value=""/>
       <BR/>
      
       <!-- hidden variables are null/empty in NoteAction submit method, using Seam remoting -->
      
       <h:inputHidden id="rowIndex2" value="noteAction.rowIndex"/>
       <h:inputHidden id="colName2" value="noteAction.colName"/>
       <h:inputHidden id="securityAuditRowNum2" value="#{mainForm:dataTable1:myAuditList.getRowIndex()}"/>
       <a4j:commandButton value="submit" action="#{securityAuditAction.submit}" onclick="Richfaces.hideModalPanel('mpEmployeeSubmit')"/>
      
       <BR/>
       <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mp');unselectCurrentRadioButton()"/>
      
       </h:panelGrid>
       </a4j:form>
       </rich:modalPanel>
      
       <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"/>
       <!-- hidden variables are null/empty in NoteAction submit method, using Seam remoting -->
      
       <h:inputHidden id="rowIndex3" value="noteAction.rowIndex"/>
       <h:inputHidden id="colName3" value="noteAction.colName"/>
       <h:inputHidden id="securityAuditRowNum3" value="#{mainForm:dataTable1:myAuditList.getRowIndex()}"/>
       <a4j:commandButton value="submit" action="#{noteAction.submit}" onclick="showNoteGraphic();Richfaces.hideModalPanel('mpNoteAndEmployeeSubmit')"/>
       <BR/>
       <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mp');unselectCurrentRadioButton()"/>
       </h:panelGrid>
       </a4j:form>
       </rich:modalPanel>
      


        • 1. Re: how to dynamically alter a rich:modalPanel?
          asookazian

          this is an example of dynamically modifying a dataTable based on the # of columns returned from a stored proc. I have this code in a SFSB and a Seam dev said it's not ok to do this. But it seems to me I'd have to do something like this to dynamically modify the rich:modalPanel...

          public void populateDynamicDataTable() {
          
           // Any columns?
           if (myList != null && myList.size() > 0) {
           dynamicDataTable = new HtmlDataTable();
          
           // Get amount of columns.
           int columns = ((List) myList.get(0)).size();
          
           // Set columns.
           for (int i = 0; i < columns; i++) {
          
           // Set header (optional).
           UIOutput header = new UIOutput();
           header.setValue(headers);
          
           // Set output.
           UIOutput output = new UIOutput();
           ValueBinding myItem =
           FacesContext
           .getCurrentInstance()
           .getApplication()
           .createValueBinding("#{myItem[" + i + "]}");
           output.setValueBinding("value", myItem);
          
           // Set column.
           UIColumn column = new UIColumn();
           column.setHeader(header);
           column.getChildren().add(output);
          
           // Add column.
           dynamicDataTable.getChildren().add(column);
           }
           }
           }