1

I have a list of names of students in a class that being printed on JSP using iterator. I am giving each name a different id. Now I want to get the details of the name when a user clicks on the name. I am using struts2. How can I send this name to action when I click on the hyperlink of that name.

<s:a href="actionName" id="<s:property value='name'>"><s:property value='name'></s:a>

when I click on the name I should be able to send that name to the action. I have to send the name because I am using the same action for getting individual details of the students.

I saw in Internet that we can do this using JS. But I don't how to do it. Can some one help me?

Aadya
  • 75
  • 10
  • possible duplicate of [How can I give a hyperlink in a struts2 iterator](http://stackoverflow.com/questions/28336063/how-can-i-give-a-hyperlink-in-a-struts2-iterator) – Aleksandr M Feb 17 '15 at 09:52
  • @ aleksandar I dont want ajax. – Aadya Feb 17 '15 at 09:54
  • This seems a duplicate to me too. If you don't want AJAX, what about a form post, or the third option of loading them eagerly ? In which way is this question different from the previous one ? – Andrea Ligios Feb 17 '15 at 10:21
  • Also why you don't want AJAX ? And why you want JS ? AJAX is JS (Asynchoronous Javascript And Xml), and form posts can be done with JS too, but this is not the preferred way because of the inability to post a form for users surfing the web with JS disabled – Andrea Ligios Feb 17 '15 at 10:25

1 Answers1

0

You can pass name as parameter to action by

<a href="actionName?param=<s:property value='name'>" id="<s:property value='name'>"><s:property value='name'></a>

Remember to write the getter and setter method for param.

hKs
  • 486
  • 2
  • 6
  • 20