Re: How can I use an Iterator's value twice?

2001-06-15 Thread Ted Husted

Your html:link needs to specify paramProperty=results. I can't tell
what the paramName should be, since that would depend on what the linked
page expects. 

Here's a reference snippet from a working page. The bean result has
accessors for donor, sortName, email, and website, where donor is a
unique key. Here the key is also used as the link text, but any other
value from the bean could have been linked instead. This snippet
generates links in the form:

/donor/Select.do?key=1234

where result.rows.getDonor() returns 1234

logic:iterate name=result property=rows id=row
td align=left
  html:link page=/donor/Select.do paramName=row paramId=key
paramProperty=donor
bean:write name=row property=donor filter=true/
  /html:link 
/td
td align=left
bean:write name=row property=sortName filter=true/
/td
td align=left nowrap
  bean:write name=row property=telephone filter=true/
/td
td align=left nowrap
   font size=1a href=mailto:bean:write name=row
property=email/bean:write name=row property=email
filter=true//a/font
/td
td align=left
   font size=1a href=http://bean:write name=row
property=website/ target=_blankbean:write name=row
property=website filter=true//a/font
/td
  /tr
/logic:iterate

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/


Digico wrote:
 
 This problem loosely related to a couple of others that I've seen recently
 on this list, and it's a common enough thing to do that there must be a
 simple solution that I just don't see.
 
 I want to produce a list of search results as hyperlinks in which each list
 value is displayed AND is used in the link, as in:
 
 ol
 lia href=/myapp/fetchItem.do?key=key_1key_1/a
 lia href=/myapp/fetchItem.do?key=key_2key_2/a
 lia href=/myapp/fetchItem.do?key=key_3key_3/a
 ... etc ...
 /ol
 
 I've tried using the iterate tag and a bean that has an Iterator property,
 along with html:link as in the following sample:


 
 logic:iterate id=results name=mainSearchBean
 property=resultsIterator 
 li
 html:link page=/bookDetails.do
 paramId=key paramName=? paramProperty=? 
 bean:write name=results/
 /html:link
 /logic:iterate
 
 I've tried setting paramId, paramName, and paramProperty in various ways but
 nothing gives me the results I want.  The best I get is a list of hyperlinks
 for the results as expected except that the actual links are all the same.
 I also tried jamming a copy of the bean:write name=results tag in the
 page attribute of html:link but that caused an exception.  Should I just
 add a Map property to mainSearchBean and, if so, how would I use it to this
 effect?
 
 Thanks.
 
 - Mark.



How can I use an Iterator's value twice?

2001-06-14 Thread Digico

This problem loosely related to a couple of others that I've seen recently
on this list, and it's a common enough thing to do that there must be a
simple solution that I just don't see.

I want to produce a list of search results as hyperlinks in which each list
value is displayed AND is used in the link, as in:

ol
lia href=/myapp/fetchItem.do?key=key_1key_1/a
lia href=/myapp/fetchItem.do?key=key_2key_2/a
lia href=/myapp/fetchItem.do?key=key_3key_3/a
... etc ...
/ol

I've tried using the iterate tag and a bean that has an Iterator property,
along with html:link as in the following sample:

logic:iterate id=results name=mainSearchBean
property=resultsIterator 
li
html:link page=/bookDetails.do
paramId=key paramName=? paramProperty=? 
bean:write name=results/
/html:link
/logic:iterate

I've tried setting paramId, paramName, and paramProperty in various ways but
nothing gives me the results I want.  The best I get is a list of hyperlinks
for the results as expected except that the actual links are all the same.
I also tried jamming a copy of the bean:write name=results tag in the
page attribute of html:link but that caused an exception.  Should I just
add a Map property to mainSearchBean and, if so, how would I use it to this
effect?

Thanks.

- Mark.