To answer the question, I'm using IE5.5.

However, I discovered the immediate problem, which turns out to be simple,
but then it gets complicated again.

First off, the double posting appears to be caused by specifying both an
action attribute on the form tag and an onClick attribute on the submit tag.
For example:

<html:form action="/test.do?action=Cancel">

<html:submit property="store" value="Store"
 
onClick="performAction(this.form,'/test.do?action=Store')"/>

I am using the JavaScript function I found an archive listing regarding how
to set multiple actions in a form....
function performAction(theForm, theAction)
{
    theForm.action = theAction;
    theForm.submit();
}

As you can see, both "actions" also specify an "action" parameter, the same
as is used in the struts-example application.  The wierd thing, though, is
that the action parameter specified in the action attribute of the form tag
is ignored.  That is, there are 2 postings but both times the action
parameter takes on the value given in the onClick action.   If I remove the
onClick attribute, I get 1 posting with the action parameter taken from the
form's action attribute.

The obvious thing to try then, would be to remove the form's action
attribute and just use the submit's onClick attribute.  However, this causes
an exception (at least in my WLS5.1SP8 environment), which complains that
the "required" action attribute is missing.  I don't understand this because
the action attribute isn't required in the struts-form tld.  Why is this
happening?

Anyway, the above observations were based on using the struts build from 14
Feb.
So then I decided to try the V1 beta 1 build.

The results are very similar except that now the form's action attribute
does NOT set the action parameter at all.  That is, if I remove the submit's
onClick attribute, there is only 1 posting, but the action parameter does
not get defined (request.getParameter("action") returns null).  This is a
bug isn't it?  If I go back to setting both the form's action attribute  and
the submit's onClick attribute, I get 2 postings and the action parameter is
set from the onClick.

I hope I explained this cleary enough.  Whether or not the problem with the
form's action attribute is a bug, I'd still like to know if there is a way
to use the onClick attribute without getting a double posting.

Regards,
Vic


> -----Original Message-----
> From: Neal Kaiser [SMTP:[EMAIL PROTECTED]]
> Sent: Saturday, February 24, 2001 10:33 AM
> To:   [EMAIL PROTECTED]
> Subject:      RE: perform() called twice
> 
> This is a little out-there, but, by any chance are you using Netscape 6
> and Frontpage for your JSP editor?
> 
> I found a bug in Netscape 6 that causes a page to be submitted twice (when
> actually pressing it once) if there are certain Frontpage META tags in
> your
> page.
> 
> The solution for us was to remove the frontpage meta tags it
> auto-generates.
> 
> One way to tell would be by doing a tail on your access_log file. If you
> see
> two
> requests, then that might be the problem.
> 
> Neal
> 
> > -----Original Message-----
> > From: Anand Raman [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, February 24, 2001 6:58 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: perform() called twice
> >
> >
> > Hi Vic
> > The action perform method is called once for every submission..
> >
> > When u hit the submit button the ActionFromBean is populated and then
> > the controller passes on the control to the Action class perform
> > method.
> >
> > U then return any appropriate action forward method from the same
> > perform method .
> >
> > I am not sure why u get 2 calls to the perform method.. Maybe posting
> > sections of code can help..
> >
> > Anand
> >
> > On Fri, Feb 23, 2001 at 01:38:18PM -0500, Fickes, Vic wrote:
> > >Hi,
> > >I am trying to understand the sequence of events that take
> > place using a
> > >simple test <html:form>.  When the form's action is
> > submitted, it causes the
> > >Action.perform() method to be called twice in the same
> > request.  I thought
> > >it might have something to do with the forward that is returned from
> > >perform() so I returned null, and it still does it.  Is this
> > the expected
> > >behavior?  I don't think this is happening in the example
> > application, so it
> > >must be something I am doing, but I can't figure out what.
> > Any ideas would
> > >be appreciated.
> > >Thanks,
> > >Vic
> >

Reply via email to