• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding objects to the list  RSS feed

 
Asrita Saran
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I am trying to add objects to a list

Please have a look at this code..







I added sanctionOrDeclineWaiver object to sanctionedOrDeclinedWaiverList and printed it immediately.
It printed both the objects correctly after adding to the list but on the UI i'm getting the object which was added first twice..
I dont understand why this is happening

This is the result im getting on UI

PartyId CaseId WaiverId OrganizationName Evidence Type Waiver Status Reason
11761091 12 748 test13 Request Open sdf
11761091 12 748 test13 Request Open sdf


Can anyone please help me out .
 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure how this code will work. It wont go into the loop since you are creating new instance of sanctionOrDeclineWaiverList() just above the loop.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you are printing it twice ! Hoe are you printing it on console ?
 
Asrita Saran
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops..sorry..I have commented that line..
SanctionOrDeclineWaiverList has some values. and the code in loop will be executed.

The problem i am facing is ,lets suppose we are adding values 'a' and 'b' to the list sanctionedOrDeclinesWaiversList,only 'a' is dispaying twice on the UI.But when I try to print immediately after adding to the list both a and b are printing correctly.

I am printing on the console with this statement immedaitely after adding in the loop:

System.out.println("GET values from the list======="+ "+sanctionedOrDeclinedWaiversList.get(i).getSanctionOrDeclineWaiver());
[ September 19, 2008: Message edited by: Asrita Saran ]
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give full details; it just serves to confuse if you comment lines out, and don't show how you are printing.
After adding one, get the size() of the List printed out.

And why are you declaring parameterised Lists and using raw types?
 
Asrita Saran
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the actual code I am using



When I am printing the list size it is displaying the list size correctly depending upon the no.of items I selected.
Values added to the list are also printed correctly in the console.

But on the UI I am getting the only the details of the object I have added first repeatedly depending upon sanctionOrDeclineWaiverList size.
If the size of list is 2,then same object is printed twice like

a 200 Hat
a 200 Hat


Here I have to add to list of type List<SanctionedOrDeclinedWaivers> to get the result visible on UI.
[ September 19, 2008: Message edited by: Asrita Saran ]
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Asrita Saran:

But on the UI I am getting the only the details of the object I have added first repeatedly depending upon sanctionOrDeclineWaiverList size.


Can you post that same code which you are using to print the List values on UI ?
 
Asrita Saran
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not using any other code to display reults on UI.
As soon as the object is added to sanctionOrDeclineWaiverList (like sanctionOrDeclineWaiverList.add(i,sanctionOrDeclineWaiver) )the result will be displayed on UI.
[ September 19, 2008: Message edited by: Asrita Saran ]
 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't seem possible with the kind of code that you have pasted. When iterating through the UI you probably arent incrementing the counter.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Asrita Saran:
This is the actual code I am using





Have you tried simply adding object to List as ,

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!