You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Faisal Shoukat <Fa...@sssworldwide.com> on 2006/01/06 17:46:51 UTC

form submitted twice

Hi,

 

I have a problem where for some unknown reason my form is submitted
twice.  I have a action class which calls a delegate which calls a DAO
class. 

 

When I press submit the form is submitted.  My code in the JSP is as
follows:

 

Javascript function called when submitting form:

 

function setAction(action) 

{

            

            document.pendingRecordForm.action.value= action;     

            document.pendingRecordForm.submit();     

}

 

To submit the form the following image:

<html:image src="../images/save_button.jpg"
onclick="setAction('approve')"/>

 

The submit then calls the perform method in my struts action class ( By
the way I am using 1.0.2 version of Struts)

 

The action class then works through the code and when the thread gets to
the DAO class the second call arrives at the action class, 

 

This second call sends back a target of failure because of some
validation error and the successful target from the first submit is
ignored.

 

I don't understand why my form gets submitted twice.

 

The struts config is as follows for the action:

 

<action path="/approvexxxx"

        type="com.myclass.xxxx"

        name="pendingRecordForm"

        scope="request"

        input="/jsp/approvexxxxxx.jsp">

        <forward name="failure" path="/jsp/approvexxxxxx.jsp"/>

        <forward name="success" path="/jsp/menu.jsp"/>

    </action>

      

 

Thanks in advance

 


Re: form submitted twice

Posted by atta-ur rehman <at...@gmail.com>.
any anchors, <a name='blah'></a> on the page?

any chance  the image is within a submit tag/button?

how/where your action is forwarding after processing?

ATTA

On 1/6/06, Faisal Shoukat <Fa...@sssworldwide.com> wrote:
>
> Hi,
>
>
>
> I have a problem where for some unknown reason my form is submitted
> twice.  I have a action class which calls a delegate which calls a DAO
> class.
>
>
>
> When I press submit the form is submitted.  My code in the JSP is as
> follows:
>
>
>
> Javascript function called when submitting form:
>
>
>
> function setAction(action)
>
> {
>
>
>
>             document.pendingRecordForm.action.value= action;
>
>             document.pendingRecordForm.submit();
>
> }
>
>
>
> To submit the form the following image:
>
> <html:image src="../images/save_button.jpg"
> onclick="setAction('approve')"/>
>
>
>
> The submit then calls the perform method in my struts action class ( By
> the way I am using 1.0.2 version of Struts)
>
>
>
> The action class then works through the code and when the thread gets to
> the DAO class the second call arrives at the action class,
>
>
>
> This second call sends back a target of failure because of some
> validation error and the successful target from the first submit is
> ignored.
>
>
>
> I don't understand why my form gets submitted twice.
>
>
>
> The struts config is as follows for the action:
>
>
>
> <action path="/approvexxxx"
>
>         type="com.myclass.xxxx"
>
>         name="pendingRecordForm"
>
>         scope="request"
>
>         input="/jsp/approvexxxxxx.jsp">
>
>         <forward name="failure" path="/jsp/approvexxxxxx.jsp"/>
>
>         <forward name="success" path="/jsp/menu.jsp"/>
>
>     </action>
>
>
>
>
>
> Thanks in advance
>
>
>
>
>

Re: form submitted twice

Posted by Mark Lowe <me...@gmail.com>.
I reckon the form is being submitted with the form.submit() and the
input type=submit

remove this

document.pendingRecordForm.submit();

and see if it works for you.

Mark


On 1/6/06, Faisal Shoukat <Fa...@sssworldwide.com> wrote:
> Hi,
>
>
>
> I have a problem where for some unknown reason my form is submitted
> twice.  I have a action class which calls a delegate which calls a DAO
> class.
>
>
>
> When I press submit the form is submitted.  My code in the JSP is as
> follows:
>
>
>
> Javascript function called when submitting form:
>
>
>
> function setAction(action)
>
> {
>
>
>
>             document.pendingRecordForm.action.value= action;
>
>             document.pendingRecordForm.submit();
>
> }
>
>
>
> To submit the form the following image:
>
> <html:image src="../images/save_button.jpg"
> onclick="setAction('approve')"/>
>
>
>
> The submit then calls the perform method in my struts action class ( By
> the way I am using 1.0.2 version of Struts)
>
>
>
> The action class then works through the code and when the thread gets to
> the DAO class the second call arrives at the action class,
>
>
>
> This second call sends back a target of failure because of some
> validation error and the successful target from the first submit is
> ignored.
>
>
>
> I don't understand why my form gets submitted twice.
>
>
>
> The struts config is as follows for the action:
>
>
>
> <action path="/approvexxxx"
>
>         type="com.myclass.xxxx"
>
>         name="pendingRecordForm"
>
>         scope="request"
>
>         input="/jsp/approvexxxxxx.jsp">
>
>         <forward name="failure" path="/jsp/approvexxxxxx.jsp"/>
>
>         <forward name="success" path="/jsp/menu.jsp"/>
>
>     </action>
>
>
>
>
>
> Thanks in advance
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: form submitted twice

Posted by Wendy Smoak <ws...@gmail.com>.
On 1/6/06, Faisal Shoukat <Fa...@sssworldwide.com> wrote:

> I have a problem where for some unknown reason my form is submitted
> twice.  I have a action class which calls a delegate which calls a DAO
> class.

> To submit the form the following image:
>
> <html:image src="../images/save_button.jpg"
> onclick="setAction('approve')"/>

Try onclick="return setAction('approve');" or
onclick="setAction('approve'); return;" to stop the double submit.

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: form submitted twice

Posted by gr...@intellicare.com.
"Faisal Shoukat" <Fa...@sssworldwide.com> wrote on 01/06/2006 
11:46:51 AM:

> Hi,
> 
> 
> 
> I have a problem where for some unknown reason my form is submitted
> twice.  I have a action class which calls a delegate which calls a DAO
> class. 
> 
> 
> 
> When I press submit the form is submitted.  My code in the JSP is as
> follows:
> 
> 
> 
> Javascript function called when submitting form:
> 
> 
> 
> function setAction(action) 
> 
> {
> 
> 
> 
>             document.pendingRecordForm.action.value= action; 
> 
>             document.pendingRecordForm.submit(); 
> 
> }
> 

Wild guess: Try adding "return false;" to the end of your 
setAction(action) and see what happens..?

Geeta