how to dynamically alter a rich:modalPanel?
asookazian Nov 15, 2007 6:43 PMHi, 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>