Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterator

 
sudhir pavan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have problem in displaying two list values in jsp using struts.

I have two list values

list 1

no name
1 ss
2 dd

list 2

no product name
1 mine ss
2 temp ss
3 disk dd

using iterator i need to display the elements in the below format

name ss
count 2

1 mine
2 temp

name dd
count 1

1 disk
 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even I had the same problem.
Just have a look at the thread : How can I call the Action class inside <logic:iterator> tag in struts 1.3

If you write a code as follows:

If an action could be fired in line 2 then it performs the business logic and retrieves each 'product' from List2 object with 'name' passed as request parameter.

But this is not possible with struts1(As I was informed in the forum).


 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The other way is to use an array of List. Sort of 2D array. List2 in your case.

The first row will contain two List2 objects(i.e [1,mine,ss] and [2,temp,ss]).
The second row will contain one List2 object(i.e [3,disk,dd]) and so on.

Try this and tell me if it works.
Also visit my thread and comment on it as somebody has tried his best to help me.
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the data structure being used has a problem.
I would actually prefer to have something like below

Category List (ss/dd)
|
|->(each category has a) Product List (mine/temp/disk)

Anybody to oppose?
Also see if the database has integrity constraint for these two tables. If yes, there should be a definite problem!!


Anyways,


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic