Struts and Collections

J

jf

Hi

I am new to struts and I have a small problem.

I have a bean (DataGrid) that has a collection of Columns (ArrayList)
and each column has rows (ArrayList). So, when i want to iterate with
the lists i would do something like:

<logic:iterate name="datagrid" property="columns" id="column">


<bean:write name="column" property="columnName"/>


<logic:iterate id="row" name="columns" property="rows">


<bean:write name="row" property="value"/>
</logic:iterate>

I can iterate with the columns but when i try to iterate with the rows
(that is a member variable of the columns) it says that cannot find the
bean.

The question is: we need to have a bean to iterate? I cannot simple
iterate within the member variable?

Even if i have it declared on the bean (Datagrid) each row must be
defined with a column (parameter). For example... Column A has 1,2,3
and Column B has 1,4,5...


This is my action form:

public class DatagridForm extends ActionForm {


private List columns;




public List getColumns()
{
return columns;
}

public void setColumns(List cols)
{
columns =cols;
}
....

Ok...I don't have a rows property, but each Column (class) has a
getRows (Row class)... So.. on normal java i would loop it without
problems!

Ok... Any help would be great
Thanks
JF
 
R

Ryan Dillon

Hi JF,

Try changing the line:
<logic:iterate id="row" name="columns" property="rows">
to:
<logic:iterate id="row" name="column" property="rows">

I think that should do it?

Regards
 
J

jf

it worked... lol..

cannot believe this... well "name" is the class name..... that
transforms into a bean. Many thanks dude..

JF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top