This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I want to dynamically set the link value in the action tag, but it is not working. The action="/TopicLink.do?link=<%= showResult %>" is giving me link="null" when I print it, but the same <%= showResult %> value in between the HTML tags are showing correct value. Please tell me where I am going wrong. Also, if I put The action="/TopicLink.do?link= testing", and later acces the value of link in my action class as
searchText = request.getParameter("link");
It gives the correct value. Only, action="/TopicLink.do?link=<%= showResult %>" does not work.:-(
Thanks, ~E
Remi Malessa
Greenhorn
Joined: Aug 27, 2007
Posts: 7
posted
0
I think I read yesterday that in Struts Tags (or html:link tag) there is a rule about using scriptlets: "all or nothing". You either write the whole construction inside the tag as a scriptlet, or you don't use the scriptlets inside. . . But I'm not 100% sure
sumita mukherjee
Greenhorn
Joined: Aug 27, 2007
Posts: 22
posted
0
Thanks for your reply. As you suggested: >You either write the whole construction inside the tag as a scriptlet, or >you don't use the scriptlets inside. . .
can you give me an example of doing that? I beg your pardon for my ignorance, but I am very new in this domain.
so the <html:link> tag is replaced by <a> (anchor)tags. But this does not work as well. Clicking on the link gives a Servlet eror 404(Action TopicLink.do navailable), even though I have a mapping in of this action in TopicLink.
Is there any way I can achieve this? Thanks for all the help.
Bhaskar Reddy
Ranch Hand
Joined: Dec 17, 2002
Posts: 52
posted
0
You could try using <html-el:link..> tag!
It is so much easier to set the values dynamically using the <html-el:xxxx> tags. I use it in combination with JSTL tags... I hope it should work with struts tags as well...
see the below code for an example -
sumita mukherjee
Greenhorn
Joined: Aug 27, 2007
Posts: 22
posted
0
Thanks for your reply. I have 2 questions regarding this: 1. I guess I need to add some jars for using this? Please correct me if I am wrong.
2. I need to set the value dynamically according to the arrayList value, so actually the value passed to link should be equal to the value of the id of Logic:iterate(i.e. showResult).
<logic resent name="resultList" scope="session"> <logic:iterate id="showResult" name="resultList"> //have to pass action="somehing.do?link=<<value of showResult>>
[ August 28, 2007: Message edited by: Bhaskar Reddy ] [ August 28, 2007: Message edited by: Bhaskar Reddy ]
sumita mukherjee
Greenhorn
Joined: Aug 27, 2007
Posts: 22
posted
0
Hi,
Thanks again for your reply. Now, while I was setting up for the JSTL resolution, I gave a last try with this and came very close, but got stuck at one place:
Now this works fine, and when I click on the link it sets the "link" parameter to "testing" correctly. But I am stuck here. How can I now set the HashMap value dynamically to the value of the Logic:Iterate Id attribute? If I can at least get a variable assigned to this it would work out. I am doing some syntactical mistakes here.
Can somebody please help me?
Regards, ~S
sumita mukherjee
Greenhorn
Joined: Aug 27, 2007
Posts: 22
posted
0
I guess I solved the problem. This works fine!! Putting the code, in case someone needs help in future: