aspose file tools*
The moose likes Struts and the fly likes Struts / JSTL - Create ActionLink Dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts / JSTL - Create ActionLink Dynamically" Watch "Struts / JSTL - Create ActionLink Dynamically" New topic
Author

Struts / JSTL - Create ActionLink Dynamically

Dane Frazier
Greenhorn

Joined: Jul 15, 2002
Posts: 18
Here's what I am trying to do...
I have my view elements working (pulling data and displaying).

I have created an "add record" and it works well.

I want to create a link to edit the data.

I have the service object that does so, but if I do this...

in view.jsp...


This prints my collection of hrefs and the related data, however when I choose an href and it goes to the action it loads the form without hitting my querystring attribute...


What do I need to different? Do I need an EditAction class? either way, I need to get at the querystring and I am not seeing it here...

Any ideas are appreciated.
Dane Frazier
Greenhorn

Joined: Jul 15, 2002
Posts: 18
Stinking emoticons. ARG!
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

Dane, you can turn off the emoticons by checking the "Disable smilies in this post" option found below the Instant Graemlins palette.

As for your problem, the Struts way to do it would be to make sure that your AdminLevelForm has an adminLevelID attribute and corresponding getter/setter. This would shield you from having to access the request directly to get the query parameters. Your code as it is now is not giving you the results you expected because you should use request.getParameter() rather than request.getAttribute() to get to the values in the query string.


Junilu - [How to Ask Questions] [How to Answer Questions]
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Another tip, it's good practice to use the <html:rewrite ..> tag if you plan on using a link in that way. This way your application is more portable and the link's href is always valid eg.

Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

[/qb]<hr></blockquote>

Or you could use the JSTL c:url tag


[ October 21, 2004: Message edited by: Junilu Lacar ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts / JSTL - Create ActionLink Dynamically