Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Didier Varon
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic