You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Husted <hu...@apache.org> on 2001/09/05 16:15:05 UTC

Re: Using the iterate tag

Personally, I would wrap the ArrayList in a bean and expose the size (or
row count) with an accessor. Then you can do things like this:

<logic:notEqual name="result" property="rowCount" value="0"> 

... iterate the list 

</logic:notEqual>
<logic:equal name="result" property="rowCount" value="0"> 

... explain that there is nothing to interate

</logic:equal>

The interate tag is designed for this strategy. You can specify the bean
with the name property, and the accessor for the ArrayList with the
property property (sic). 

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


chiji nwankwo wrote:
> 
> Hi,
> 
> I am try to use the iterate tag to display a list of strings on a
> page.  The strings I am using have been initialized in an ArrayList.
> I want to be able to check how many strings are in the list so that I
> can display a certain amount on a number of pages.  This is because I
> do not know how many strings I will have in advance.  The example
> below is a simulation, but I seem to be getting an error when I try to
> use a jsp runtime expression such as <%= size %>.
> 
> This is the example I am trying at the moment, please help if you can.
> 
> <%
>   java.util.ArrayList testList = new java.util.ArrayList();
>   for( int i = 0; i < 30; i++ )
>       testList.add( new Integer( i ) );
> 
>    int size = testList.size();
>  %>
> 
>  <logic:iterate id="playerStats" collection="<%= testList
> %>" type="java.lang.Integer"
>      offset="0" length="<%= size %>">
>            <%= playerStats %>
>  </logic:iterate>
> 
> and this is the error I am getting.
> 
> org.apache.jasper.JasperException: Unable to compile class for
> JSPC:\jakarta-tomcat-3.2.1\work\localhost_8080%2FvideoLounge\_0002fsearchResults_0002ejspsearchResults_jsp_47.java:646:
> Incompatible type for method. Can't convert int to java.lang.String.
>                 _jspx_th_logic_iterate_0.setLength( size );
>                                                     ^
> 1 error
> 
> Thanks
> 
> Chiji
> 
> >From: "Robert Taylor"
> >Reply-To: struts-user@jakarta.apache.org
> >To:
> >Subject: Persistence tier in web applications
> >Date: Wed, 5 Sep 2001 05:51:52 -0400
> >MIME-Version: 1.0
> >Received: from [64.125.133.20] by hotmail.com (3.2) with ESMTP id
> MHotMailBD5F41A100984004315B407D85140A910; Wed, 05 Sep 2001 02:55:45
> -0700
> >Received: (qmail 55442 invoked by uid 500); 5 Sep 2001 09:54:14 -0000
> >Received: (qmail 55432 invoked from network); 5 Sep 2001 09:54:13
> -0000
> >Received: from avocet.mail.pas.earthlink.net (207.217.121.50) by
> daedalus.apache.org with SMTP; 5 Sep 2001 09:54:13 -0000
> >Received: from dialup-209.246.189.57.dial1.atlanta1.level3.net
> ([209.246.189.57] helo=muleworkrt)by avocet.mail.pas.earthlink.net
> with smtp (Exim 3.32 #2)id 15eZO1-0001yH-00for
> struts-user@jakarta.apache.org; Wed, 05 Sep 2001 02:54:21 -0700
> >From struts-user-return-16688-cn081 Wed, 05 Sep 2001 02:56:56 -0700
> >Mailing-List: contact struts-user-help@jakarta.apache.org; run by
> ezmlm
> >Precedence: bulk
> >list-help: <?xml:namespace prefix = mailto />
> >list-unsubscribe:
> >list-post:
> >Delivered-To: mailing list struts-user@jakarta.apache.org
> >Message-ID:
> >X-Priority: 3 (Normal)
> >X-MSMail-Priority: Normal
> >X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
> >Importance: Normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
> >X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
> >
> >Greetings, I was wondering if anyone was implementing the DAO design
> pattern
> >using JDO. I am currently re-engineering a web application and plan
> to use
> >Struts for the web tier and am looking for a non-J2EE solution for
> the
> >business/persistence layer. I have done some cursory research on JDO
> and was
> >curious if anyone was using it. If so, which implementation, and how
> you are
> >using value objects with it.
> >
> >thanks,
> >
> >robert
> >
> 
> ----------------------------------------------------------------------
> Get your FREE download of MSN Explorer at http://explorer.msn.com

RE: Using the iterate tag

Posted by Roumen Ganeff <ga...@wizcom.bg>.
isn't there a bean:size tag, which is designed for this?

G.

-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Wednesday, September 05, 2001 5:15 PM
To: struts-user@jakarta.apache.org
Subject: Re: Using the iterate tag


Personally, I would wrap the ArrayList in a bean and expose the size (or
row count) with an accessor. Then you can do things like this:

<logic:notEqual name="result" property="rowCount" value="0">

... iterate the list

</logic:notEqual>
<logic:equal name="result" property="rowCount" value="0">

... explain that there is nothing to interate

</logic:equal>

The interate tag is designed for this strategy. You can specify the bean
with the name property, and the accessor for the ArrayList with the
property property (sic).

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


chiji nwankwo wrote:
>
> Hi,
>
> I am try to use the iterate tag to display a list of strings on a
> page.  The strings I am using have been initialized in an ArrayList.
> I want to be able to check how many strings are in the list so that I
> can display a certain amount on a number of pages.  This is because I
> do not know how many strings I will have in advance.  The example
> below is a simulation, but I seem to be getting an error when I try to
> use a jsp runtime expression such as <%= size %>.
>
> This is the example I am trying at the moment, please help if you can.
>
> <%
>   java.util.ArrayList testList = new java.util.ArrayList();
>   for( int i = 0; i < 30; i++ )
>       testList.add( new Integer( i ) );
>
>    int size = testList.size();
>  %>
>
>  <logic:iterate id="playerStats" collection="<%= testList
> %>" type="java.lang.Integer"
>      offset="0" length="<%= size %>">
>            <%= playerStats %>
>  </logic:iterate>
>
> and this is the error I am getting.
>
> org.apache.jasper.JasperException: Unable to compile class for
>
JSPC:\jakarta-tomcat-3.2.1\work\localhost_8080%2FvideoLounge\_0002fsearchRes
ults_0002ejspsearchResults_jsp_47.java:646:
> Incompatible type for method. Can't convert int to java.lang.String.
>                 _jspx_th_logic_iterate_0.setLength( size );
>                                                     ^
> 1 error
>
> Thanks
>
> Chiji
>
> >From: "Robert Taylor"
> >Reply-To: struts-user@jakarta.apache.org
> >To:
> >Subject: Persistence tier in web applications
> >Date: Wed, 5 Sep 2001 05:51:52 -0400
> >MIME-Version: 1.0
> >Received: from [64.125.133.20] by hotmail.com (3.2) with ESMTP id
> MHotMailBD5F41A100984004315B407D85140A910; Wed, 05 Sep 2001 02:55:45
> -0700
> >Received: (qmail 55442 invoked by uid 500); 5 Sep 2001 09:54:14 -0000
> >Received: (qmail 55432 invoked from network); 5 Sep 2001 09:54:13
> -0000
> >Received: from avocet.mail.pas.earthlink.net (207.217.121.50) by
> daedalus.apache.org with SMTP; 5 Sep 2001 09:54:13 -0000
> >Received: from dialup-209.246.189.57.dial1.atlanta1.level3.net
> ([209.246.189.57] helo=muleworkrt)by avocet.mail.pas.earthlink.net
> with smtp (Exim 3.32 #2)id 15eZO1-0001yH-00for
> struts-user@jakarta.apache.org; Wed, 05 Sep 2001 02:54:21 -0700
> >From struts-user-return-16688-cn081 Wed, 05 Sep 2001 02:56:56 -0700
> >Mailing-List: contact struts-user-help@jakarta.apache.org; run by
> ezmlm
> >Precedence: bulk
> >list-help: <?xml:namespace prefix = mailto />
> >list-unsubscribe:
> >list-post:
> >Delivered-To: mailing list struts-user@jakarta.apache.org
> >Message-ID:
> >X-Priority: 3 (Normal)
> >X-MSMail-Priority: Normal
> >X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
> >Importance: Normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
> >X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
> >
> >Greetings, I was wondering if anyone was implementing the DAO design
> pattern
> >using JDO. I am currently re-engineering a web application and plan
> to use
> >Struts for the web tier and am looking for a non-J2EE solution for
> the
> >business/persistence layer. I have done some cursory research on JDO
> and was
> >curious if anyone was using it. If so, which implementation, and how
> you are
> >using value objects with it.
> >
> >thanks,
> >
> >robert
> >
>
> ----------------------------------------------------------------------
> Get your FREE download of MSN Explorer at http://explorer.msn.com