• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form submission using struts link tag

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Can anybody please tell me how can i submit a form using <html:link>. I want to send multiple parameters with this submission.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to submit a form from a link, you need to use javascript to:

1) change the form's action to the URI you want the link to go to
2) submit the form.

If you're doing this, I'd recommend using a regular <a> tag, rather than <html:link>.

Here's a simple example:

<a href="#" onklick="document.myForm.action='myAction.do';document.myForm.form.submit();">Click Here</a>

onklick is deliberately misspelled to get this message past the security measures at JavaRanch.
 
dnyan ginde
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill I am using javascript to submit the form. My code is as follows

When i am using the above code i get the following exception
[1/30/06 18:51:51:336 IST] 64d7befc WebGroup E SRVE0026E: [Servlet Error]-[/pages/details.jsp(32,66) Attribute lForm has no value]: org.apache.jasper.compiler.ParseException: /pages/details.jsp(32,66) Attribute lForm has no value.

But when i use the normal <a> tag it works. Even you suggested to use <a> instead of <html:link>. Any specific reason its not working with <html:link>?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason it doesn't work with <html:link> is that you can't embed a <bean:write> tag inside any <html:xxx> tag. Struts just doesn't support it. If you really wanted to use an <html:link> tag, you could use a scriptlet in the href attribute.

In my opinion, <html:link> doesn't really give you any advantages over <a> when you're doing this type of thing, so why use it?
 
dnyan ginde
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the post.
reply
    Bookmark Topic Watch Topic
  • New Topic