You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steve A Drake <sa...@comet.ucar.edu> on 2001/07/03 23:39:36 UTC

html:link problem

 Hello. I'm trying to use <html:link> to submit the contents of a form.
The problem is that when I submit the form using <html:link>, the
ActionForm bean is not populated. My form looks like:


  <html:form action="simpleQuery.do">

...

        <html:link forward="simpleQuery"
                   paramId="offset"
                   paramName="resultNavigator"
                   paramProperty="startIndex" >
        {Stuff here}
        </html:link>

...
  </html:form>

In struts-config.xml, I've defined a global forward mapping from
"simpleQuery" to "/simpleQuery.do" . The parameter "offset" passes as a
request parameter to the Action class okay.

The only difference in the processing within Struts that I see is that,
for a form submission with the "Submit" button, Struts sees a "POST"
whereas for the <html:link> it sees a "GET" operation. For example,

output when using <html:submit>:

2001-07-03 16:30:07 action: Processing a POST for /simpleQuery
2001-07-03 16:30:07 action:  Looking for ActionForm bean under attribute
'simpleQueryForm'
2001-07-03 16:30:07 action:  Creating new ActionForm instance of class
'edu.ucar.comet.struts.SimpleQueryForm'
2001-07-03 16:30:07 action:  Storing instance under attribute
'simpleQueryForm' in scope 'request'
2001-07-03 16:30:07 action:  Populating bean properties from this request
2001-07-03 16:30:07 action:  Validating input form properties
2001-07-03 16:30:07 action:   No errors detected, accepting input
2001-07-03 16:30:07 action:  Looking for Action instance for class
edu.ucar.comet.struts.SimpleQueryAction


output when using <html:link>:

2001-07-03 16:30:24 action: Processing a GET for /simpleQuery
2001-07-03 16:30:24 action:  Looking for ActionForm bean under attribute
'simpleQueryForm'
2001-07-03 16:30:24 action:  Creating new ActionForm instance of class
'edu.ucar.comet.struts.SimpleQueryForm'
2001-07-03 16:30:24 action:  Storing instance under attribute
'simpleQueryForm' in scope 'request'
2001-07-03 16:30:24 action:  Populating bean properties from this request
2001-07-03 16:30:24 action:  Validating input form properties
2001-07-03 16:30:24 action:   No errors detected, accepting input
2001-07-03 16:30:24 action:  Looking for Action instance for class
edu.ucar.comet.struts.SimpleQueryAction



Re: html:link problem

Posted by Steve A Drake <sa...@comet.ucar.edu>.
 Thanks for your reply Matt.

 I tried invoking a Javascript function to perform the form submission,
e.g.:

         <html:link onclick="performAction(form, 'simpleQuery.do')"
                    forward="simpleQuery"
                    paramId="offset"
                    paramName="resultNavigator"
                    paramProperty="startIndex" >
         {Stuff here}
         </html:link>

but the "forward" attribute overrides the "onclick". If I leave out the
"forward" attribute, the JSP doesn't compile complaining that I need to
use one of "forward", "href" or "page". So now my problems are:

 1) How can I invoke the Javascript function (and ignore the hyperlink
attribute)
 2) How do I pass the request parameter (can I still use paramId, etc.)

Thanks in advance.


On Tue, 3 Jul 2001, Matt Raible wrote:

> You cannot use a link to submit a form, unless you
> call a javascript function from the link.  The link
> will only submit its parameters to the form bean.
>
> Hope this helps,
>
> Matt
>
> --- Steve A Drake <sa...@comet.ucar.edu> wrote:
> >  Hello. I'm trying to use <html:link> to submit the
> > contents of a form.
> > The problem is that when I submit the form using
> > <html:link>, the
> > ActionForm bean is not populated. My form looks
> > like:
> >
> >
> >   <html:form action="simpleQuery.do">
> >
> > ...
> >
> >         <html:link forward="simpleQuery"
> >                    paramId="offset"
> >                    paramName="resultNavigator"
> >                    paramProperty="startIndex" >
> >         {Stuff here}
> >         </html:link>
> >
> > ...
> >   </html:form>
> >
> > In struts-config.xml, I've defined a global forward
> > mapping from
> > "simpleQuery" to "/simpleQuery.do" . The parameter
> > "offset" passes as a
> > request parameter to the Action class okay.
> >
> > The only difference in the processing within Struts
> > that I see is that,
> > for a form submission with the "Submit" button,
> > Struts sees a "POST"
> > whereas for the <html:link> it sees a "GET"
> > operation. For example,
> >
> > output when using <html:submit>:
> >
> > 2001-07-03 16:30:07 action: Processing a POST for
> > /simpleQuery
> > 2001-07-03 16:30:07 action:  Looking for ActionForm
> > bean under attribute
> > 'simpleQueryForm'
> > 2001-07-03 16:30:07 action:  Creating new ActionForm
> > instance of class
> > 'edu.ucar.comet.struts.SimpleQueryForm'
> > 2001-07-03 16:30:07 action:  Storing instance under
> > attribute
> > 'simpleQueryForm' in scope 'request'
> > 2001-07-03 16:30:07 action:  Populating bean
> > properties from this request
> > 2001-07-03 16:30:07 action:  Validating input form
> > properties
> > 2001-07-03 16:30:07 action:   No errors detected,
> > accepting input
> > 2001-07-03 16:30:07 action:  Looking for Action
> > instance for class
> > edu.ucar.comet.struts.SimpleQueryAction
> >
> >
> > output when using <html:link>:
> >
> > 2001-07-03 16:30:24 action: Processing a GET for
> > /simpleQuery
> > 2001-07-03 16:30:24 action:  Looking for ActionForm
> > bean under attribute
> > 'simpleQueryForm'
> > 2001-07-03 16:30:24 action:  Creating new ActionForm
> > instance of class
> > 'edu.ucar.comet.struts.SimpleQueryForm'
> > 2001-07-03 16:30:24 action:  Storing instance under
> > attribute
> > 'simpleQueryForm' in scope 'request'
> > 2001-07-03 16:30:24 action:  Populating bean
> > properties from this request
> > 2001-07-03 16:30:24 action:  Validating input form
> > properties
> > 2001-07-03 16:30:24 action:   No errors detected,
> > accepting input
> > 2001-07-03 16:30:24 action:  Looking for Action
> > instance for class
> > edu.ucar.comet.struts.SimpleQueryAction
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>

-----------------------------------------------------------
Steve Drake                            sad@comet.ucar.edu
UCAR / COMET                           (303) 497 - 8496
PO Box 3000
Boulder, CO  80307-3000



Re: html:link problem

Posted by Matt Raible <ma...@yahoo.com>.
You cannot use a link to submit a form, unless you
call a javascript function from the link.  The link
will only submit its parameters to the form bean.

Hope this helps,

Matt

--- Steve A Drake <sa...@comet.ucar.edu> wrote:
>  Hello. I'm trying to use <html:link> to submit the
> contents of a form.
> The problem is that when I submit the form using
> <html:link>, the
> ActionForm bean is not populated. My form looks
> like:
> 
> 
>   <html:form action="simpleQuery.do">
> 
> ...
> 
>         <html:link forward="simpleQuery"
>                    paramId="offset"
>                    paramName="resultNavigator"
>                    paramProperty="startIndex" >
>         {Stuff here}
>         </html:link>
> 
> ...
>   </html:form>
> 
> In struts-config.xml, I've defined a global forward
> mapping from
> "simpleQuery" to "/simpleQuery.do" . The parameter
> "offset" passes as a
> request parameter to the Action class okay.
> 
> The only difference in the processing within Struts
> that I see is that,
> for a form submission with the "Submit" button,
> Struts sees a "POST"
> whereas for the <html:link> it sees a "GET"
> operation. For example,
> 
> output when using <html:submit>:
> 
> 2001-07-03 16:30:07 action: Processing a POST for
> /simpleQuery
> 2001-07-03 16:30:07 action:  Looking for ActionForm
> bean under attribute
> 'simpleQueryForm'
> 2001-07-03 16:30:07 action:  Creating new ActionForm
> instance of class
> 'edu.ucar.comet.struts.SimpleQueryForm'
> 2001-07-03 16:30:07 action:  Storing instance under
> attribute
> 'simpleQueryForm' in scope 'request'
> 2001-07-03 16:30:07 action:  Populating bean
> properties from this request
> 2001-07-03 16:30:07 action:  Validating input form
> properties
> 2001-07-03 16:30:07 action:   No errors detected,
> accepting input
> 2001-07-03 16:30:07 action:  Looking for Action
> instance for class
> edu.ucar.comet.struts.SimpleQueryAction
> 
> 
> output when using <html:link>:
> 
> 2001-07-03 16:30:24 action: Processing a GET for
> /simpleQuery
> 2001-07-03 16:30:24 action:  Looking for ActionForm
> bean under attribute
> 'simpleQueryForm'
> 2001-07-03 16:30:24 action:  Creating new ActionForm
> instance of class
> 'edu.ucar.comet.struts.SimpleQueryForm'
> 2001-07-03 16:30:24 action:  Storing instance under
> attribute
> 'simpleQueryForm' in scope 'request'
> 2001-07-03 16:30:24 action:  Populating bean
> properties from this request
> 2001-07-03 16:30:24 action:  Validating input form
> properties
> 2001-07-03 16:30:24 action:   No errors detected,
> accepting input
> 2001-07-03 16:30:24 action:  Looking for Action
> instance for class
> edu.ucar.comet.struts.SimpleQueryAction
> 
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/