Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form submission using struts link tag

 
dnyan ginde
Ranch Hand
Posts: 68
  • 0
  • 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.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the post.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic