Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

form submission using struts link tag

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks for the post.
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic