This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes how to  send variable value through <html:link> tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to  send variable value through <html:link> tag" Watch "how to  send variable value through <html:link> tag" New topic
Author

how to send variable value through <html:link> tag

Aniket Khadke
Greenhorn

Joined: Jul 13, 2011
Posts: 29

Hi,
In my application I am displaying list of students. And when user clicks on student's name, his profile should be displayed. For this I want to send students name with the url. How can I do that?
Thanks..
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Aniket,

If using html:link is the only option you are looking for then,
1. use "href/onclick" attribute to set the URL and append the values to the URL (not secure but works with/without java script browser)
2. use "href/onclick" attribute to call javascript method and pass this value as method parameter and submit the action in javascript.



Have Fun with Java
little,little.. little by little makes a lot..
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

Hi Aniket,

Assuming the name of the ActionForm is 'StudentsForm' which has a student object.
The 'student' object contains 'studentName' as one of its property.
'stud' is the scripting variable in the <logic:iterator> tag.
Now, when the user clicks on the name of the student (defined in <bean:write> tag) the 'passStudentName' action is fired taking studentName as the value of the request parameter. And note that (paramId="name") 'name' of the request parameter.
So, in your ActionForm you should have a field called 'name' which will hold the value passed by the request parameter(i.e studentName).

If you have any problem in understanding the above one reply me back.

Regards,

Sandy

Take up one idea. Make that one idea your life; dream of it; think of it; live on that idea. Let the brain, the body, muscles, nerves, every part of your body be full of that idea, and just leave every other idea alone. This is the way to success.
Aniket Khadke
Greenhorn

Joined: Jul 13, 2011
Posts: 29

Sandy Chatterjee wrote:Hi Aniket,

Assuming the name of the ActionForm is 'StudentsForm' which has a student object.
The 'student' object contains 'studentName' as one of its property.
'stud' is the scripting variable in the <logic:iterator> tag.
Now, when the user clicks on the name of the student (defined in <bean:write> tag) the 'passStudentName' action is fired taking studentName as the value of the request parameter. And note that (paramId="name") 'name' of the request parameter.
So, in your ActionForm you should have a field called 'name' which will hold the value passed by the request parameter(i.e studentName).

If you have any problem in understanding the above one reply me back.

Regards,

Sandy



Hi Sandy,
Code worked like a champ... thanks.. :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to send variable value through <html:link> tag
 
Similar Threads
how to retrieve value of attribute of an xml element tag using jsp
Option collections problem
Struts 2 iterators
struts 1.3 Interactive form
(struts 1.2)retreiving values from multibox