You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kalcevich, Daniel" <dk...@firstam.com> on 2006/03/03 21:21:18 UTC
Logic Tag Question
I have the following:
- An ArrayList<LabelValueBean> in the ServletContext called
"timezones"
- A Form Bean in the request scope called "accountProfileForm"
I want to be able to loop through the values in the "timezones"
attribute and compate the "value" to the value of the "timeZone" in the
"accountProfileForm". Here is what I am trying:
<logic:iterate id="timeZones" collection="timezones" property="value">
<logic:equal name="accountProfileForm" property="timeZone"
value="timeZones.value">
<bean:write name="timeZones" property="label"/>
</logic:equal>
</logic:iterate>
I get the following error:
12:16:59,031 ERROR [action]:253 - Servlet.service() for servlet action
threw exception
javax.servlet.jsp.JspException: ServletException in
'/jsp/templates/tab_content_template.jsp': ServletException in
'/jsp/account/account_profile_form.jsp': Cannot create iterator for this
collection
at
org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTa
g.java:923)
Can someone point me in the right direction or let me know what is wrong
with the above? Thanks.
Daniel
Re: Logic Tag Question
Posted by "bryan@xoscript.org" <br...@xoscript.org>.
If I am not mistaking you will use either the collection or the property
attribute but not both.
http://struts.apache.org/struts-taglib/tagreference-struts-logic.html#logic:iterate
For each iteration of the loop you should be able to compare the value of the
id property in you logic:equal tag to the forms value by saying
<logic:iterate id="tz" collection="timezones">
<logic:equal name="accountProfileForm" property="timeZone" value="${tz}">
//do something
</logic:equal>
</logic:iterate>
Bryan LaPlante
---------- Original Message -----------
From: "Kalcevich, Daniel" <dk...@firstam.com>
To: user@struts.apache.org
Sent: Fri, 3 Mar 2006 12:21:18 -0800
Subject: Logic Tag Question
> I have the following:
>
> - An ArrayList<LabelValueBean> in the ServletContext called
> "timezones"
>
> - A Form Bean in the request scope called "accountProfileForm"
>
> I want to be able to loop through the values in the "timezones"
> attribute and compate the "value" to the value of the "timeZone" in the
> "accountProfileForm". Here is what I am trying:
>
> <logic:iterate id="timeZones" collection="timezones" property="value">
>
> <logic:equal name="accountProfileForm" property="timeZone"
> value="timeZones.value">
>
> <bean:write name="timeZones" property="label"/>
>
> </logic:equal>
>
> </logic:iterate>
>
> I get the following error:
>
> 12:16:59,031 ERROR [action]:253 - Servlet.service() for servlet action
> threw exception
>
> javax.servlet.jsp.JspException: ServletException in
> '/jsp/templates/tab_content_template.jsp': ServletException in
> '/jsp/account/account_profile_form.jsp': Cannot create iterator for this
> collection
>
> at
> org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTa
> g.java:923)
>
> Can someone point me in the right direction or let me know what is wrong
> with the above? Thanks.
>
> Daniel
------- End of Original Message -------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Logic Tag Question
Posted by Wendy Smoak <ws...@gmail.com>.
On 3/3/06, Kalcevich, Daniel <dk...@firstam.com> wrote:
I have the following:
> - An ArrayList<LabelValueBean> in the ServletContext called
> "timezones"
>
> - A Form Bean in the request scope called "accountProfileForm"
>
> I want to be able to loop through the values in the "timezones"
> attribute and compate the "value" to the value of the "timeZone" in the
> "accountProfileForm". Here is what I am trying:
It looks like a Map would be a better choice than an
ArrayList<LabelValueBean>. Can you change it? Then you could just use
[untested]
<c:out value="${timeZones[accountProfileForm.timeZone]}"/>
--
Wendy