2014-10-09 29 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" /> 
相关问题