Logic:iterator reading from an array or collection

R

Robert Hornsby

Hi,
I am using the logic:iterator tag in a jsp using struct to output a
collection or an array of items. This works fine, however when the
user submits the form and I try to get the changed items the array
always come back null. I have tried this with array and collection
objects. Does anyone know why the collection is not getting
ititialized with the new data?

Thanks

My bean has the field

private FeaturedAuctions[] featuredAuctions;

and methods

public FeaturedAuctions[] getFeaturedAuctions()
{
return featuredAuctions;
}

public void setFeaturedAuctions( FeaturedAuctions[] featuredAuctions )
{
this.featuredAuctions = featuredAuctions;
}

The iterator sections of the jsp goes

<logic:iterate id="currentAuction"
name="adminFeaturedListForm" property="featuredAuctions">
<tr>
<td align="center" width="213">&nbsp;</td>
<td align="left" width="308"
class="bctext">&nbsp;</td>
</tr>
<tr>
<td width="470">
<table width="100%" border="1" cellspacing="0"
cellpadding="0" bordercolorlight="#99CCFF" bordercolordark="#99CCFF">
<tr>
<td>
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td align="center" width="213"
onClick="openImageDialog('<bean:write name="currentAuction"
property="bcSerialNo"/>','<bean:write name="currentAuction"
property="imageNames"/>', txt<bean:write name="currentAuction"
property="bcSerialNo"/>, <bean:write name="currentAuction"
property="bcSerialNo"/>, featuredBox, description<bean:write
name="currentAuction" property="bcSerialNo"/>,
txtDescription<bean:write name="currentAuction"
property="bcSerialNo"/>);"><span id="<bean:write name="currentAuction"
property="bcSerialNo"/>"><img src="<bean:write name="currentAuction"
property="imageUrl"/>"></span></td>
<td align="left" width="80%" class="bctext">
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr width="100%">
<td class="bcbtext"
width="100%">
<bean:write
name="currentAuction" property="make"/>&nbsp;<bean:write
name="currentAuction" property="model"/>&nbsp;<bean:write
name="currentAuction" property="year"/>,Category<bean:write
name="currentAuction" property="category"/>
</td>
</tr>
<tr width="100%">
<td class="bctext" width="100%"><b>Description : </b><span
id="description<bean:write name="currentAuction"
property="bcSerialNo"/>"><bean:write name="currentAuction"
property="vehicledescription"/></span></td>
</tr>
<tr width="100%">
<td class="bctext" width="100%"><b>Location :</b>
<bean:write name="currentAuction" property="location"/></td>
</tr>
<tr width="100%">
<td class="bctext" width="100%">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td align="center" width="82">
<input type="hidden" name="txtDescription<bean:write
name="currentAuction" property="bcSerialNo"/>" value="<bean:write
name="currentAuction" property="vehicledescription"/>">
<input type="hidden" name="txt<bean:write
name="currentAuction" property="bcSerialNo"/>" value="<bean:write
name="currentAuction" property="firstImage"/>">
<html:multibox property="featuredBox"><bean:write
name="currentAuction" property="bcSerialNo"/></html:multibox></td>
</tr>
</logic:iterate>

thanks for any help you can offer

Robert Hornsby
 
S

Sebastian Millies

Robert Hornsby said:
Hi,
I am using the logic:iterator tag in a jsp using struct to output a
collection or an array of items. This works fine, however when the
user submits the form and I try to get the changed items the array
always come back null. I have tried this with array and collection
objects. Does anyone know why the collection is not getting
ititialized with the new data?

Thanks

My bean has the field

private FeaturedAuctions[] featuredAuctions;

and methods

public FeaturedAuctions[] getFeaturedAuctions()
{
return featuredAuctions;
}

public void setFeaturedAuctions( FeaturedAuctions[] featuredAuctions )
{
this.featuredAuctions = featuredAuctions;
}

The iterator sections of the jsp goes

<logic:iterate id="currentAuction"

[.. stuff deleted]
name="adminFeaturedListForm" property="featuredAuctions">
<input type="hidden" name="txtDescription<bean:write
name="currentAuction" property="bcSerialNo"/>" value="<bean:write
name="currentAuction" property="vehicledescription"/>">
<input type="hidden" name="txt<bean:write
name="currentAuction" property="bcSerialNo"/>" value="<bean:write
name="currentAuction" property="firstImage"/>">
<html:multibox property="featuredBox"><bean:write
name="currentAuction" property="bcSerialNo"/></html:multibox></td>
</tr>
</logic:iterate>

thanks for any help you can offer

Robert Hornsby

I guess you'd need to address the form using an indexed property in your
input fields,
and provide indexed getters and setters.

Does your code above actually compile? It seems to contain nested quotes.

-- Sebastian
 
S

steph

It sounds like a problem of scope:

I gess your form must be in the session scope.

Am I right ? ...

Le 24/09/2004 10:50, Robert Hornsby a &eacute;crit :
Hi,
I am using the logic:iterator tag in a jsp using struct to output a
collection or an array of items. This works fine, however when the
user submits the form and I try to get the changed items the array
always come back null. I have tried this with array and collection
objects. Does anyone know why the collection is not getting
ititialized with the new data?

Thanks

My bean has the field

private FeaturedAuctions[] featuredAuctions;

and methods

public FeaturedAuctions[] getFeaturedAuctions()
{
return featuredAuctions;
}

public void setFeaturedAuctions( FeaturedAuctions[] featuredAuctions )
{
this.featuredAuctions = featuredAuctions;
}

The iterator sections of the jsp goes

<logic:iterate id="currentAuction"
name="adminFeaturedListForm" property="featuredAuctions">
<tr>
<td align="center" width="213">&nbsp;</td>
<td align="left" width="308"
class="bctext">&nbsp;</td>
</tr>
<tr>
<td width="470">
<table width="100%" border="1" cellspacing="0"
cellpadding="0" bordercolorlight="#99CCFF" bordercolordark="#99CCFF">
<tr>
<td>
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td align="center" width="213"
onClick="openImageDialog('<bean:write name="currentAuction"
property="bcSerialNo"/>','<bean:write name="currentAuction"
property="imageNames"/>', txt<bean:write name="currentAuction"
property="bcSerialNo"/>, <bean:write name="currentAuction"
property="bcSerialNo"/>, featuredBox, description<bean:write
name="currentAuction" property="bcSerialNo"/>,
txtDescription<bean:write name="currentAuction"
property="bcSerialNo"/>);"><span id="<bean:write name="currentAuction"
property="bcSerialNo"/>"><img src="<bean:write name="currentAuction"
property="imageUrl"/>"></span></td>
<td align="left" width="80%" class="bctext">
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr width="100%">
<td class="bcbtext"
width="100%">
<bean:write
name="currentAuction" property="make"/>&nbsp;<bean:write
name="currentAuction" property="model"/>&nbsp;<bean:write
name="currentAuction" property="year"/>,Category<bean:write
name="currentAuction" property="category"/>
</td>
</tr>
<tr width="100%">
<td class="bctext" width="100%"><b>Description : </b><span
id="description<bean:write name="currentAuction"
property="bcSerialNo"/>"><bean:write name="currentAuction"
property="vehicledescription"/></span></td>
</tr>
<tr width="100%">
<td class="bctext" width="100%"><b>Location :</b>
<bean:write name="currentAuction" property="location"/></td>
</tr>
<tr width="100%">
<td class="bctext" width="100%">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td align="center" width="82">
<input type="hidden" name="txtDescription<bean:write
name="currentAuction" property="bcSerialNo"/>" value="<bean:write
name="currentAuction" property="vehicledescription"/>">
<input type="hidden" name="txt<bean:write
name="currentAuction" property="bcSerialNo"/>" value="<bean:write
name="currentAuction" property="firstImage"/>">
<html:multibox property="featuredBox"><bean:write
name="currentAuction" property="bcSerialNo"/></html:multibox></td>
</tr>
</logic:iterate>

thanks for any help you can offer

Robert Hornsby
 
S

Sudsy

Robert said:
Hi,
I am using the logic:iterator tag in a jsp using struct to output a
collection or an array of items. This works fine, however when the
user submits the form and I try to get the changed items the array
always come back null. I have tried this with array and collection
objects. Does anyone know why the collection is not getting
ititialized with the new data?

Sebastian is right: you need to use indexed properties. See
<http://www.sudsy.net/technology/struts-advanced.html>
 

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