Jsf 如何将文本字段值从覆盖面板传递到父窗体
单击覆盖面板上的“提交”按钮时,我无法从覆盖面板中的文本框到主窗体中的文本框中获取值Jsf 如何将文本字段值从覆盖面板传递到父窗体,jsf,primefaces,facelets,Jsf,Primefaces,Facelets,单击覆盖面板上的“提交”按钮时,我无法从覆盖面板中的文本框到主窗体中的文本框中获取值 <?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
<?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>
.链接{
颜色:蓝色;
字体大小:15px;
}
.表格{宽度:300px;
保证金:0自动;
}
.按钮{
}
历法
函数checkPasswords(){
警报(“hii”);
警报(document.getElementById(“form:pass”).value);
警报(“测试”);
window.opener.document.getElementById(“form:pass”).value=document.getElementById(“overPanel1:newpass”).value;
//document.getElementById(“overPanel1”).hide();
返回false;
}
用户名:
密码:
新密码:
出生日期:
首先,您不应该使用嵌套表单
对于您的问题,您需要在提交第一份表格后更新第二份表格,例如:
<p:commandButton value="Submit" action="user" update="form" />