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

struts 2: how to call action from href link

 
Ranch Hand
Posts: 191
  • 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.>
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • 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
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And go to that action's page?
 
vikas sharmaa
Ranch Hand
Posts: 191
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Likes 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
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • 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.
 
Ranch Hand
Posts: 53
Android Eclipse IDE Chrome
  • 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")
 
Greenhorn
Posts: 17
Java
  • 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?

 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic