1 Reply Latest reply on Jun 22, 2008 12:30 PM by Tuna Tore

    Modal Pane first time returns empty (null)

    Tuna Tore Newbie

      I have the folowing code in my xhtml file. I try to open a modalpane and show staff's information in that modal pane. However the code below doesn't work like that I want;

      <h:column>
      <center>
      <a4j:commandLink action="#{AdminPanelBean.chooseStaffs}" value="Update" oncomplete="javascript:Richfaces.showModalPanel('mp',{width:425,height:200})" reRender="staffUpdateForm">
      </a4j:commandLink>
      </center>
      </h:column>


      This is the backing bean method to choose a staff from datatable

      public String chooseStaffs()
       {
       try
       {
       Staff tStaff = (Staff)getStaffTable().getRowData();
       mainStaff = tStaff;
       AJAXModalPaneRender=true;
       }
       catch(Exception e)
       {
       log.log(Level.SEVERE,"Admin Panel : ChooseStaff ");
       }
       return "refresh";
       }



      Here is my modalpane code;

      <rich:modalPanel id="mp" minHeight="100" minWidth="250"
       resizeable="false" height="250" width="200" zindex="2000"
       rendered="true">
      
       <f:facet name="header">
       <h:outputText value="Update Information" />
       </f:facet>
       <f:facet name="controls">
       <h:graphicImage value="/images/close.png" style="cursor:pointer"
       onclick="Richfaces.hideModalPanel('mp')" />
       </f:facet>
       <h:form id="staffUpdateForm">
       <table cellpadding="0" cellspacing="0" border="0">
       <tr>
       <td align="left"><h:outputLabel style="color:Black;font-weight: bold;"
       for="sfirstname" value="First name"></h:outputLabel></td>
       <td align="left"><h:inputText id="sfirstname"
       value="#{AdminPanelBean.mainStaff.staffFirstname}" validatorMessage="Max : 50 Characters">
       <f:validateLength minimum="0" maximum="50" />
       </h:inputText>
       </td>
       <td><a4j:outputPanel ajaxRendered="true"><h:message for="sfirstname" id="error" errorClass="errors" showDetail="false" showSummary="true"></h:message></a4j:outputPanel></td>
       </tr>
       <tr>
       <td align="left"><h:outputLabel style="color:Black;font-weight: bold;"
       for="slastname" value="Last Name"></h:outputLabel></td>
       <td align="left"><h:inputText id="slastname"
       value="#{AdminPanelBean.mainStaff.staffLastname}" validatorMessage="Max : 50 Characters">
       <f:validateLength minimum="0" maximum="50" />
       </h:inputText></td>
       <td><a4j:outputPanel ajaxRendered="true"><h:message for="slastname" id="error1" errorClass="errors" showDetail="false" showSummary="true"></h:message></a4j:outputPanel></td>
       </tr>
       <tr>
       <td align="left"><h:outputLabel style="color:Black;font-weight: bold;"
       for="susername" value="Staff Username"></h:outputLabel></td>
       <td align="left"><h:inputText id="susername"
       value="#{AdminPanelBean.mainStaff.staffUsername}" validatorMessage="Max : 50 Characters">
       <f:validateLength minimum="0" maximum="50" /></h:inputText></td>
       <td><a4j:outputPanel ajaxRendered="true"><h:message for="susername" id="error2" errorClass="errors" showDetail="false" showSummary="true"></h:message></a4j:outputPanel></td>
       </tr>
       <tr>
       <td align="left"><h:outputLabel style="color:Black;font-weight: bold;"
       for="spassword" value="Staff Password"></h:outputLabel></td>
       <td align="left"><h:inputText id="spassword"
       value="#{AdminPanelBean.mainStaff.staffPassword}" validatorMessage="Max : 50 Characters">
       <f:validateLength minimum="0" maximum="50" /></h:inputText></td>
       <td><a4j:outputPanel ajaxRendered="true"><h:message for="spassword" id="error3" errorClass="errors" showDetail="false" showSummary="true"></h:message></a4j:outputPanel></td>
       </tr>
       <tr>
       <td align="left"><h:outputLabel style="color:Black;font-weight: bold;"
       for="stelephone" value="Staff Telephone"></h:outputLabel></td>
       <td align="left"><h:inputText id="stelephone"
       value="#{AdminPanelBean.mainStaff.staffTelephone}" validatorMessage="Max : 50 Characters">
       <f:validateLength minimum="0" maximum="50" />
       </h:inputText>
       </td>
       <td><a4j:outputPanel ajaxRendered="true"><h:message for="stelephone" id="error4" errorClass="errors" showDetail="false" showSummary="true"></h:message></a4j:outputPanel></td>
       </tr>
       <tr>
       <td align="left"><h:outputLabel style="color:Black;font-weight: bold;"
       for="semail" value="Staff Email"></h:outputLabel></td>
       <td align="left"><h:inputText id="semail"
       value="#{AdminPanelBean.mainStaff.staffEmail}" validatorMessage="Email Max : 50 Characters">
       <f:validateLength minimum="0" maximum="50" /></h:inputText>
       </td>
       <td align="right">
       <a4j:commandButton oncomplete="windowclose();" value="Update" action="#{AdminPanelBean.updateStaff}" reRender="sfirstname" >
       </a4j:commandButton>
       </td>
       </tr>
       <tr>
       <td>
       <h:inputHidden id="stffid" value="#{AdminPanelBean.mainStaff.staffId}">
       </h:inputHidden>
       <h:inputHidden id="stffmodalparam" value="staffUpdate" /></td>
       <td ><a4j:outputPanel ajaxRendered="true"><h:message for="semail" id="error5" errorClass="errors" showDetail="false" showSummary="true"></h:message></a4j:outputPanel></td>
       <td> </td>
       </tr>
      
       </table>
       </h:form>
       </rich:modalPanel>


      The problem is that when I choose a staff with a code like that

      <h:column>
       <center><h:commandButton value="Choose" actionListener="#{AdminPanelBean.chooseStaff}" /></center>
       </h:column>


      Backing bean
      public String chooseStaff(ActionEvent ae)
       {
       try
       {
       Staff tStaff = (Staff)getStaffTable().getRowData();
       mainStaff = tStaff;
       AJAXModalPaneRender=true;
       }
       catch(Exception e)
       {
       log.log(Level.SEVERE,"Admin Panel : ChooseStaff ");
       }
       return "refresh";
       }


      the page refresh and if I press after choose to update modal pane works greatly and show the results in a modal pane. But in this way I must always press choose button.

      I want to open a modal pane by clicking only one button or a link button the first code never choose a staff?

      I didn't solve this problem. I need some advices thank you for answers