You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andrew Yates <ad...@sanger.ac.uk> on 2003/06/16 15:15:24 UTC

Possible problem with forms & struts

Hi there,

This is the first time I've mailed this list so hi to everyone. I think
my problem lies in struts so hopefully this is the correct place to mail
to. I have a JSP page with two submit buttons which are linked to the
same ActionForm and Action with each button corresponding to a different
action. One is a search button and the other is a commit changes button.
The form was capturing these two button's outputs and the action then
deciding on what processes/classes/methods to run.

The problem is that every so often the page will create a get using the
search button even though I pressed the commit button. I've tried giving
both buttons the same name but different values, spliting the two
submits into two forms. I don't want to do split them up into two pages
and two sets of Actions & forms since the two pages are very similar in
content.

Has anyone else encountered this kind of problem before & how did you
solve it?

Many thanks,

Andy Yates

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


Re: Possible problem with forms & struts

Posted by Kevin Robair <kr...@yahoo.com>.
Hi Andrew,

Welcome to the list. Without more details, I can only speculate. Since my
code regularly parses (successfully) input from one form with multiple
buttons, I doubt this is a struts bug, but more than likely a config
issue.

A couple questions:

1. Are you looking at both the HTML page source, and the Request
parameters as seen by your action, and seeing the discrepancy? One thing
you could try is to extend ActionServlet and print out the request
parameters in and overridden version of  doGet() before moving on (don't
forget to call super.doGet()). If the discrepancy still exists, the
problem is in your container, or browser, or possibly in your
interpretation of what you are seeing.

2. Are you handling session timeouts? if not, you may be getting saddled
with a new session w/o expecting it. This seems an unlikely candidate
unless you are using the submitted button's value in some indirect way,
but I thought I would suggest it anyway.

I would assume you are doing something like this:

               <html:cancel onclick="bCancel=true;">
                  <bean:message key="button.cancel"/>
                </html:cancel>    
               &nbsp;
               &nbsp;
               <html:submit property="submit" onclick="bCancel=true;">
                  <bean:message key="button.previous"/>
               </html:submit>
               &nbsp;
               <html:submit property="submit" onclick="bCancel=false;">
                   <bean:message key="button.next"/>
               </html:submit>

Then in a formbean (in this case an dyna form:
     ....
    <form-property name="submit" type="java.lang.String" initial="" />
     ....

The in the Action something like this, depending on your ActionForm:

  DynaValidatorForm dvf = (DynaValidatorForm)actionForm;
  submitVal = (String)dvf.get("submit");


This always works for me. 


--- Andrew Yates <ad...@sanger.ac.uk> wrote:
> Hi there,
> 
> This is the first time I've mailed this list so hi to everyone. I think
> my problem lies in struts so hopefully this is the correct place to mail
> to. I have a JSP page with two submit buttons which are linked to the
> same ActionForm and Action with each button corresponding to a different
> action. One is a search button and the other is a commit changes button.
> The form was capturing these two button's outputs and the action then
> deciding on what processes/classes/methods to run.
> 
> The problem is that every so often the page will create a get using the
> search button even though I pressed the commit button. I've tried giving
> both buttons the same name but different values, spliting the two
> submits into two forms. I don't want to do split them up into two pages
> and two sets of Actions & forms since the two pages are very similar in
> content.
> 
> Has anyone else encountered this kind of problem before & how did you
> solve it?
> 
> Many thanks,
> 
> Andy Yates
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


=====
Kevin Robair
krobair@yahoo.com
(h) 703 876-0894
(c) 703 850-9544

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