This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

finding correct object in action

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about implementation. I have a list of objects(in session scope) which have various fields including username and a unique id. I display these on a page, as shown below.

USERNAME ID ....
<link>john doe<link> 1 .....
<link>jane doe<link> 2 ......

These are links. When a user clicks one of the links I send the request to an action. In this action class I want to determine which object has been chosen.

Thanks
mannu
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most common way to do this is to have the link pass a parameter indicating which link was selected as in:

<a href="myAction.do?user=joe">Joe</a>
 
Pranav Sharma
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for answers to both the questions. I just wanted to if you could suggest some reference where I could read abt this. What im askin is if this advice specific to struts or jsp/servlets.

thanks anyways
 
Pranav Sharma
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A followup question, this would work for hardcoded 'user'. However how would i add names dynamically

thanks
 
Pranav Sharma
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i added <href="Action.do?<bean:write name="result" property="fldrnum" />

It works, but is this good practice
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <html:link> tag has more than one method for including dynamically generated parameters with links. Check out this link:

http://struts.apache.org/userGuide/struts-html.html#link

I don't see anything wrong with the method you used also.
 
Do not threaten THIS beaver! Not even with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!