2014-10-09 59 views
0

我無法從覆蓋面板中的文本框中將值從主窗體中的文本框中單擊覆蓋層上的提交按鈕面板。如何將文本字段值從覆蓋面板傳遞到父窗體

<?xml version="1.0" encoding="UTF-8"?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 

     xmlns:h="http://java.sun.com/jsf/html" 

     xmlns:f="http://java.sun.com/jsf/core" 

     xmlns:p="http://primefaces.org/ui"> 
    <h:head> 
     <style> 
      .link{ 

       color:blue; 

       font-size: 15px; 

      } 

      .form{ width: 300px; 

        margin: 0 auto; 

      } 

      .button{ 
      } 

     </style> 

     <title>Calendar</title> 
     <script> 
      function checkPasswords() { 

       alert("hii"); 

       alert(document.getElementById("form:pass").value); 

       alert("test"); 

       window.opener.document.getElementById("form:pass").value = document.getElementById("overPanel1:newpass").value; 

       // document.getElementById("overPanel1").hide(); 

       return false; 

      } 
     </script> 
    </h:head> 

    <h:body> 
     <h:form styleClass="form" id="form"> 
      Username : <p:inputText id="username" 
            value="#{userBean.username}"> 
       <f:validateLength minimum="5" maximum="7" /> 
      </p:inputText> 

      <h:message for="username" style="color:red" /> 
      <br /> 
      <br /> 
      Password : <p:password id="pass" 
            value="#{userBean.password}" /> 
      <br /> 
      <p:commandLink styleClass="link" 
          value="change Password" id="commandlink" 
          style="height:20px" /> 
      <p:overlayPanel id="overPanel1" 
          for="commandlink" 
          dynamic="true" 
          widgetVar="overpanel" 
          hideEffect="fade"> 
       <h:form id="innerform">      
        <h:panelGrid columns="1" cellpadding="1"> 
         New Password  : <p:password id="newpass" 
                 value="#{userBean.password}" /> 
         <br /> 
         <p:commandButton styleClass="button" 
             id="change" value="Change" 
             onclick=" return checkPasswords(); 
              overpanel.hide()"> 
          <!-- <p:ajax event="change" update="pass" partialSubmit="true" /> --> 
         </p:commandButton> 
        </h:panelGrid> 
       </h:form> 
      </p:overlayPanel> 
      <br /> 
      <br /> 
      Date Of Birth : <p:calendar value="#{dateBean.date}" 
             mode="popup" showOn="button" /> 
      <br /> 
      <br /> 
      <p:commandButton value="Submit" action="user" /> 
     </h:form> 
    </h:body> 
</html> 

回答

1

首先,你不應該使用嵌套窗體。

至於你的問題,你需要你提交的第一個例如後更新第二種形式:

<p:commandButton value="Submit" action="user" update="form" /> 
相關問題