File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Not getting contents of formbean Watch "Not getting contents of formbean New topic

Not getting contents of formbean's collection...

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186

I am developing web application using Struts1.1. Now following is my (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">
<td colspan="5">Your Shopping Cart is Empty!!!</td>
<logic:notEmpty name="viewcartForm" property="cartdata">
<td colspan='25' class=header width="100%" height=30>
<center><blink>Parts in your Shopping Cart </blink></center>

<table border="1" cellpadding="0" width="100%" bgcolor="#71B8FF"
bordercolor="#000000" cellspacing="1">
<logic:iterate name="viewcartForm" property="cartdata"
<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>

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.

********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:
subject: Not getting contents of formbean's collection...
It's not a secret anymore!