Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple but different parameters in an html:link

Status
Not open for further replies.

Nondescripthandle

Programmer
Oct 1, 2003
3
0
0
CA
I'm trying to build a section of a page which is a bit like an explorer, although just a list of child "nodes" that can be opened by clicking on the link. I've figured out how to get all my Node objects into a Hashmap, and iterate through them using logic:iterate. Where the problem arises is that for each node, the link is the same, i.e. same arguments for each link, but not necessarily the same each time, but each one has a final argument called 'path' which is different for each link in the list.

The html:link tag allows one to insert a single argument or many, but in the case of many, you have to pack them into a hashmap first, and the two don't work together (i.e. if I put all the common arguments into a hashmap, but put the differeing one into paramId, paramName, it will only pick up the latter, and the rest will be dropped.

I also noted that you can't stick <%=jspvalue%> tags into struts attributes. If you can, can somebody give me the correct syntax?

Ideally, I want to do something where I have a HashMap of child nodes called childNodes in the request, also a Hashmap with the common attributes and I do something like:

<logic:iterate id=&quot;subnodes&quot; indexId=&quot;idx&quot; name=&quot;childNodes&quot; scope=&quot;request&quot;>
<bean:define id=&quot;subnode&quot; name=&quot;subnodes&quot; property=&quot;value&quot;/>
<html:link page=&quot;/main.do&quot; map=&quot;commonAttrs
paramId=&quot;path&quot; paramName=&quot;subnode&quot; property=&quot;path&quot;>
</html:link>
</logic:iterate>

Obviously this on its own won't work, but you get the idea.

Cheers
-Hugh
 
Hi,

If I understood you correctly are to trying to do some thing like this ?

URL = main.do?path=subnode1&test1=a&test2=b

In the above case you can do like this .

<logic:iterate id=&quot;subnodes&quot; indexId=&quot;idx&quot; name=&quot;childNodes&quot; scope=&quot;request&quot;>
<bean:define id=&quot;path&quot; name=&quot;subnodes&quot; property=&quot;subnode&quot;/>
<bean:define id=&quot;test1&quot; name=&quot;subnodes&quot; property=&quot;test1&quot;/>
<bean:define id=&quot;test2&quot; name=&quot;subnodes&quot; property=&quot;test2&quot;/>
<%
java.util.HashMap commonAttrs = new java.util.HashMap();
emailValues.put(&quot;path&quot;,subnode);
emailValues.put(&quot;test1&quot;,test1);
emailValues.put(&quot;test2&quot;,test2);
pageContext.setAttribute(&quot;commonAttrs&quot;, commonAttrs);
%>
<html:link page=&quot;/main.do&quot; name=&quot;commonAttrs&quot; scope=&quot;page&quot;>
Test
</html:link>
</logic:iterate>

Cheers,
-Venu

 
Sorry,

In the above code please change the

emailValues.put(Object key, Object value)
to
commonAttrs.put(Object key, Object value)

Cheers,
-Venu
 
Hmmmm,
that should work. I was hoping to cut down on object creation, but if that's the way to do it then so be it.

Ideally, I'm looking to have something like
URLS main.do?func=view&sub=msgs&tree=true&path=/home/ABC/asset-1
main.do?func=view&sub=msgs&tree=true&path=/home/ABC/asset-2
main.do?func=view&sub=msgs&tree=true&path=/home/ABC/asset-3

which the solution above would do. I'll give it a try and I'll let you know how it works.

Thanks
-Hugh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top