How to prevent dupilcate form submission in JSF 1.x

Hi All
How to prevent dupilcate form submission in JSF 1.x application. As of now ,when the user clicked the submit button two times , application inserts 2 records in database.
Please suggest how to prevent dupliacte form submission without using Javascript. Kindlly share examples if any.
Regards,
DEV

Your problem is not really double submission but the fact that your application allows double insertion. The fix is functionally easy but technically very cumbersome: before inserting, check if the data already exists. If you build in such a guard you also protect against other methods of causing a resubmission, such as the browser back button.
PS: what's the deal with the no javascript limitation? You do realize that when you use JSF you're tanking your application full of javascript, right?

Similar Messages

  • Preventing duplicate form submission

    how do i prevent from the form being submitted twice in case user clicks the submit button twice?

    Search at the net "struts tokens".

  • Preventing duplicate form submission when page is loaded from history

    Hi
    We have record insertion forms some of which insert unique
    records into sql databases and some which may not. Is there a way
    of stopping the user pulling the page from history (or using the
    back button) and then resubmitting the data?
    I have put a trigger on the databases that basically updates
    existing data rather than re-inserting it if a duplicate is entered
    but as some of the record submissions are not unique this isn't
    always possible. I would also rather restrict the submission client
    side to reduce bandwidth and database calls.
    I have tried various 'no caching' techniques on the page but
    none seem to work. Anyone have any bright ideas ... I am all out of
    ideas bright or not!!!
    TIA
    Karen

    Karen
    I have used session variables to control this sort of thing.
    Basically the
    insert/update statement tests for the existance of a variable
    with a
    particular name. If no variable exists then this will
    indicate that the
    request is coming from a history file, and it will not allow
    the process.
    Equally as part of the insert process change the value in the
    variable and
    do not allow and insert if the variable holds that value.
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "big_old_bird" <[email protected]> wrote in
    message
    news:e2totv$ec9$[email protected]..
    > Hi
    >
    > We have record insertion forms some of which insert
    unique records into
    > sql
    > databases and some which may not. Is there a way of
    stopping the user
    > pulling
    > the page from history (or using the back button) and
    then resubmitting the
    > data?
    >
    > I have put a trigger on the databases that basically
    updates existing data
    > rather than re-inserting it if a duplicate is entered
    but as some of the
    > record
    > submissions are not unique this isn't always possible. I
    would also
    > rather
    > restrict the submission client side to reduce bandwidth
    and database
    > calls.
    >
    > I have tried various 'no caching' techniques on the page
    but none seem to
    > work. Anyone have any bright ideas ... I am all out of
    ideas bright or
    > not!!!
    >
    > TIA
    > Karen
    >

  • How to prevent Mail form marking the messages as read when marked?

    I use Mail 3.0 on Leopard (10.5.1).
    Each time I click on a message, it automatically marks the message as read.
    Is there any way to prevent this from happening? How can i set up a time-delay or switch it off?

    I think the only way would be for Apple to implement a delay for marking files as read. Perhaps putting a delay of a second or two would work, so folks can browse through their mail without actually reading it. As it is, though, there's no way to prevent mail from marking a message you browse over.

  • Prevent duplicate form submission from same user

    What's the best way to prevent the same person/computer from
    submitting a form? I am wondering about cookies, ip address,
    etc.

    Rking1966 wrote
    I am wondering about cookies...
    You got me wondering, too. I thought of something like:
    formPage.cfm
    ============
    <cfif isDefined("cookie.isFormSubmitted") and
    cookie.isFormSubmitted>
    You have already submitted the form. You may only do so
    once.<br>
    <p>
    <a href="someOtherBusinessPage.cfm">To
    business</a>
    </p>
    <cfelse>
    <form action="actionPage.cfm" method="post">
    <input name="field1" type="Text">
    <input name="send" type="Submit" value="Send">
    </form>
    </cfif>
    actionPage.cfm
    =============
    <cfif NOT isDefined("cookie.isFormSubmitted")>
    <cfcookie name="isFormSubmitted" expires="never"
    value="true">
    </cfif>
    <!---
    Business code to process submitted form fields
    --->

  • How to prevent iTunes form deleting songs when iPhone/iPod is NOT connected?

    One day, I was reading a pdf file on my Mac Computer and decided to open iTunes. All my songs was deleted!!!! I didn't even connect my iPhone to the computer!!!! I the forced quit iTunes and reopened it again. Some of my music came back. I then shut down my computer and opened iTunes the nesxt day. All of my songs (I think) came back, except my Movie file is completely empty!!!!!!! All my movies stored in iTunes was deleted!!!!!!!
    How do I stop iTunes from spontaneously deleting stuff from my computer?!!!! My computer btw is the MacBook Core 2 Duo. Could it be this computer is getting old?

    Don't sync any iTunes content with iTunes on your work computer - don't have anything selected under these tabs for your iPhone sync preferences with iTunes on your work computer - Music, Movies, TV Shows, Podcasts, Apps.

  • How do you prevent form submission if Spry validation fails?

    After reviewing and implementing the SpryValidationConfirm and SpryValidationPassword widgets on a test page, I am unable to prevent the form from being submitted if the validation of either widget fails.
    A feature of both widgets is "Blocking form submission if the password criteria is not met".
    I ihave included my code below:
    <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css">
    <cfform method="post" action="result.cfm">
      <span id="sprypassword1">
        <label>Password
          <cfinput type="password" name="mypassword1" id="mypassword1" size="30" />
        </label>
        <span class="passwordRequiredMsg">The password cannot be empty</span>
        <span class="passwordMinCharsMsg">The password must contain at least 15 characters</span>
        <span class="passwordInvalidStrengthMsg">The password must contain 2 special characters, 2 uppercase characters, 2 lowercase characters, and 2 numbers</span>
      </span>
      <span id="spryconfirm1">
        <label>Confirm Password
          <cfinput type="password" name="mypassword2" id="mypassword2" size="30" >
        </label>
        <span class="confirmRequiredMsg">A value is required</span>
        <span class="confirmInvalidMsg">The values don't match</span>
      </span>
      <cfinput type="submit" name="submit" value="Go to the next page">
    </cfform>
    <script type="text/javascript">
    <!--
    var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1", {minChars:15, minUpperAlphaChars:2, minSpecialChars:2, minNumbers:2, minAlphaChars:2}, {validateOn:["blur", "change"]});
    var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "mypassword1", {validateOn:["blur", "change"]});
    //-->
    </script>

    Thanks so much!
    I removed the <cf prefixes from the cfform and cfinput tags and form now does not submit on invalid data.
    I did not rename the 'password' fields as I think there needs to be 2 inputs that can be compared for the confirmation widget to function.
    I have attatched the working code below:
    <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css">
    <form method="post" action="result.cfm">
      <span id="sprypassword1">
        <label>Password
          <input type="password" name="mypassword1" id="mypassword1" size="30" />
        </label>
        <span class="passwordRequiredMsg">The password cannot be empty</span>
        <span class="passwordMinCharsMsg">The password must contain at least 15 characters</span>
        <span class="passwordInvalidStrengthMsg">The password must contain 2 special characters, 2 uppercase characters, 2 lowercase characters, and 2 numbers</span>
      </span>
      <span id="spryconfirm1">
        <label>Confirm Password
          <input type="password" name="mypassword2" id="mypassword2" size="30" >
        </label>
        <span class="confirmRequiredMsg">A value is required</span>
        <span class="confirmInvalidMsg">The values don't match</span>
      </span>
      <input type="submit" name="submit" value="Go to the next page">
    </form>
    <script type="text/javascript">
    <!--
    var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1", {minChars:15, minUpperAlphaChars:2, minSpecialChars:2, minNumbers:2, minAlphaChars:2}, {validateOn:["blur", "change"]});
    var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "mypassword1", {validateOn:["blur", "change"]});
    //-->
    </script>
    Again thanks so much!

  • Preventing sensitive form re-submission

    I want to prevent the refresh/re-submission of form on the server side(not using javascript).There is some way of using tokens in session and request to validate the request from the client.But I am not very sure how to go about it.Can anyone elaborate the same for me..Thanks in advance....

    You're on the right track. To use tokens, there should be a number stored in the session, and that same number placed in a hidden field in the form.
    Before serving the form, create a unique key - new Date().getTime() gives you a long with millisecond precision. Store that number in the session and also place it in a hidden field in the form. When the form is submitted, check the hidden against the number in the session. If they match, the form submission is valid; remove the key and process the form. If the user tries to submit the same form by using the "back" button, the number in the form no longer has a match in the session, and you reject the form submission.
    example:
    in the jsp that generates the form:
    <%
       // create a number unique to the current millisecond
        long key = new java.util.Date().getTime();
        // place it in the session to be looked up later
        session.setAttribute( "formKey", Long.toString( key )  );
    %>
    <form>
        <!-- put the form key in the form -->
        <input type="hidden" name="formKey" value="<%= key %>">
    </form>in the code that processes the form:
    String key = request.getParameter( "formKey" )
    String sessionKey = (String)session.getAttribute( "formKey" );
    if ( key.equals( sessionKey ) ){
        // process the form
    } else {
        // key is not valid - send some error message
    }

  • How do I attach a JavaBean to a HTML Form submission

    I found an example in the O'Reilly JavaServer Pages book that shows you how to pass a JavaBean from a JSP to a servlet.
    <jsp:useBean id="userInfo" scope="request" class="com.ora.jsp.beans.userinfo.UserInfoBean">
    <jsp:setProperty name="userInfo" property="*" />
    </jsp:useBean>
    <jsp:forward page="/myServlet" />
    Then in the servlet, you do:
    UserInfoBean userInfo = ( UserInfoBean )request.getAttribute("userInfo");
    I want to do almost the exact same thing...but I don't want to forward the request. I want to pass the JavaBean along as part of an HTML form submission. Can anyone help me out with this? Thanks.

    Assuming that you have setup your environment correctly and you have a web application server like Tomcat running.
    Since you didn't provide the code for the bean I created my own. You can change the code any way you want.
    Say UserInfoBean is :
    package test17;
    public class UserInfoBean {
        String firstName;
        String lastName;
        public UserInfoBean() {
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
    }And say you have a JSP page like this:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head><title></title></head>
      <body>
      <jsp:useBean id="userInfo" scope="request" class="test17.UserInfoBean">
      <jsp:setProperty name="userInfo" property="*" />
      </jsp:useBean>
      <form action="index.jsp" method="POST">
          <input type="text" name="firstName" value="${userInfo.firstName}"/>
          <br/><br/>
          <input type="text" name="firstName" value="${userInfo.lastName}"/>
          <br/><br/>
          <input type="submit" name="submit" value="submit"/>
      </form>
      </body>
    </html>If you access the JSP page like this:
    http://localhost:8080/p/test17/index.jsp?firstName=George&lastName=W
    then it passes in the request parameter from the query string and populates the form.
    Once the form is populated if you submit the form , data is transmitted to the next page , and you can access it via request.getParameter.
    Is this the solution you are looking for?

  • Preventing the Duplicate Form Submission??

    Hi,
    How to prevent the duplicate form from been submitted without disabling the back button in IE???
    Thanks,
    JavaCrazyLover

    I had the same wonder. I found the following articles are quite helpful. They give detailed background info, a design pattern to deal with it, and a Struts implementation.
    http://www.theserverside.com/articles/content/RedirectAfterPost/article.html
    http://www.theserverside.com/articles/content/RedirectAfterPost2/article.html
    Cheers,
    littlemonster

  • How to create search form in jsf telnet with auto submit?

    I am trying to create a simple search form on a jsf telnet page
    with jdeveloper 10.1.3 and and j2se version 1.4.2.
    The problem I am having is the example search form I have seen
    uses an execute command button, which I can't use on the telnet page.
    I would like to query the results upon entering the criteria, without the
    user pressing a button. This is because the page will used with a barcode
    scanner. I am attempting to use a valueChange listener on the input field, but
    I am unsure if this is the right approach. Any feedback is appreciated.
    Thanks

    In my application whenever I change a value or want to follow a commandLink, my page just refreshes and I end up with the old values. I have not been able to navigate in my application. I am using the arrows or tab to navigate in my page and press enter to submit.
    I have set the STATE_SAVING_METHOD to server, but this is not helping.
    I have a deadline that is closing in on me, can anyone hint me in the right direction?

  • Mandatory check box before form submission

    I want users to accept my 'Terms & Conditions' statement on an application form before they are allowed to submit it by the e-mail button.
    I want to place a required check box which produces an error message and prevents form submission until it is checked.
    I have read hordes of the postings but none of the solutions seem to do quite what I want.
    Any advice would be gratefully received

    Hi,
    I used the script you provided in the above post, and it worked perfectly, but my situation is a little different: I have two checkboxes, but I only want the message to appear if one of them isn't selected. If the other checkbox is selected, I need the fake submit button to go ahead and generate the email to send the form. I'm new to LiveCycle Designer, and I'm unsure of how to correctly use the "if" and "else" javascript. I need the message to appear when clicking the WebExYes checkbox, but I don't want it to appear when the user clicks the IntercallCheckBox.
    Here's what my script looks like so far:
    if 
    (form1.subForm1.WebEx.WebExYes.rawValue != "1"){ xfa.host.messageBox("You must read the FHEG WebEx Usage Standards and select the Yes checkbox before submitting.");
    else 
    { SubmitButton.execEvent("click");
    if 
    (form1.subForm1.AccountRequest.IntercallCheckBox.rawValue != "1")
    else 
    {SubmitButton.execEvent ("click");
    Can someone tell me what I'm doing wrong or if I can even make this happen?
    Thank you,
    Hannah

  • Is it possible to add files to a PDF form submission?

    Hi there,
    Someone asked me to add an attachment field to a PDF dynamic form. Based on previous research we figured out that will not be possible: our users don't have Acrobat - just Reader - and we won't purchase Reader Extensions. How about using a form field to help the user send the attachments that a are required with that give form? For instance:
    - User would fill in the form and when asked for attachments he/she would browse for the file.
    - The form would save the file name as text on the form (like the answer for a text field)
    - The PDF form would memorize the location of the file(s)
    - When the user hits "Submit" the PDF form would gather the files listed for attachment and add them as attachments - in additon to itself - to the email created by the submission button.
    That way the attachments are not saved as part of the PDF form, but the PDF form is automating the process of adding them to the submission email.
    Is that doable with LiveCycle Designer? Any tips on how to go about coding/building those actions?
    Thanks in advance,
    AV

    If your user is using Adobe Reader and wants to add an attachment to your PDF file... you need Adobe LiveCycle Designer Reader Extensions to do that...
    If your user is using Adobe Acrobat Pro then u can add attachments with this
    var myDoc = event.target;
    var sFile = "myFile" + NumericField1.rawValue;
    myDoc.importDataObject({cName: sFile});
    var myDataObject = myDoc.getDataObject(sFile); 
    var sFileName = myDataObject.path; 
    ListBox1.addItem(sFileName,sFile); 
    NumericField1.rawValue = NumericField1.rawValue + 1;
    you can also remove the file
    myDoc.removeDataObject(sFile);
    you can also open the file
    myDoc.exportDataObject({ cName: sFile, nLaunch: 2 });

  • How To Reset a Form (Not as easy as you would think)?

    Hi All,
    I'm unable to get a form to reset its value when using a commandButton that has immediate set to true.
    I've got a simple little jsf page that has a form and a datatable. The form is bound to an object in a class I'm using to handle the view, the datatable is bound to a dataModel from the same handler class. The functionality I have is quite simple:
    a user clicks on a commandLink in a row of the datatable
    the corresponding object is loaded into a "currentObject" property of the handler class
    the form fields are mapped to the "currentObject" property of the handler.
    The user may update or reset the form.
    The goal is to have the reset commandButton set the "currentObject" property of the handler class to null (or a new, unpopulated object) so that the fields of the form are set to blank again on render. This works fine as long as I don't use immediate="true". When I do use the immediate=true attribute, the "currentObject" variable is, indeed, set to null, but the form still renders with the old "currentObject" values in it!!
    I have to use immediate="true" because there is validation going on for the form that I want to avoid.
    If I use a commandButton type="reset", the fields are not cleared because the reset functionality of the browser (ie6 and firefox) resets the fields to the values they were at the time the form was displayed--the very values I wish to totally remove!
    This seems like such a common, simple thing to do. What am I missing?
    Thanks,
    John

    I have a similiar problem, and maybe putting buttons in a different form is the answer:
    I have a page with a selectOneListbox on the left, and a set of inputs on the right. The listbox represents the available beans to select, and the set of inputs contains all the editable fields for the beans. Basically this is just a bean editor.
    There is a command Button beneath the listbox for viewing a bean. When this button is clicked, the set of inputs are populated with that bean's data.
    There is also a command button beneath the set of inputs that allows the user to save their changes.
    All of these elements are in the same form tag.
    JSF jsp:
    <f:view>
      <h:form>
        <h:panelGrid columns="2">
          <h:panelGrid columns="2">
            <h:selectOneListbox size="10" value="#{editor.selectedBean}" >
              <f: selectItems value="#{editor.beanSelectItemCollection}" />
            </h:selectOneListbox>
            <h:commandButton actionListener="#{editor.view}" value="View" />
          </h:panelGrid>
          <h:panelGrid  columns="2">
            <h:inputText value="#{editor.editingBean.property}" />
            <h:commandButton actionListener="#{editor.save}" value="Save" />
          </h:panelGrid>
        </h:panelGrid>
      </h:form>
    </f:view>Editor bean:
    public class Editor {
      // use a blank bean as default
      // so the editor is populated with blanks
      private Bean editingBean = new Bean();
      // don't initially select any beans
      private Bean selectedBean = null;
      private Map beans = new HashMap();
      public Editor() {
      public void save(ActionEvent e) {
        beans.put(editingBean.getId(), editingBean);
      public void view (ActionEvent e) {
        editingBean = (Bean)selectedBean.clone();
      // getters and setters
      public Bean getEditingBean() {
        return editingBean;
      public void setEditingBean(Bean b) {
        editingBean = b;
      public Bean getSelectedBean() {
        return selectedBean;
      public void setSelectedBean(Bean b) {
        selectedBean = b;
      // before entering the JSP for this bean, this method should be called
      // to populate the editor
      public void setBeans(Collection c) {
        beans.clear();
        for (Iterator i = c.iterator(); i.hasNext(); ) {
          Bean b = (Bean)i.next();
          beans.put(b.getId(), b);
      public Collection getBeans() {
        return beans.values();
      public Collection getBeanSelectItemCollection() {
        Collection items = new ArrayList(beans.size());
        for (Iterator i = beans.values().iterator(); i.hasNext(); ) {
          items.add(new SelectItem(bean, bean.getProperty());
        return items;
    }Here comes the problem:
    If I want to set fields as required or use any of the JSF validation functionality, my view usecase breaks. This happens if the user views bean1 changes some data to be invalid/not existant and then tries to view bean2. If they don't click the save button, validation/required should not be checked. My initial thought is that I should be able to set my view button and view listbox to be immediate. This does properly update the view listbox, but then if I change the values in the backing bean for the set of inputs, those changes are never updated to the screen, and the set of inputs is still populated with bean1's data even though the backing bean for all those inputs is now bean2.
    It appears that the view never requeries the backing bean when responseComplete() is called (which happens with an immediate command). Is this a bug in faces, or is this how the spec says it is supposed to behave? If this is the correct behavior what is a better practice to acheieve my usecase?
    My current workaround is to ignore faces validation and manually validate when the user clicks the save command, and then manually set the messages for the bad components. Obviously, this is not an ideal solution, but I was hoping that this faces behavior was incorrect and thus my solution would be temporary.
    I'm not tied to a specific solution, but I am discouraged that Adam says in order to reset the set of inputs, we have to manually update the model during the apply request values phase.

  • How can i submit form-data with acrobat pocket pc

    how can i submit form-data (http-post) on a PPC?
    how can i store the data offline?
    which submit-functions are availabe for the pocket pc reader?
    do i need ARES?
    where can i find a documentation of of the available functions for the ppc version?
    where can i fond form-samples for ppc?
    from the docu on my pocket pc:
    Submit form data using handheld devices over a wireless connection. If you are working offline, the data is temporarily stored, then submitted once a connection is established. Send forms by e-mail or directly to the destination server using a cradle or cable

    To your question regarding the Pocket PC version of Reader, I downloaded Adobe Reader for Pocket Pc 2 and installed it on my HP iPAQ . I then loaded my test PDF file onto the iPAQ. The Reader for Pocket PC preformed an email submission fine. However, I received no indication that anything happened when I tried an HTTP Post. So I think you can only do an email submission.
    In general, I have been testing to see how much I can do without the Live Cycle Reader Extensions, since for sure I will never be able to purchase them. What I have found is that for Acrobat Reader 7, the email submission works for all of the people I have asked to test it, but the HTTP Post has worked for only one of the two people who have tested it so far with Reader 7 (the one for which it worked claims that he only has Reader 7 on his computernot Acrobat).

Maybe you are looking for

  • MERGE statement - Source with duplicate values not raising error ora-30926

    Hi , I'm having a problem with merge that has already been reported in another thread ( Re: MERGE strange behavior ). I created a procedure with a query and have tested inserting two equal values on the Key column to raise the error. But on the first

  • Firefox 6.0.2 crashes and Windows XP restarts the whole system

    When I visit the 'YouTube' website, after a while Firefox crashes (Then I see for a very short moment a blue screen with text, but it dissapeared very quickly, so I couldn't read the text) and my complete windows XP system restarts. Then when I open

  • Possible To Change The Colour Of A Theme Template For A Book - Aperture

    Hi I am using Aperture 3 and would like to make a photo book for a recent trip, combined with including the text of a blog I wrote during the journey. I like the journal theme that now exists in Aperture theme layouts, but I'd like to change the "bar

  • Stolen pc - how do I stop it synching & updating info from phone/iPad

    I have had my lap top stolen, how can I remotely deauthorise, or stop the laptop automatically synchronising. I have iPhone and iPad to do this now? Is simply changing my password enough or is there something else I can do? I am concerned my personal

  • ASO and archive

    Does the begin archive command work for ASO? I tried the Esscmd version on an ASO and it worked fine. Is the DBAG correct in saying? "The ESSCMD command BEGINARCHIVE and the MaxL statement alter database begin archive do not support aggregate storage