You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Aaron O'Hara <Aa...@HelloNetwork.com> on 2001/09/06 23:05:53 UTC

Examples anyone?

All,

Would somebody be able to point me to an example of iteration with the
following environmental "restrictions"?  I've looked at sample code, but
nothing seems to meet 100% what I'm trying to do and I'm still tearing my
head out trying get get it to work.

I have an application scope bean with a getMethod() that returns a List
which is actually an ArrayList of "Task" objects.  I want to iterate through
this List and display properties of the Task object using the getter
methods.

In an unsuccessful attempt, I've tried:

<jsp:useBean id="general" scope="application"
class="com.razorfront.corporate.global.General"/>
<jsp:useBean id="task" scope="page"
class="com.razorfront.corporate.task.Task"/>

<logic:iterate id="task" name="general" property="tasks">
  <bean:write name="task" property="subject"/> <br>
</logic:iterate>

(I've omitted the taglib statements for brevity)

I've seen examples using HaspMaps and Lists of numbers, but not a List of
Objects.  Any assistance would be greatly appreciated!

Aaron

Re: According to the TLD attribute id is mandatory for tag iterate

Posted by Cedric Dumoulin <ce...@lifl.fr>.
  You make a mistake when in your closing iterate tag. You have to put '/' at
the beginning, otherwise, you start a new tag, causing the error.

  So, write </logic:iterate> instead of <logic:iterate/>, and all should work
fine.

    Cedric

Leo Amigood wrote:

> I'm almost dead with solving this issue.
> I'm getting this error "According to the TLD attribute id is mandatory for
> tag iterate"
> but everything seems similar to the previous guy code.
>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
>
> <jsp:useBean id="clist" scope="session" class="com.whatever.DBCountriesList"
> />
> <logic:iterate id="country" name="clist" property="myCountry" >
>         <bean:write name="country" property="title" />
> <logic:iterate/>
>
> 1) i have getMyCountry() with returns ArrayList
> 2) and getTitle() in the Country objects with are nested into that ArrayList
>
> any kind of help/examples would be appreciated.


According to the TLD attribute id is mandatory for tag iterate

Posted by Leo Amigood <le...@mosbusiness.ru>.
I'm almost dead with solving this issue.
I'm getting this error "According to the TLD attribute id is mandatory for
tag iterate"
but everything seems similar to the previous guy code.

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<jsp:useBean id="clist" scope="session" class="com.whatever.DBCountriesList"
/>
<logic:iterate id="country" name="clist" property="myCountry" >
	<bean:write name="country" property="title" />
<logic:iterate/>

1) i have getMyCountry() with returns ArrayList
2) and getTitle() in the Country objects with are nested into that ArrayList

any kind of help/examples would be appreciated.


Re: Examples anyone?

Posted by Bill Clinton <bc...@snipermail.com>.
Aaron,
      I believe the code you have should be accurate, but leave out the 
usebean directive for task (which isn't necessary and I think is 
interfering with your iteration id because it has the same id):

<jsp:useBean id="general" scope="application"
class="com.razorfront.corporate.global.General"/> 

<logic:iterate id="task" name="general" property="tasks">
  <bean:write name="task" property="subject"/> <br>
</logic:iterate>

this is assuming:
1) the method in General that returns the Arraylist is getTasks().
2) there is a method in Task called getSubject()

Hope that helps,
Bill



Aaron O'Hara wrote:

>All,
>
>Would somebody be able to point me to an example of iteration with the
>following environmental "restrictions"?  I've looked at sample code, but
>nothing seems to meet 100% what I'm trying to do and I'm still tearing my
>head out trying get get it to work.
>
>I have an application scope bean with a getMethod() that returns a List
>which is actually an ArrayList of "Task" objects.  I want to iterate through
>this List and display properties of the Task object using the getter
>methods.
>
>In an unsuccessful attempt, I've tried:
>
><jsp:useBean id="general" scope="application"
>class="com.razorfront.corporate.global.General"/>
><jsp:useBean id="task" scope="page"
>class="com.razorfront.corporate.task.Task"/>
>
><logic:iterate id="task" name="general" property="tasks">
>  <bean:write name="task" property="subject"/> <br>
></logic:iterate>
>
>(I've omitted the taglib statements for brevity)
>
>I've seen examples using HaspMaps and Lists of numbers, but not a List of
>Objects.  Any assistance would be greatly appreciated!
>
>Aaron
>
>.
>