Submit twice ?

Hello all.
I'm writing a jsf app that takes an input form, validates it, and then
forwards the user to a confirmation page.
Pretty straightforward, very similar to jsf tutorials.
However, once I added selectOneMenu items, I now find
myself having to submit the form twice before getting the
confirmation page.
The selectOneMenu items do have valueChangeListener
routines in the backing bean, because if I did not include
those, it would not return the value selected in the drop-down
boxes.
The form is submitted by a commandButton, which calls a
validate() routine in the backing bean, which returns null if
not validated or 'success' if validated, which should then
forward the browser to the confirm page.
I put System.out.println() messages in the valueChangeListener
as well as the validate() routine, and the first submit shows the
messages in valueChangeListener, the second shows the validate()
routine messages.
Maybe I'm missing something in the lifecycle order that may
cause this, but I have not been able to make it work right.
Has anyone come across this behavior in jsf ?
If anyone is interested, I can email a jar with the source,
xml (faces-config.xml, web.xml), and jsp files.
There seems no way to attach it in the forums.
I can, however, post snippets of how I code the drop-downs:
jsp file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
   <td align="left">  
      <h:selectOneMenu value="#{data.state}"
              valueChangeListener="#{data.stateSelected}">
         <f:selectItems value="#{data.statelist}"/>
      </h:selectOneMenu>
   </td>
java source:
(drop-downs populate fine......)
   public Collection getStatelist(){
      //System.out.println(getLogtime() + "DataBean: getStates()");
      if (sdata==null)
         try{
            populateStates();
         } catch(SQLException sqlEx) {
            logger.log(Level.SEVERE, "loginAction", sqlEx);
         } catch(NamingException nameEx) {
            logger.log(Level.SEVERE, "loginAction", nameEx);
         } catch(Exception Ex) {
            System.out.println(getLogtime() + "DataBean: getStates() Exception!");
            //System.out.println("  nbr of state records: [" + sdata.size() + "]");
            System.out.println("   msg: [" + Ex.getMessage() + "]");
            //return sdata;
      //System.out.println(getLogtime() + "DataBean: nbr of State records: [" + sdata.size() + "]");
      return sdata;
   public void populateStates()
      throws SQLException, NamingException
      //System.out.println("DataBean: populateStates()...");
      //ctx = new InitialContext();
      ctx = new InitialContext(System.getProperties());
      if(ctx==null){
           throw new NamingException("DataBean: No initial context");
      ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/testdataDS");
      if(ds==null){
         System.out.println("DataBean: no data source!!");
         throw new NamingException("No data source");
      //System.out.println("DataBean: getConnection...");
      try {
         conn = ds.getConnection();
         if(conn==null) {
            System.out.println("DataBean: no connection!!");
            throw new SQLException("DataBean: No database connection");
         } else {
            PreparedStatement dataQuery = conn.prepareStatement(
               "SELECT state_code, state_name FROM state ORDER BY state_code");
            ResultSet result = dataQuery.executeQuery();
            sdata = new ArrayList();
            sdata.add(new SelectItem(" ","Please select one"));
            if(!result.next()){
               return;
            } else {
               sdata.add(new SelectItem(result.getString("state_code")
                                       ,result.getString("state_name")));
               while(result.next()){
                  sdata.add(new SelectItem(result.getString("state_code")
                                          ,result.getString("state_name")));
      } catch(SQLException se){
         System.out.println("DataBean: populateStates() - connection/statement/execute : ");
         System.out.println("   message: [" + se.getMessage() + "]");
         //se.printStackTrace();
         // look at the warnings issued it should help you resolve the problem
         SQLWarning warning = null;
         try {
            // Get SQL warnings issued
           //warning = conget.getWarnings();
           warning = (SQLWarning)se.getNextException();
           if (warning == null) {
              System.out.println("DataBean: populateStates()could not get sql warnings");
           } else {
              //while (warning != null) {
                 System.out.println("DataBean populateStates() - Warning: " + warning);
                 //warning = warning.getNextWarning();
              //   warning = (SQLWarning)se.getNextException();
         } catch (Exception we) {
            System.out.println("DataBean populateStates() - SQLException !!");
            System.out.println("   msg: [" + we.getMessage() + "]");
         sdata = new ArrayList();
      } catch (Exception e) {
         System.out.println("DataBean: populateStates() lookup exception:");
         System.out.println("  msg: [" + e.getMessage() + "]");
         e.printStackTrace();
         sdata = new ArrayList();
      } finally {
         conn.close();
faces-config.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC
   "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
   "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
   <application>
     <locale-config>
          <default-locale>en</default-locale>
          <supported-locale>en</supported-locale>
          <supported-locale>en_US</supported-locale>
          <!-- supported-locale>de</supported-locale -->
     </locale-config>
     <!-- message-bundle>
          de.laliluna.tutorial.messageresource.MessageResources
     </message-bundle -->
   </application>
   <!-- managed beans of the simple hello world app -->
   <managed-bean>
      <managed-bean-name>data</managed-bean-name>
      <managed-bean-class>edu.msu.hit.data.DataBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
   </managed-bean>
   <!-- Navigation rules -->
   <navigation-rule>
      <description>Test select one page</description>
      <from-view-id>/testSelectOnePage.jsp</from-view-id>
      <!-- navigation-case>
         <from-outcome>ticketsfailure</from-outcome>
         <to-view-id>/ticketsonline.jsp</to-view-id>
      </navigation-case -->
      <navigation-case>
         <from-outcome>success</from-outcome>
         <to-view-id>/testSelectOneConfirm.jsp</to-view-id>
      </navigation-case>
   </navigation-rule>
</faces-config>
web.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
   <display-name>MyFaces Demo</display-name>
   <description>a Myfaces demo page</description>
    <!-- Listener, that does all the startup work (configuration, init). -->
    <!-- listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener -->
    <!-- Faces Servlet -->
    <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- Faces Servlet Mapping -->
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <resource-ref>
      <description>Sybase Datasource resource</description>
      <res-ref-name>jdbc/testdataDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>
    <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>false</param-value>
       <description>
          Set this flag to true if you want the JavaServer Faces
          Reference Implementation to validate the XML in your
          faces-config.xml resources against the DTD. Default
          value is false.
       </description>
    </context-param>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>
    <!-- context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>
            /WEB-INF/faces-config.xml
        </param-value>
        <description>
            Comma separated list of URIs of (additional) faces config files.
            (e.g. /WEB-INF/my-config.xml)
            See JSF 1.0 PRD2, 10.3.2
        </description>
    </context-param -->
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
        <description>
            State saving method: "client" or "server" (= default)
            See JSF Specification 2.5.2
        </description>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
        <description>
            This parameter tells MyFaces if javascript code should be allowed in the
            rendered HTML output.
            If javascript is allowed, command_link anchors will have javascript code
            that submits the corresponding form.
            If javascript is not allowed, the state saving info and nested parameters
            will be added as url parameters.
            Default: "true"
        </description>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
        <description>
            If true, rendered HTML code will be formatted, so that it is "human readable".
            i.e. additional line separators and whitespace will be written, that do not
            influence the HTML code.
            Default: "true"
        </description>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
        <param-value>true</param-value>
        <description>
            If true, a javascript function will be rendered that is able to restore the
            former vertical scroll on every request. Convenient feature if you have pages
            with long lists and you do not want the browser page to always jump to the top
            if you trigger a link or button action that stays on the same page.
            Default: "false"
        </description>
    </context-param>
    <!-- the following context-params are for jsf 1.1 -->
    <!-- tjc 2007-02-07 -->
    <context-param>
        <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
        <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.redirectTracker.POLICY</param-name>
        <param-value>org.apache.myfaces.redirectTracker.NoopRedirectTrackPolicy</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.redirectTracker.MAX_REDIRECTS</param-name>
        <param-value>20</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>
</web-app>I'm running jsf 1.1, tomcat v5.5.20, apache 2.059, JK 1.2.18
Thanks to anyone for insight.

Hello. Me again.
I did not post the JSP file that was using the above code, so I
decided to post it, and mention that if I use:
onchange="submit();"within the <h:selectOneMenu> tag, the form does not need to be
submitted twice, but takes the values and validates them.
On the other hand, if your form is long enough, and you have to scroll
down to change the drop-down box, the form is submitted, and
so it takes you to the top of the page again.
I guess that I could design the page so that the entire form fits
within the browser without scrolling, but that would depend on
how big the user makes their browser window.
Anyway, here is the JSP:
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
<%
* MOCF ball tickets order form.
%>     
<jsp:include page="./headerform.jsp">
   <jsp:param name="pagetitle" value="MOCF Ball Tickets Purchase Page" />     
   <jsp:param name="page" value="tickets" />     
</jsp:include>
<center>
<h:form>
<table border="2" cellspacing=1 cellpadding=2>
<tr>
   <td align=center>
   <h:outputText value="#{mocfBall.mocfyear}"/>
    <h:outputText value="#{mocfBall.mocftitle}"/><br>
     <b><i>
     <h:outputText value="#{mocfBall.mocfslogan}"/>
     </i></b><br>
     <h:outputText value="#{mocfBall.mocflocation}"/><br>
     <h:outputText value="#{mocfBall.mocfcity}"/><br>
     <h:outputText value="#{mocfBall.mocfdate}"/><br>
   </td>
</tr>
</table>
<table border="0" cellspacing=1 cellpadding=2 width="90%">
<tr>
   <td align=center>
      MOCF Ball Tickets PURCHASE FORM
   </td>
</tr>
<tr>
   <td align=center>
      Date/Time: 
        <h:outputText value="#{mocfBall.currentdatetime}"/>
   </td>
</tr>
<!-- tr>
   <td align=center>
        <a href="./ticketsprint.jsp">
           LINK to PRINTABLE FORM<br>
           (You can click here, then print the page,<br>
           and send it in the mail with your check.)
        </a>
     </td>
</tr -->
<tr>
   <td align=center>
      <font size="2" face="arial">
             You may print this form and fill in the fields by hand,
             <br>or<br>
             fill in the fields now by typing, then print the form with the
             PRINT button in the browser menu above, or the "Print Page"
             button below.
             <br><br>
             For questions, please contact:<br>
             <h:outputText value="#{mocfBall.mocfcontactname}"/>
              at 
             <h:outputText value="#{mocfBall.mocfcontactphone}"/>
              or by email at 
             <h:outputText value="#{mocfBall.mocfcontactemail}"/>
             <br><br>
             To use the postal service instead of online submission,
             please mail this form, with your check, to:<br>
             <h:outputText value="#{mocfBall.mocfsnailtitle}"/><br>
             <h:outputText value="#{mocfBall.mocfsnailaddr1}"/><br>
             <h:outputText value="#{mocfBall.mocfsnailaddr2}"/><br>
             <h:outputText value="#{mocfBall.mocfsnailaddr3}"/><br>
          </font>
       </td>
</tr>
<tr>
   <td align=right>
      <a href=<h:outputText value="#{mocfBall.mocfhome}"/>>MOCF Ball Home</a>
   </td>
</tr>
</table>
<table width="90%" border="1" cellpadding="2" cellspacing="0">
  <tr>
    <td width="100%" valign="top" colspan="2" align="center">
        (* = field required)
    </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Salutation:
     </td>
     <td align="left" valign="top">
        <h:selectOneMenu id="formSalutations"
                 valueChangeListener="#{ticketsformBean.mocfsalutationSelected}"
                 value="${ticketsformBean.mocfsalutation}">
            <f:selectItems value="#{ticketsformBean.allsalutations}"/>
        </h:selectOneMenu>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.salutationerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *First name:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocffirstname}" size="40"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.firstnameerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Last name:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocflastname}" size="40"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.lastnameerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Address1:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfaddress1}" size="40"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.address1error}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Address2:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfaddress2}" size="40"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.address2error}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *City:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfcity}" size="30"/>
        <font size="-2px" color="red">
        <br>
        <h:outputText value="#{ticketsformBean.cityerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *State:
     </td>
     <td align="left" valign="top">
        <h:selectOneMenu id="states"
                 valueChangeListener="#{ticketsformBean.mocfstateSelected}"
                 value="${ticketsformBean.mocfstate}">
            <f:selectItems value="#{ticketsformBean.allstates}"/>
        </h:selectOneMenu>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.stateerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Zip:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfzip}" size="10"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.ziperror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Phone:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfphone}" size="10"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.phoneerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        Fax:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocffax}" size="10"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.faxerror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Email:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfemail}" size="60"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.emailerror}"/>
        </font>
     </td>
  </tr>
</table>
<table width="90%" border="1" cellpadding="2" cellspacing="0">
  <tr>
     <td align="right" valign="top">
        *Number of tickets to reserve:
     </td>
     <td align="left" valign="top">
        <h:selectOneMenu id="ticketcount"
                valueChangeListener="#{ticketsformBean.mocfnbrofticketsSelected}"
                 value="${ticketsformBean.mocfnbroftickets}">
            <f:selectItems value="#{ticketsformBean.allticketcounts}"/>
        </h:selectOneMenu>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.nbrticketserror}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Name1:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfname1}" size="30"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.name1error}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Name2:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfname2}" size="30"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.name2error}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Name3:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfname3}" size="30"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.name3error}"/>
        </font>
     </td>
  </tr>
  <tr>
     <td align="right" valign="top">
        *Name4:
     </td>
     <td align="left" valign="top">
        <h:inputText value="#{ticketsformBean.mocfname4}" size="30"/>
        <font class="formerror">
        <br>
        <h:outputText value="#{ticketsformBean.name4error}"/>
        </font>
     </td>
  </tr>
  <tr>
    <td align="center" valign="top" colspan="2">
      <h:commandButton value="Submit tickets order"
         action="#{ticketsformBean.validate}"/>
    </td>
  </tr>
</table>
</h:form>
<br>
<table border="0" cellspacing=1 cellpadding=2>
<tr>
   <td align=center>
      <input type="hidden" name="form" value="print">
        <INPUT TYPE="button" name="printMe" onClick="print()" value="Print Page">
   </td>
</tr>
</table>
</center>
<h:messages />
<jsp:include page="./footerform.jsp" />
</f:view>

Similar Messages

  • Disable submit twice with valid spry validation

    Is there a line of javascript that can be added to the textfield .js file (or elsewhere) to disable the submit button if clicked, only if all spry fields are valid so users/clients don't submit twice?  But stay active if spry fields are invalid so users can make corrections and submit again? 

    In my simplistic way of thinking, if the SpryValidationTextField.js script already tells the form to stop submission and give error messages if textfields are invalid
    Correct, but without the click on the submit button, there is no trigger, hence no error messages.
    I guess we could simulate a form submit. Maybe you would like to play around with
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet">
    </head>
    <body>
    <form id="myForm" action="" method="post">
      <div id="sprytextfield1">
        <label for="text1"></label>
        <input type="text" name="text1" id="text1" onkeyup="validateEnableSubmit();">
        <span class="textfieldRequiredMsg">A value is required.</span> </div>
      <div id="sprytextfield2">
        <label for="text2"></label>
        <input type="text" name="text2" id="text2" onkeyup="validateEnableSubmit();">
        <span class="textfieldRequiredMsg">A value is required.</span> </div>
      <div id="sprytextfield3">
        <label for="text3"></label>
        <input type="text" name="text3" id="text3" onkeyup="validateEnableSubmit();">
        <span class="textfieldRequiredMsg">A value is required.</span> </div>
      <div>
        <input id="myButton" name="myButton" type="submit" disabled>
      </div>
    </form>
    <script src="SpryAssets/SpryValidationTextField.js"></script>
    <script>
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
    function validateEnableSubmit(){
        var myForm=document.getElementById("myForm");
        var validForm = Spry.Widget.Form.validate(myForm);
        if(validForm == true)
            document.getElementById("myButton").disabled = false;
        else
            document.getElementById("myButton").disabled = true;
    </script>
    </body>
    </html>

  • How to prevent submit twice?

    i just use jsp and jstl.
    There is some way can prevent submit twice?
    i use sql in jdbc, first get the last record in table, compare the submit data and the last record, if same, prevent submit.
    but it can't check the date -- not the last record, same with the submit record.
    anyway can do it?

    what he/she is saying that you can put unique key on you databse that you cannot duplicate inserting records.. another way is to put javascript confirm box.. that way your client has to click ok to submit your form and it can prevent the user from double clicking your submit button.

  • Post Submit Twice Or More

    Hi Everyone!
              We have this problem
              - user claims to click/submit once
              - access.log shows the same form submitted twice or more at the same exact time
              I don't know whether it is due to firewall or any other settings in Weblogic 8.1 SP3 which I am not aware of. Also, could it be also because of the hyperlink we're using instead of "input" submission? Please advise. Any help would be appreciated!
              Attached below is the snipplets of code.
              Thanks in advance,
              Hardy
              <P>
              <p>Load File <br><br>
              function SubmitUploadForm() <br>
              { <br>
                  if(!isSubmit)<br>
                  {<br>
                      isSubmit = true;<br>
                      var inputFileTextBox =
              document[getNetuiTagName("uploadForm")][getNetuiTagName("inputbox")];<br>
                      <br>
                      if (inputFileTextBox.value == '')<br>
                      {<br>
              disableProcessing();<br>
                      }<br>
                      else<br>
                      {<br>
              enableProcessing();<br>
                      }<br>
                  document[getNetuiTagName("uploadForm")].submit();<br>
                  }<br>
              }</p>
              <p>function disableProcessing()<br>
              {<br>
                  document.getElementById ("processing").style.display =
              'none';<br>
                  document.getElementById ("button_disabled").style.display =
              'none';<br>
              }</p>
              <p>function enableProcessing()<br>
              {<br>
                  document.getElementById ("processing").style.display =
              'inline';<br>
                  document.getElementById ("button_disabled").style.display =
              'inline';<br>
                  document.getElementById ("button_enabled").style.display =
              'none';<br>
              }</p>

    Hi
              Check at www.javaranch.com ( search for double request )
              Jin

  • In a JSP Page, onclick of submit, it is submitting twice.

    Hello! everybody...
    Please help me.. its urgent!
    I have a jsp page, after i enter values in textboxes and click on submit, i am calling a javascript function wherein i am submitting the form.
    The problem is, it is submitting twice and inserting the record in the database twice.
    here is my code.
    anybody pls let me know where the problem is?
    Thanks in advance.
    /*Javascript Function for onsubmit*/
    function addVersion()
                             alert('hi');
                             this.VersionDynaForm.action = "./Version.do?param=add";
                             this.VersionDynaForm.submit();
    <html:form action="/Version.do" styleId="VersionDynaForm" onsubmit= "return addVersion()">
    <input type="hidden" name="actionType" value="">
         <table cellspacing=0 cellpadding=2 border=0 class="table_view" id="TABLE3" >
              <tr class="table_data">
                        <td class="smalltext" width="200px" align="left"><b>Year<span style="color:Red;">*</span></b></td>
                        <td width="150px">
                        <select id="FLP_YEAR" name="FLP_YEAR" class="mediumtext" style="width:120px; height:30px" onchange="FLP_YEARChanged()">
                        <option value="">Select</option>
                             <%
                             ArrayList year = new ArrayList<Version>();
                             year = (ArrayList)session.getAttribute("years");
                             if(year!=null)
                        for(int i=0;i<year.size();i++){                                 
                             Version temp1 = (Version)year.get(i);
                             if(temp1.getFLP_YEAR().equals(Element6)){
         %>
              <OPTION selected value='<%=temp1.getFLP_YEAR()%>'><%=temp1.getFLP_YEAR()%></OPTION>
                        <%}
                             else{%>
                             <OPTION value='<%=temp1.getFLP_YEAR()%>'><%=temp1.getFLP_YEAR()%></OPTION>
                        <%}
                        %>
                        </select>
                   </td>
                   <td width="150px"></td>
                   <td width="200px"></td>
                   <td width="200px"></td>     
                   <td width="150px"></td>
                   <td width="150px"></td>
                        <td width="200px"></td>
         </tr>
         <tr class="table_data">
                        <td class="smalltext" width="200px" align="left"><b>Business Line<span style="color:Red;">*</span></b></td>
                        <td widht="150px">
                        <select id="LPA_BUSINESS_LINES" name="LPA_BUSINESS_LINES" class="mediumtext" style="width:120px; height:30px" onchange="alert('hi');testChanged()">
                        <option value="">Select</option>
                             <%
                             ArrayList lst1 = new ArrayList<Version>();
                             lst1 = (ArrayList)session.getAttribute("mnemonic1");
                             if(lst1!=null)
                        for(int i=0;i<lst1.size();i++){                                 
                             Version temp1 = (Version)lst1.get(i);
                             if(temp1.getLPA_BUSINESS_LINES().equals(Element1)){
         %>
              <OPTION selected value='<%=temp1.getLPA_BUSINESS_LINES()%>'> <%=temp1.getLPA_BUSINESS_LINES()%></OPTION>
                        <%}
                             else{%>
                             <OPTION value='<%=temp1.getLPA_BUSINESS_LINES()%>'> <%=temp1.getLPA_BUSINESS_LINES()%></OPTION>
                        <%}
                        %>
                        </select>
                   </td>
                   <td width="150px"></td>
                   <td width="200px"></td>
                   <td width="200px"></td>     
                   <td width="150px"></td>
                   <td width="150px"></td>
                        <td width="200px"></td>
         </tr>
         <tr class="table_data" align="left">
                        <td class="smalltext" width="200px" align="left"><b>RC Number<span style="color:Red;">*</span></b></td>
                        <td width="150px">
                        <select id="LPA_RC_NUMBER" name="LPA_RC_NUMBER" class="mediumtext" style="width:120px; height:30px" onchange="LPA_RC_NUMBERChanged()">
                        <option value="">Select</option>
                             <%
                             ArrayList lst2 = new ArrayList<Version>();
                             lst2 = (ArrayList)session.getAttribute("rcmnemonic");
                             if(lst2!=null && Element2!=null)
                        for(int i=0;i<lst2.size();i++){                                 
                             Version temp2 = (Version)lst2.get(i);
                                  if(temp2.getLPA_RC_NUMBER().equals(Element2)){
         %>
              <OPTION selected value='<%=temp2.getLPA_RC_NUMBER()%>'> <%=temp2.getLPA_RC_NUMBER()%></OPTION>
                        <%}
                             else{%>
                             <OPTION value='<%=temp2.getLPA_RC_NUMBER()%>'> <%=temp2.getLPA_RC_NUMBER()%></OPTION>
                        <%}
                        %>
                        </select>
                        </td>
                        <td class="smalltext" width="200px" align="left"><b>Version<span style="color:Red;">*</span></b></td>
                        <td width="150px">
                        <select id="LPA_VERSION_ID" name="LPA_VERSION_ID" class="mediumtext" style="width:120px; height:30px" onchange="LPA_VERSION_IDChanged()">
                        <option value="">Select</option>
                             <%
                             ArrayList ver = new ArrayList<Version>();
                             ver = (ArrayList)session.getAttribute("version");
                             if(ver!=null && Element5!=null)
                        for(int i=0;i<ver.size();i++){                                 
                             Version temp3 = (Version)ver.get(i);
                                  if(temp3.getLPA_VERSION_ID().equals(Element5)){
         %>
              <OPTION selected value='<%=temp3.getLPA_VERSION_ID()%>'> <%=temp3.getLPA_VERSION_NO()%></OPTION>
                        <%}
                             else{%>
                             <OPTION value='<%=temp3.getLPA_VERSION_ID()%>'> <%=temp3.getLPA_VERSION_NO()%></OPTION>
                        <%}
                        %>
                        </select>
                        </td>
                   <td width="150px"></td>
                   <td width="200px"></td>
                   <td width="200px"></td>     
                   <td width="150px"></td>
         </tr>
         <tr class="table_data" >
                   <td class="smalltext" width="200px" align="left"><b>Project<span style="color:Red;">*</span></b></td>
                        <td width="150px">
                        <select id="LPA_PROJECT_NAME" name="LPA_PROJECT_NAME" class="mediumtext" style="width:120px; height:30px" onchange="LPA_PROJECT_NAMEChanged()">
                        <option value="">Select</option>
                             <%
                             ArrayList lst3 = new ArrayList<Version>();
                             lst3 = (ArrayList)session.getAttribute("project");
                             if(lst3!=null && Element3!=null)
                        for(int i=0;i<lst3.size();i++){                                 
                             Version temp2 = (Version)lst3.get(i);
                                  if(temp2.getLPA_PROJECT_NAME().equals(Element3)){
         %>
              <OPTION selected value='<%=temp2.getLPA_PROJECT_NAME()%>'> <%=temp2.getLPA_PROJECT_NAME()%></OPTION>
                        <%}
                             else{%>
                             <OPTION value='<%=temp2.getLPA_PROJECT_NAME()%>'> <%=temp2.getLPA_PROJECT_NAME()%></OPTION>
                        <%}
                        %>
                        </select>
                   </td>     
                   <td align="left" class="smalltext" width="150px"><b>Version Name</b><span style="color:Red;">*</span></td>
                   <td><input type="text" class="smalltext" property="LPA_VERSION_NAME" name="LPA_VERSION_NAME" value="" maxlength="30"/></td>
                   <td width="150px"></td>
                   <td width="200px"></td>
                   <td width="200px"></td>     
                   <td width="200px"></td>
         </tr>     
    </table>          
    <table cellspacing=0 cellpadding=2 border=0 class="table_input" id="TABLE2" >     
              <tr class="table_input">
                   <td height="10px" colspan="5" class="table_top_td" align = "right" >
                   <INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="submit" value="NewVersion" class="btn" >
                   <INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="button" value="Update" class="btn" name="method" onclick="javascript:return updateFunction();">
                   <INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="button" value=Cancel class="btn" name="method" onclick="history.go(-1)" >
                   </td>
              </tr>
    </table>

    hi
    change the type="button" in the following line
    <INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="submit" value="NewVersion" class="btn" >
    and call the javascript function on onClick in above line and dont call it from form(tat u hav done), remove it from form
    then it wont submit twice
    -venkat

  • Submit Button Issues

    I have created a form in InfoPath and am using SharePoint as the method of users entering their inquiries.
    Whenever I click the "submit" button, nothing occurs. I have to click it again for the data connections to run. For some reason, the submit button only works when clicked twice.
    I am using a standard button with no conditions, so the actions run as soon as the button is clicked.
    I have the following actions being run upon click:
    1- Submit using a data connection (Main data connection)
    2- Switch view to E-mail (a view I created)
    3- Submit using a data connection (E-mail)
    4- Close this form: no prompt
    There are no validation or formatting rules on this button. I am not sure why it has to be clicked twice. Does anybody have any ideas? I have searched google a bit and haven't found much.
    Thanks.

    Hi,
    According to your post, my understanding is that the submit button only works when clicked twice.
    If the form has the rich text box control, you need to go to the rich text box properties | browser forms tab | and change the post back settings to Never.
    Here are some similar threads for your reference:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/b113e820-3b9a-48f4-802c-bb36860b0ac7/infopath-button-has-to-be-clicked-twice-to-submit
    http://www.linkedin.com/groups/Submit-problem-in-Infopath-sharepoint-43166.S.163875753
    http://sharepoint.stackexchange.com/questions/100232/infopath-form-requires-me-to-submit-twice-due-to-slow-validation
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Help needed, double post-submit on Oracle 9iAS ?

    Hi,
    I am working on a project where we make use of Oracle Application Server 9.0.3 in combination with OC4J and struts. During development we have made use of JDeveloper 9.0.3 and its integrated server for testing the application. Unfortunately we have been waiting too long with deploying the app on the 'real' (Oracle IAS) server, and now we found out that when deploying the application on IAS, some parts of our application do not seem to work anymore.
    After a little investigation we found out that all POST submits of our forms seem to be submitted twice.
    Since we did some Javascript-evaluation before submitting, we first thought that that the problem was client-side, but after adding code to make sure that the submit will only occur once (flag set to 1 before submit, and only submit when flag = 0 etc..), the problem still persists...so the submit does not come from our document.formx.submit() command...
    Let me restate that this double posting does not occur within the JDeveloper-test-environment using the same browser.
    Now convinced that the problem was server-side, we thought we could focus on this side. Unfortunately, after an occasional test with a Mozilla-browser (our default (customer) browser is IE6), the problem did NOT occur !
    So, to sum things up :
    - Javascript does not submit twice
    - On the server, the logging indicates a double post-action
    - On client-side, only a single-post is allowed...
    - mozilla does not seem to cause problems, while IE6 does.
    - JDeveloper runtime environment does not expose the problem (with either browser, it goes smooth), while deploying on the IAS 9.0.3 server does...
    Can anyone shed some light on this ? We've been looking into it for a day already, and need to get it fixed asap (as always ;o))...
    Thanks for any info,
    Bas van Driel

    This sounds like a strange java problem not IAS
    From the sun site
    "When I try to open a file through my Java Web Start application, a message box pops up with the title "javaw.exe - No Disk". Why does this happen?
    This is a bug in the Java 2 SDK v1.2.2 or v1.3 . This bug will be fixed in a future Java 2 SDK release. In the meantime, there are a couple workarounds: "
    Id be very tempted to remove any JDK/JRE installations, or even better start with a clean machine.
    Hope this helps.

  • How to avoid submit disable?

    When I press submit FF automatically disable submit button so you cant submit twice. But this future is annoying because i cant normally test my script, how can I turn off this?

    http://forum.java.sun.com/thread.jsp?forum=45&thread=183161

  • I have iPhoto 08 and have been happy with it. Don't want to upgrade. But suddenly, when I click on an event, instead of all the photos, I just get one- enlarged- and cannot move to the next one. The photo just jumps up or down.  How to solve?

    I have posted "submit" twice and keep getting requests to submit again.  Now being asked to write a summary! Here we go.  I have iPhoto 08 and am happy with it.  Don't want to upgrade. But suddenly when I click on an event, instead of getting all the photos, I just get a large version of one photo and cannot move on to the others.  The right arrow will not move it and the photo just jumps around.

    Note the slider bottom right of the iPhoto Window. Drag it left.

  • Serial number has been registered before!

    I bought a new macbook pro and was trying to register the product online. it is a sucsessful registration on the product. However when i try to update the MAC OS X to Lion, it cannot be updated and request to use the up-to-date program to submit some of the information.
    I did submit twice on the up-to-date program. Cause the first email was reflected that the attached receipt was illegible. Hence, i upload another with a more high and clear pixel jpg. by right it should be clear enough. It still doesn't work out.
    I call up to apple support to ask. With the Serial number check, found out that my serial number has been registered before with another person name, and is not under my name. moreover that the purchase date is on April 2011. Which cause my warranty to be expired on the April 2012.
    I very doubt that my macbook pro is not new. Or been used before and return to the store.
    DId anyone experience that same problem?

    If the item is brand new out of the box then it may just simply be someone accidentally registered their system serial with yours by spelling mistake (S instead of 5, B instead of 8, etc..)
    Best way to resolve this is just call AppleCare and provide them with your proof of purchase and the serial number, I'm sure they can sort it out if you get to the right department.
    Link:
    http://www.apple.com/support/contact/

  • Constant site errors

    Once again we are getting constant "web page error" when save a reply. Also no emails are being sent since yesterday.
    When clicking "Alert Me" the page jumps to my user profile then throws page error.
    This happens on one Win 8.1 and one Windows 7 system.
    ¯\_(ツ)_/¯

     "web page error" when save a reply.
    What is the scenario?  E.g. this sounds like it could be clicking on Submit twice?  I keep forgetting that that is possible because of how Answers has been working (had been working, since it too apparently now allows us to retry a Submit when
    it comes back after having done nothing.)
    C.f.
    https://social.technet.microsoft.com/Forums/en-US/e00db0a4-cf3b-4759-b99f-7a87d89d73d9/whose-bug-ie-or-fissues?forum=reportabug
    http://answers.microsoft.com/en-us/feedback/forum/fdbk_commsite-bug/performance-problems-report-errors-here/e93eeb69-6502-44b6-aa63-424d8239d4e0?page=25&msgId=5996c5b8-12e7-48d3-9984-4c8e402f7b50 
    Note that for another issue in that same "Performance" thread we had been asked to clear our caches, apparently in the belief that something had been fixed.  I give proof that if that was in fact true it was not the client caches which need
    to be cleared but some intermediate ones in the network.  I don't know how we are supposed to help try to diagnose a case like that.  On Answers they are asking for Fiddler traces but I think that could actually fix some problems if they are related
    to timeouts that we have no control over otherwise (because Fiddler is a proxy program).
    So, try using Fiddler?  If nothing else you may then have diagnostics to help give a clearer symptom description.   <eg>
    Robert Aldwinckle

  • Prevent end-user doubleclicking buttons

    EHLO
    Anyone experienced this?
    There are certain checks needed for buttons which trigger inserts to tables. If the response is slow and the page redirects on the same page after submit the end-user might press submit twice or even more eagerly. Such might lead then cumbersome situations where the data is inserted several times etc..
    The checking can of course be done by writing certain conditions e.g. selects to the table etc.. but is there better way to do this?
    How-about having prevent-doubleclick-checkbox for the button and then have actually 3-statuses
    - working - and there custom message for the eager pusher
    - success
    - failure
    /paavo

    Hiya
    We're having big problems at the moment with our users double clicking and gettting oracle errors (because we do not allow duplicate rows in the tables).
    I've tried your suggestion using a HTML button and inserting the Javascript to disable the button once it's been clicked, and this works great.
    However I was wondering if there is something similar I could use for the Template Based Buttons (rather than HTML) as these have been used throughout our applications. I have tried the javascript method, but this doesnt seem to work.
    Many Thanks in advance.
    Natalie.

  • ThreadPoolExecutor constructor

    The thread pool executor takes a blocking queue as its argument (i.e. the work queue) which according to the API’s is used for +“… holding tasks before they are executed”+
    If a thread pool executor is permitted a maximum of 2 threads and has a fixed size work queue of 1 ….. if the main thread calls submit() twice before one of the pooled threads has a chance to execute will this result in the second call to submit() throwing an exception because of the size of the work queue being exceeded?
    I’m just slightly confused by the following description from the API:
    +•     If fewer than corePoolSize threads are running, the Executor always prefers adding a new thread rather than queuing.+
    +•     If corePoolSize or more threads are running, the Executor always prefers queuing a request rather than adding a new thread.+
    +•     If a request cannot be queued, a new thread is created unless this would exceed maximumPoolSize, in which case, the task will be rejected.+
    As +“fewer than corePoolSize threads are running”+, i.e. no threads are running, does the work queue actually get used (and so is its size relevant)?

    submit() on ThreadPoolExecutor will call execute this code:
        public Future<?> submit(Runnable task) {
            if (task == null) throw new NullPointerException();
            RunnableFuture<Object> ftask = newTaskFor(task, null);
            execute(ftask);
            return ftask;
        }That code will then call execute that is implemented like this in ThreadPoolExecutor:
        public void execute(Runnable command) {
            if (command == null)
                throw new NullPointerException();
            if (poolSize >= corePoolSize || !addIfUnderCorePoolSize(command)) {  // 1
                if (runState == RUNNING && workQueue.offer(command)) { //2
                    if (runState != RUNNING || poolSize == 0)
                        ensureQueuedTaskHandled(command);
                else if (!addIfUnderMaximumPoolSize(command)) // 3
                    reject(command); // is shutdown or saturated // 4
        }addIfUnderCorePoolSize at 1 will return false since it can't create a new thread (you had already created two threads)
    workQueue.offer at 2 will return false since we already had placed one item in the bound queue and can't add a new item right now
    addIfUnderMaximumPoolSize will also return false since we can't create a new thread
    reject at 4 will then be executed
    Kaj

  • Invalidating a session

    I have the following situation in a web application that requires log in: User loges in. Browses around and loges out (where session.invalidate() is called). If he goes back (press the back button on the browser) to the page after the login and reloads, user data (username and password) is posted again and the user is logged in again. How do I prevent this from happening? If a user loges out I don't want the username and password to be posted again without entering them.

    Okay.. I've done some research. This seems to be a common problem with no good solution. I've found two suggestions. Firstly, there's the "disable the back button solution" which isn't an option for me but here is the link in case you want to implement:
    http://www10.brinkster.com/A1ien51/Scripts/BackButton.htm
    The second is basically what I said in my previous post. I have tested this with a dummy page and it works well to distinguish between a legitimite submit and a pressing the back button (or copying and pasting the URL). Please find below the code listing. If you have any questions please don't hesitate to ask.
    ~Rob Lundeen
    -->TestBackButtonBug.jsp
    <%@ page language="java" errorPage="errorpage.jsp" contentType="text/html;charset=windows-1252" %>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <%@ page import="oracle.jbo.ApplicationModule, oracle.jbo.JboException" %>
    <%@ page import="oracle.jbo.html.*" %>
    <% RequestParameters params = HtmlServices.getRequestParameters(pageContext);
    String formTimeStamp = "";
    String serverTimeStamp = ""; %>
    <html>
    <head>
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    <LINK REL=STYLESHEET TYPE="text/css" HREF="bc4j.css">
    <TITLE>TESTING</TITLE>
    </head>
    <body>
    <h3>Testing Back Button Bug</h3>
    <% // Grab the current time and get a string which will change every millisecond
    java.util.Date now = new java.util.Date();
    String timeStamp = Long.toString(now.getTime());
    // check to see if this is a postback or not
    if (request.getMethod().equalsIgnoreCase("POST")) {
    // parse out the timeStamp querystring parameter
    formTimeStamp = params.getParameter("timeStamp");
    // grab the session attribute we have set (at the end of the page)
    serverTimeStamp = (String)session.getAttribute("SystemChangeDiagram.LoginPage");
    // compare the two. If they match, then this is a "clean" post, if not it is
    // the result of the back button or a URL paste
    if (formTimeStamp.equalsIgnoreCase(serverTimeStamp)) {
    %>Clean Post and txtInput=<%=params.getParameter("txtInput")%><%
    } else {
    // dump some output to show why this failed
    %>Dirty Post (Back button, submit twice or url paste) and txtInput=<%=params.getParameter("txtInput")%>
    --formTimeStamp=(<%=formTimeStamp%>)
    serverTimeStamp=(<%=serverTimeStamp%>)<%
    %>
    <%-- Make the form that will submit the text field and hidden field --%>
    <form name="Test" action="TestBackButtonBug.jsp" method="POST">
    <table border="0">
    <tr>
    <td title="Test" align="right">
    Input Data
    </td>
    <td title="">
    <input type="text" name="txtInput">
    </td>
    </tr>
    </table>
    <%-- here's the hidden field "timeStamp" which holds the value --%>
    <input type="hidden" name="timeStamp" value="<%=timeStamp%>">
    <input type="submit" value="Update">
    <input type="reset" value="Reset">
    </form>
    <% // Set the session attribute. This will change after we have recieved the first
    // post but the cached page (in the browsers history) will have the old timestamp
    // so it will not match up
    session.setAttribute("SystemChangeDiagram.LoginPage", timeStamp);
    %>
    </body>
    </html>

  • Please delete.......

    Sorry, I hit Submit twice.....

    You could try them here.
    http://azure.microsoft.com/en-us/support/forums/
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

Maybe you are looking for