主页面userList.jsp:
<a href="javascript:;" onClick="window.showModalDialog('showUserById.action?recordCheck=${id}',window,'dialogWidth:480px;dialogHeight:180px;status:no;')">修改</a>
window参数通过window.dialogArguments来取得传递进来的参数,在子页面中 对应self 关闭self.close();
struts.xml
<action name="showUserById" class="userAction" method="showUserById">
<result name="success">/userModify.jsp</result>
</action>
<action name="modifyUser" class="userAction" method="modifyUser">
<result name="success" type="redirect">showUserById.action</result> ------此处不知道到底怎么写。如有知道请告知。
</action>
子页面userModify.jsp:
<iframe name="commitArea" style='display:none;'></iframe>
<form name="modifyForm" method="post" target="commitArea">
<input type="hidden" name="user.id" value="${user.id }">
USERNAME:<input type="text" name="user.userName" id="username" value="${user.userName }"/><br/>
PASSWORD:<input type="password" name="user.password" id="password" value="${user.password }"/><br/>
FIRSTNAME:<input type="text" name="user.firstName" value="${user.firstName }"><br/>
LASTNAME:<input type="text" name="user.lastName" value="${user.lastName }"/><br/>
ADDRESS:<input type="text" name="user.address" value="${user.address }"/><br/>
</form>
<button id="modifyUser">修改</button>
$().ready(function(){
$("#modifyUser")
.button()
.click(function(){
modifyForm.action = "modifyUser.action";
modifyForm.submit();
window.dialogArguments.window.location="userList.action";
self.close();
});
});
提交时把当前子页面提交到iframe里,