You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Oberlander <Je...@onename.com> on 2002/01/22 19:43:38 UTC
iterate tag problems
Been through the archive, and the logic-present.jsp in the sample
distributions but nothing has solved this yet.
I am simply adding an ArrayList of String to a request in my action. I've
added 3 Strings to oMessages:
request.setAttribute("messages",oMessages);
RELEVANT JSP :
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<logic:present name="messages">
<logic:iterate id="item" name="messages">
<li>Info: <bean:write name="item" /></li>
</logic:iterate>
</logic:present>
OUTPUT:
Info:
Info:
Info:
So it is iterating through the 3 items, but is writing nothing. What am I
missing??
Thanks
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: iterate tag problems
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Jeff" == Jeff Oberlander <Je...@onename.com> writes:
Jeff> Been through the archive, and the logic-present.jsp in the sample
Jeff> distributions but nothing has solved this yet.
Jeff> I am simply adding an ArrayList of String to a request in my action. I've
Jeff> added 3 Strings to oMessages:
Jeff> request.setAttribute("messages",oMessages);
Jeff> RELEVANT JSP :
Jeff> <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
Jeff> <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
Jeff> <logic:present name="messages">
Jeff> <logic:iterate id="item" name="messages">
Jeff> <li>Info: <bean:write name="item" /></li>
Jeff> </logic:iterate>
Jeff> </logic:present>
Jeff> OUTPUT:
Jeff> Info:
Jeff> Info:
Jeff> Info:
Jeff> So it is iterating through the 3 items, but is writing nothing. What am I
Jeff> missing??
I'm sure there's a better way to do this, and I'd love to know it, but when I
ran into something like this, instead of a Collection of Strings, I made a
Collection of Beans which have a String data member.
So, you might have something like this:
public class MessageItem
{
public String value;
public MessageItem(String value) {this.value = value;}
public String getValue() {return (value);}
public void setValue(String value) {this.value = value;}
}
and then:
<logic:iterate id="item" name="messages" type="MessageItem">
<li>Info: <bean:write name="item" property="value"/></li>
</logic:iterate>
In other words, I had trouble using the values while iterating through a
Collection of primitives, so I wrapped a Bean around the primitives.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; BrainBench CJ12P (#12004)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Action forward with URL parameters
Posted by John Ng <jn...@yahoo.com>.
I would like to use the action's perform method to
forward to a perl page. However, I also would like to
pass in some argument on the URL.
For example : http://abc.com?name=JK&state=NY
I definied http://abc.com in the struts-config.xml.
However, how can I make the ActionForward object to
contain those name and state info and append it to the
URL after the forward.
Thanks in advance for any suggestions.
JN.
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>