Hi Victor

There is kind of a limitation with handling index property at the moment.
But you can get around it by writing a simple counter code into the JSP page
(should be fixed in STRUTS 1.1).

I would suggest the following

1) A form bean and make Order an attribute of the form bean (ie include the
getOrder() and setOrder() methods).

I would change your orderdetail class to use...

public class OrderDetail implments Serializable {
  private java.util.Arraylist orderlines=new java.util.Arraylist();
        public java.util.Arraylist getOrderlines(){...}
        public void set setOrderlines(java.util.Arraylist orderlines){...}
  //other attributes and methods
}

In your JSP page use the iterate tag to access your formbean's
order.orderDetail.orderlines, cast it to be of type OrderLineDetail (you
will need to put in a fully qualified package name eg
org.victor.OrderLineDetail). Now you can access all the attributes of
OrderLineDetail inside your iterate loop.

Regards

Michael Mok
www.webappcabaret.com/normad


-----Original Message-----
From: Victor Chai [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 12 June 2001 16:09
To: [EMAIL PROTECTED]
Subject: Handling nested properties


Hi,

I have been working on struts a few days ago, I have
been trying to develop ordering system using struts.

I already have four Java Bean to represent an Order,
which contains OrderHeader and OrderDetail, and within
OrderDetail there will be collection of
OrderLineDetail, pls refer to below for detail,


public class Order implements Serializable {
  private OrderHeader=null;
  private OrderDetail=null;
  //other attributes and methods
}

public class OrderHeader implements Serializable {

//attributes and methods
}

public class OrderDetail implments Serializable {
  private OrderLineDetail[] orderlines=new
Hashtable();
  //other attributes and methods
}

public class OrderLineDetail implements Serializable {
  //methods and attributes

}

Based on the above design, how will it fit into struts
framework?

I have been trying to use <logic:iterate>, seems that
it won't work.

Hope some expert can throw some light on me.

thanks!



__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send dad a Father's Day Card!
http://greetings.yahoo.com.sg/

Reply via email to