You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pete Black <pe...@metering.co.nz> on 2001/01/31 06:11:07 UTC

using logic:iterate with Arrays

Hi there,

can anyone help me out with the syntax for dealing with iterating through an
array of Strings, returned by a FormBean property?

my current code looks like:

logic:iterate id="element" property="records">
<bean:write name="element"/><BR>
</logic:iterate>

the method getRecords() in my FormBean returns a String[] array, but i get
this error:

java.lang.NullPointerException at java.util.Hashtable.get(Hashtable.java,
Compiled Code) 

It looks like Struts thinks it is trying to iterate over a Hashtable. The
docs suggest that arrays are supported, since i don't really need a
Hashtable.. Does using an array require a different syntax, or should i use
another type of object, rather than an Array?

Thanks

-Pete

Re: using logic:iterate with Arrays

Posted by Ted Husted <ne...@husted.com>.
See if adding 

name="myFormBean" 

as a parameter to the logic tag helps.

*********** REPLY SEPARATOR  ***********

On 1/31/2001 at 6:11 PM Pete Black wrote:

Hi there,

can anyone help me out with the syntax for dealing with iterating
through an
array of Strings, returned by a FormBean property?

my current code looks like:

logic:iterate id="element" property="records">
<bean:write name="element"/><BR>
</logic:iterate>

the method getRecords() in my FormBean returns a String[] array, but i
get
this error:

java.lang.NullPointerException at
java.util.Hashtable.get(Hashtable.java,
Compiled Code) 

It looks like Struts thinks it is trying to iterate over a Hashtable.
The
docs suggest that arrays are supported, since i don't really need a
Hashtable.. Does using an array require a different syntax, or should i
use
another type of object, rather than an Array?

Thanks

-Pete



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/