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

struts 2: how to call action from href link

 
vikas sharmaa
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
normally, we mention the action attribute as a paramater of the form tag. then on click of submit button, the corresponding action class is called. Now, i would like to call action on click of the hyperlink ( i.e. <s:a href tag). how could i achieve it in Struts 2. Please help.>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

You want to call an action when you click a link?

Or you want to submit a form when you click a link?
 
vikas sharmaa
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
newton, i want to call an action on clicking a link.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And go to that action's page?
 
vikas sharmaa
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, go to the action page. i forgot to mention one thing that information related to link clicked is also required in the next action page.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You'll have to be more specific about that second requirement, I have no idea what it means.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:



thanks newton, after writing above code, execute method of the action class is called. But, i also want to send a value associated with the link clicked to the action class. how could i achieve it.

Let me elaborate the issue:

I have a list of employees with hyperlink on their names. now, i want user to edit an emploee by clicking on its name link. by above code, the execute method of action class is getting called. but i also want to send the emp name to the action class. how could i pass it?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the url tag docs?

From that page:



It's almost always quicker to check the documentation first.
 
Bilal A. Siddiqui
Ranch Hand
Posts: 53
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikas,

you can send the name or any other value like the way i have show below.




name variable contains the value.

on action page you can get this value by either making getter setter bean of EmpName or by using

request.getParameter("EmpName")
 
Gaurav Manral
Greenhorn
Posts: 17
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vikas sharmaa wrote:
David Newton wrote:

This was very useful David Newton.
But can you tell me, can we do the same like this?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic