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

    how to make a modalPanel header display dynamic content

    asookazian

      I have a richfaces modalPanel that I would like the header to state as follows:

      "Please enter a note for Joe Shmoe" where 'Joe Shmoe' is a variable depending on what row/employee the user is trying to modify in the dataTable. I tried to achieve this using an AJAX call to set the instance variable in a SFSB that would then be displayed when the showModaPanel fires when users clicks 'no' on radio button.

      unfortunately, the problem is that the setter for the dynamic name content is happening after the getHeader method call so it's displaying like:
      "Please enter a note for"

      Any ideas or example on how to achieve this?

      here's some of the code:

      <rich:modalPanel id="mp" minHeight="200" minWidth="450"
       height="200" width="500" zindex="2000">
       <f:facet name="header">
       <h:outputText value="#{securityAuditAction.header}"/>
       </f:facet>
       <f:facet name="controls">
       <h:graphicImage value="/img/icon_edit.gif" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" />
       </f:facet>
       <a4j:form id="a4jForm">
       <h:panelGrid columns="2" style="vertical-align:middle">
       <h:inputText id="noteText" value="#{noteAction.noteText}"/>
       <h:inputHidden id="rowIndex" value="noteAction.rowIndex"/>
       <h:inputHidden id="colName" value="noteAction.colName"/>
       <h:inputHidden id="siteId" value="noteAction.siteId"/>
       <h:inputHidden id="employeeNumber" value="noteAction.employeeNumber"/>
       <a4j:commandButton value="submit" action="#{noteAction.submit}" onclick="showNoteGraphic();Richfaces.hideModalPanel('mp')"/>
       </h:panelGrid>
       </a4j:form>
       </rich:modalPanel>


      in dataTable:

      <h:selectOneRadio id="accountApprovedRB" value="#{myRow[1].icomsAccountApproved}" onclick="processNote(this, #{myAuditList.getRowIndex()}, 'accountApproved');checkForSubmit(#{myAuditList.getRowIndex()})">
       <f:selectItems value="#{securityAuditAction.securityAuditRadioButtons}" />
       </h:selectOneRadio>


      .js:

      function processNote(rButton, rowIndex, colName) {
      
       //if they clicked no, popup modal response window for note
       if (rButton.value == 'false') {
      
       siteId = document.getElementById("mainForm:dataTable1:"+rowIndex+":siteId").value;
       employeeNumber = document.getElementById("mainForm:dataTable1:"+rowIndex+":employeeNumber").value;
       employeeName = document.getElementById("mainForm:dataTable1:"+rowIndex+":employeeNameHidden").value;
      
       //Richfaces.showModalPanel('mp',{width:450, top:200, param1: rowIndex, param2: colName, param3: siteId, param4: employeeNumber});
       Richfaces.showModalPanel('mp',{width:450, top:200});
      
       //set hidden variables in modalPanel form
       document.getElementById("a4jForm:rowIndex").value = rowIndex;
       document.getElementById("a4jForm:colName").value = colName;
       document.getElementById("a4jForm:siteId").value = siteId;
       document.getElementById("a4jForm:employeeNumber").value = employeeNumber;
      
       //set focus to inputText of modalPanel
       document.getElementById("a4jForm:noteText").focus();
      
       //AJAX js functions...
       setCurrentEmployeeName(employeeName);
       getExistingNote(rowIndex, colName);
      
       }
       }


      SFSB method:
      public String getHeader() {
       log.info("in getHeader()");
       return "Please enter your note for " + currentEmployeeName;
       }


        • 1. Re: how to make a modalPanel header display dynamic content
          asookazian

          also need to know how to display dynamic content in the outputText tags as well for 'xyz' and 'Mike Bell':

          <rich:modalPanel id="mp" minHeight="200" minWidth="450"
           height="200" width="500" zindex="2000">
          
           <f:facet name="header">
           <!-- <h:outputText value="#{securityAuditAction.header}"/> -->
           <h:outputText value="Note for Mike Bell"/>
           </f:facet>
          
           <!--
           <f:facet name="controls">
           <h:graphicImage value="/img/icon_edit.gif" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" />
           </f:facet>
           -->
           <a4j:form id="a4jForm">
           <h:panelGrid columns="2" style="vertical-align:middle">
           <h:outputText id="description" value="Please explain why XYZ is not approved:"/>
           <BR/>
           <h:inputTextarea id="noteText" value="#{noteAction.noteText}" rows="6" cols="50"/>
           <h:inputHidden id="rowIndex" value="noteAction.rowIndex"/>
           <h:inputHidden id="colName" value="noteAction.colName"/>
           <h:inputHidden id="siteId" value="noteAction.siteId"/>
           <h:inputHidden id="employeeNumber" value="noteAction.employeeNumber"/>
           <a4j:commandButton value="submit" action="#{noteAction.submit}" onclick="showNoteGraphic();Richfaces.hideModalPanel('mp')"/>
           <BR/>
           <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mp')"/>
           </h:panelGrid>
           </a4j:form>
           </rich:modalPanel>