Reputation: 123
I am using Struts 2 with tiles for my application.
In the application i am using an action class say 'A' with different action methods like add,*edit*,save,*savesuccess* and so on.
In a page, when i am clicking a check box ,i use window.open method to open a pop-up window by calling a action method "edit()" of the action class A which performs some database operation and return the result to the pop-window.
After performing some modification i submit the form to a action method named "save()" in action class A and it return the result page to the same pop-window.
The problem is when i close the pop-window, the action is executed once again and shows null values in console and exception.
I thought it may be due to browser so i try the event.returnValue=false on click event in the pop-window but still i am facing the problem.
I came to know about the token interceptor in struts2. But when i am using tag in the page , it shows 404 error.
I will be thankful to those who provide some examples related to using token Interceptor in struts2 with tiles..
Struts.xml
<action name="*Com" method="{1}" class="com.act.A">
<result name="add" type="tiles">add</result>
<result name="edit" type="tiles">edit</result>
<result name="save" type="tiles">save</result>
<result name="savesuccess" type="tiles">savesuccess</result>
Parent Page pop window open code:
editwindow=window.open("editCom?id="+id+"&name="+name+"..and son on","edit","width=605px,height=270px,channelmode=no,left=250px,location=no,menubar=no,status=no,titlebar=no,toolbar=no,top=250px,scrollbars=yes,resizable=no");
Popwindow Edit window form submission code
<form name="editpage" action="saveCom" method="post">
..........
After clicking the submit button it open a new page on the same popwindow like this
<html>
<script type="text/javascript">
function check1(){
window.opener.location="savesuccessCom";
}
</script>
<body onunload="check1">
<form name="editsave" method="post" action="" >
.....
<p>Changes Saved Successfully</p>
<input type="button" name="Saved" id="Save" value="Save" onclick="self.close();event.returnValue=false;"/>
</form>
</body>
</html>
Please help me to solve this issues.
Upvotes: 2
Views: 2057
Reputation: 2138
In that 2nd page the action you have given is action="".
I think the page get refreshed due to that action="".
I believe you are not passing any values from this page to next page, because you are closing the page with self.close() in button.
So remove that form tag and try it again. That will solve the problem :-)
Upvotes: 4