0

we are using webflow as we have multiple forms to fill before submitting . On final page when user submit all database transaction happens . So i want user to prevent from multiple submit . Is there a way where webflow itself graceful handles this . By gracefully i mean it should redirect or keep user on same page which should internal prevent any action for multiple submit. Please note we cannot use javascript .

2 Answers2

0

It would nice if there was some built-in mechanism to handle this pattern. In the meantime, we do this in our "action" class with a synchronized block, a mutex, and some flow scope object or attribute. For example:

Object mutex = WebUtils.getSessionMutex(
        ((HttpServletRequest) context.getExternalContext().getNativeRequest()).getSession());

synchronized (mutex) {

    if (!model.isComplete()) {
        // complete transaction
        model.setComplete(true);
    }
 }

 // return correct transition
Community
  • 1
  • 1
dbreaux
  • 4,982
  • 1
  • 25
  • 64
  • how do we get model in webflow ? The method i am calling from *-flow.xml is something like updateXXYY(RequestContext requestContext). – user2135940 Mar 07 '13 at 11:23
  • presently, I have prevented multiple submit by creating the token in session using tag library on the jsp where submit needs to be prevented . One first submit token is removed from session and transaction is done and for other subsequent submit are ignore as token is removed . – user2135940 Mar 07 '13 at 16:31
0

You can do it with javascript as:

    <html>
    <head>
    <script language="JavaScript" type="text/javascript">
        var count = 0;
        function submitFunction(eventId){   
            if(count == 0){
                count++;
                document.getElementById("yourForm")._eventId.value = eventId;   
                document.getElementById("yourForm").submit(); 
            }else{
                document.getElementById("requestMsg").style.display = 'block';
            }
        }
    </script>
    <head>
    </head>
    <body>
    <form:form id="yourForm" commandName="yourForm" method="post">
        <table>
            <tr>
                <td>
                    <div id="requestMsg">Request under process....</div>
                </td>
            </tr>
            ....
            <tr>
                <td>
                    <a href="javascript:submitFunction('submit');"><span>Submit</span></a>
                </td>
            </tr>   
        </table>
    </form:form>
    </body>

Prasad
  • 3,785
  • 2
  • 14
  • 23