Added check for duplicate form submissions to dialog/wizard framework

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2736 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-05-02 11:27:17 +00:00
parent aa417e841f
commit 86134ca56f
2 changed files with 34 additions and 25 deletions

View File

@@ -23,6 +23,8 @@ import org.alfresco.web.ui.common.Utils;
*/ */
public abstract class BaseDialogBean implements IDialogBean public abstract class BaseDialogBean implements IDialogBean
{ {
protected boolean isFinished = false;
// services common to most dialogs // services common to most dialogs
protected BrowseBean browseBean; protected BrowseBean browseBean;
protected NavigationBean navigator; protected NavigationBean navigator;
@@ -34,6 +36,9 @@ public abstract class BaseDialogBean implements IDialogBean
{ {
// tell any beans to update themselves so the UI gets refreshed // tell any beans to update themselves so the UI gets refreshed
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans(); UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
// reset the isFinished flag
this.isFinished = false;
} }
public String cancel() public String cancel()
@@ -45,30 +50,36 @@ public abstract class BaseDialogBean implements IDialogBean
{ {
String outcome = getDefaultFinishOutcome(); String outcome = getDefaultFinishOutcome();
UserTransaction tx = null; // check the isFinished flag to stop the finish button
// being pressed multiple times
try if (this.isFinished == false)
{ {
FacesContext context = FacesContext.getCurrentInstance(); this.isFinished = true;
tx = Repository.getUserTransaction(context); UserTransaction tx = null;
tx.begin();
// call the actual implementation try
outcome = finishImpl(context, outcome); {
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context);
tx.begin();
// persist the changes // call the actual implementation
tx.commit(); outcome = finishImpl(context, outcome);
// allow any subclasses to perform post commit processing // persist the changes
// i.e. resetting state or setting status messages tx.commit();
outcome = doPostCommitProcessing(context, outcome);
} // allow any subclasses to perform post commit processing
catch (Throwable e) // i.e. resetting state or setting status messages
{ outcome = doPostCommitProcessing(context, outcome);
// rollback the transaction }
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} catch (Throwable e)
Utils.addErrorMessage(formatErrorMessage(e)); {
outcome = null; // rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(formatErrorMessage(e));
outcome = null;
}
} }
return outcome; return outcome;

View File

@@ -2,8 +2,6 @@ package org.alfresco.web.bean.wizard;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.dialog.BaseDialogBean;