This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes Not getting contents of formbean's collection... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Not getting contents of formbean Watch "Not getting contents of formbean New topic
Author

Not getting contents of formbean's collection...

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
hi,

I am developing web application using Struts1.1. Now following is my ViewCartForm.java (formbean)file.
=========================
public class ViewcartForm extends ActionForm {
/** cartsessiondata property */
private CartSessionData[] cartdata=new CartSessionData[0];

public CartSessionData[] getCartdata() {
return cartdata;
}
public void setCartdata(CartSessionData[] cartdata) {
this.cartdata = cartdata;
}

}
========================

& this is content of my Viewcart.jsp file:-
==================
<logic:empty name="viewcartForm" property="cartdata">
<tr>
<td colspan="5">Your Shopping Cart is Empty!!!</td>
</tr>
</logic:empty>
<logic:notEmpty name="viewcartForm" property="cartdata">
<tr>
<td colspan='25' class=header width="100%" height=30>
<center><blink>Parts in your Shopping Cart </blink></center>
</td>
</tr>
<tr>
<td>

<table border="1" cellpadding="0" width="100%" bgcolor="#71B8FF"
bordercolor="#000000" cellspacing="1">
<tbody>
<logic:iterate name="viewcartForm" property="cartdata"
id="partsincart">
<tr>
<td colspan="2" class=darkodd>    Part ID:</td>
<td colspan="2" class=darkodd> <bean:write
name="partsincart" property="partid" /></td>
<td colspan="2" class=darkodd> <bean:write
name="partsincart" property="partdesc" /></td>
</tr>
</logic:iterate>
</table>
</td>
</tr>
</logic:notEmpty>
=================

In The above jsp file I am not able to get any of the parts from my "cartsdata" collection inside my form bean.
What is problem here?
When I am executing viewcart.jsp file i am just getting the header inside <logic:notempty......> tag , i.e, I am just getting output "Parts in your Shopping Cart" on my jsp file. Rest I can't see. Whare I am wrong? PLease tell me.
Thanx in Advance.
Prash.


********Deserve Before You Desire********
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I do not recall using the empty tags with arrays. Looking at the documentation, it just mentions null objects, empty strings and empty Collections. Since your class initializes your array, I am wondering if your array is actually empty but you get the notEmpty output because the array is not null.

If you are using and IDE with a debugger, you can try setting a breakpoint on the getCartdata method to see what it is returning.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not getting contents of formbean's collection...