掲示板

Action method executed multiple times - Multiple submits to DB

12年前 に Hon Hwang によって更新されました。

Action method executed multiple times - Multiple submits to DB

New Member 投稿: 17 参加年月日: 11/07/04 最新の投稿
Hi all,

I've attached my code to this.

Basically, I am doing a cut down version of code in Liferay 6 Development Guide section on Service Builder. Cut down in the sense that I've removed groupId and companyId from my model for the time being.

The issue I am encountering is that whenever the OK button (submit) is clicked in edit.jsp to put the data into the DB, 3 rows are added to the DB. The first row is the actual data from the text fields; the other two are just empty.

I initially had one one view; I am working towards a portlet that shows all the current books and allows users to add new book in one single view. I thought that was the problem - i.e., having all of them in one view.jsp. So I break it down into 2 - view.jsp and edit.jsp (following the pattern of My Greeting Portlet).

The issue is still there. I am using com.liferay.portal.kernel.log.Log to see how many times my action method is called - this does not work either.

I am guessing what is happening here is that the action method is successfully executed. Then the portlet is being called twice - in action mode?

Either that or my liferay installation has some problems.

Thanks.
12年前 に Hon Hwang によって更新されました。

RE: Action method executed multiple times - Multiple submits to DB

New Member 投稿: 17 参加年月日: 11/07/04 最新の投稿
After changing the log from Liferay's build in one to Apache's Log4J, I notice the problem is actually related to browser refresh.

Specifically, my action method is being called whenever there is a browser refresh - even when view.jsp is showing.

Do I need to set some view mode settings somewhere?

I've found similar questions here and here, but they currently have no answers.

Any ideas? My browser is Safari 5.0.5 on Mac OS 10.6
12年前 に Saran veda によって更新されました。

RE: Action method executed multiple times - Multiple submits to DB

Junior Member 投稿: 45 参加年月日: 07/07/26 最新の投稿
Hi,

Just do a cross check, whether you have reference to Image which is actually present, since invalid reference always makes refresh the page internally.
Just have a look and also try to install firebug and check your request/response.

Thanks,
Saravanan
12年前 に Hon Hwang によって更新されました。

RE: Action method executed multiple times - Multiple submits to DB (回答)

New Member 投稿: 17 参加年月日: 11/07/04 最新の投稿
Fixed. Found out this is a well known double submit after POST on browser refresh.

I followed this blog in sending a redirect after my action method has been processed.

Other sources I found are Post/Redirect/Get from Wikipedia and article from theserverside.com