I was working on a small project, where i have a jsp which has a form with action on it. When I click on that button, it calls the action mapping method successfully. In that method I am calling a db which does select insert on DB on some 30k records. The problem is after running the db code for some 10-20 seconds, the action mapping method is called again. I dont know the reason for it.
What I want to achieve is, Actionmapping method should call only once because it is violating integrity constraint if it calls twice. I dont know the reason why liferay behaves differently.
I would also like to know if it is possible to separate the db code from actionmapping method so that method is called when button is clicked and then it should return back to jsp by giving a message as "In Progress". Can anyone provide me some ideas regarding this. Thanks!!!!
I am using liferay 7 GA2 with spring mvc framework
jsp file code:
<portlet:actionURL var="InvokeFileURL">
<portlet:param name="action" value="callaction"/>
</portlet:actionURL>
<aui:form action="<%= InvokeFileURL %>" method="post">
<div><b>Files Selected For Invoke</b></div>
<div style="width:1180px;height:670px;border:1px solid #000; margin-left:30px;max-height: 700px; overflow:auto;" id="invokefiles" >
</div>
<br/>
<p style= "text-align:right;margin-right:10px" ><aui:button name="Invoke" value="Invoke" type="submit" /></p>
</aui:form>
Controller code
@ActionMapping(params = "action=callaction" )
public void invokerequest(ActionRequest request, ActionResponse response)
throws Exception {
_log.info("Invoke called"); //Called Twice
DBParserJDBC.DBParser(); //called twice
//Function to call DB ( its a long process)
response.setRenderParameter("action", "success");
}
@RenderMapping(params = "action=success")
public String viewSuccess() {
_log.info("#############Calling viewSuccess###########");
return "view";
}