• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not getting contents of formbean's collection...

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic