• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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.
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic