I�m having problems populating the data into a JavaBean nested inside an ActionForm.
The form bean:
The �Customer� JavaBean:
I can access these fields in my JSP pages fine (using struts nested tags), but how do I populate the �customerNumber� via the �CustomerForm� � this is probably quite simple, but it is totally evading me!
My submit function looks like:
The Action Class looks like:
I can display the �select� button fine, along with the customer numbers, addresses etc, but I want to pass the customerNumber into the next form; all my attempts show the �CustomerForm to be null, but I can see the customerNumber in the parameter printout:
First of all, your CustomerForm must Extend ActionForm if you expect Struts to populate it.
Secondly, this page obviously displays a number of customers on a single page. This is fine for output only, but when you want to input customer data from one or more of the customers, you must tell struts which customer you're working with. As you've coded it now, there's no way of telling.
I'd suggest reading this link on using indexed properties in Struts. By following the principles it outlines, you will hopefully be able to reconstruct your CustomerForm bean to handle multiple customers, and code the JSP to tell which customer you're operating on at any given time.
Try refactoring your application to conform to the principles in the link, and if you still have problems, let us know, and we'll help you solve the problems.
Also, Property names should always start with a lower-case letter, so "Customer.xxxx" is not going to work. It has to be "customer.xxxx"
One other note: When you're first starting to use indexed properties, it's much easier to put your ActionForm in session scope. As you get more used to them, you can try putting them in request scope and using "lazy initialization" to recreate the list of beans. [ June 12, 2006: Message edited by: Merrill Higginson ]