• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can this be done better (html:link)

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding unique params to the url.
I am getting a list from the database and making the primary keys links so that a individual record from the db can be used.
I can quite easily display the rows using html:link tags (not shown) but I have been having trouble adding the dynamic unique param to the end of the url.(simple stuff but seems tricky in struts).
Links would look like:
/iNet/execute/viewSelectedNews?newsId=1
/iNet/execute/viewSelectedNews?newsId=2
/iNet/execute/viewSelectedNews?newsId=n
This is my current working solution. But its not ideal.
The Collection holds NewsVO objects.
It only has a single field for simplicty (newsId).
Can some liet me know if there is a way to lose the scriptlet code?

Thanks in advance.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try something like this:

One thing to note is that the value returned from your collection, what we refer to as "news" in the id property of the iterate tag, needs to be a String in order to be referenced by the paramName property of <html:link>.
 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do soimething like thuis
<bean efine id="nid" name="NewsVO" property="newsId" />
Then,
<html:link page="="/iNet/execute/viewSelectedNews" paramId="newsId" paramName="nid" >View</html:link>
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason
Your solution doesn't quite work.
The resulting URL is as follows:
http://blab-blah/execute/viewSelectedNews?clinton.inet.news.NewsVO@1adfbe3
The NewsVO class newsId is of type Long, but it returns a String.
------
Manasa
Your solution doesn't produce any output.
------
Thanks both of you.
Any more suggestions?
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure the NewsVO class is overriding the toString() method properly? Looks to me like it is using the standard toString method from Object.
Like Jason said, the paramName attribute has to be a String, so you need to either return the value you want from the toString method or create a getter for the value and access it as a property.
E
[ December 09, 2003: Message edited by: Eric Fletcher ]
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The NewsVO class is doing this:

Do you see a problem?
Thanks
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IGNORE PREVIOUS MSG _TYPO - THIS ONE IS CORRECT
The NewsVO class is doing this:

Do you see a problem?
Thanks
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this then:
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Woohoo.
Thanks Jason. Beers on me.
 
straws are for suckers. tiny ads are for attractive people.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic