File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How can I create objects dynamically in a jsp and put them in a collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How can I create objects dynamically in a jsp and put them in a collection" Watch "How can I create objects dynamically in a jsp and put them in a collection" New topic
Author

How can I create objects dynamically in a jsp and put them in a collection

Didier Varon
Greenhorn

Joined: Jul 14, 2005
Posts: 23
I have a jsp to create Department objects and I need to put them inside a Collection, those Department objects need to be created dynamically in the jsp, I have been able to create one Department object, but I am clueless on how to create more of these objects and how to put them in a collection. Here is the code:

createDepartment.jsp:


Here is the javaScript that create the input tag for the new Department object:


And the action this page goes is:


The List deptos always has a null entry, what I want is to be able to create as many Depto objects as the users needs and store them in the List Deptos. Is it possible to do so?

Thank you.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't know YUI, but from here it looks like you're adding child nodes to a hidden input tag?!

If you just have input fields named "deptos" it'll populate a list.
Didier Varon
Greenhorn

Joined: Jul 14, 2005
Posts: 23
Dave, thanks for your answer, in the code that I posted I was trying that, since the other ideas that I had did not work.

First I tried:
same Action:

in the jsp:

but threw an exception since List does not have a method depto, then I tried:


but the List deptos is empty.

I have populated collections of Strings before, but I am clueless on how to populate a Collection of objects.

The yui code that I have is that when an image is dropped into a workArea node then a new Depto object should be created and added to the deptos List.

Thank you again for your time and help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I create objects dynamically in a jsp and put them in a collection