• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display data using Structs Tag

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to show some data in Jsp using structs tag.
My data is in ArrayList which contains number of ArrayLists.

ArrayList table = new ArrayList();

for(int i=0;....)
{
ArrayList row = new ArrayList ();
row.add(i);
row.add("ID "+i);
table.add(row)
}

Here I had the entire data in ArrayList 'table '
How can I display it in JSP. What should I give for property = ???



<logic:iterate id="row" name="table">
<tr>

<td><bean:write name="row" property="???"/></td>

</tr>
</logic:iterate>


Thanks in Advance.
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The output would look like this:


If this doesn't work, post the results because I didn't test this at all.
 
Jobin Mathew
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, This is working.

But for the first value of inner ArrayList, I need to draw a check box.
anf for rest of all, I want to display the values. So in the inner loop (iterate), i need to distinguish between first iteration & the next iterations. How can I do this?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to answer this question, we'd need to know what the checkbox represents. Is it a single boolean value for each row? or do you want to store an array of values, with each checked box representing one item in the array?
 
Dom Lassy
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to me like you should be using a list of objects instead of a list of lists where you conditionally display a checkbox based on the index of the inner loop.
 
Jobin Mathew
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey not like that.

Lst us see the arrayList
[ [1,ABC,18], [2,TRE,20], [5,REYT,30] ]

Here I want to draw checkboxes with values 1,2,5

And need to display other values. Like

Select Name Age
==============================
ckbx value=1 ABC 18
ckbx value=2 TRE 20
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Dom that it would be better to have a list of Objects. For example, suppose you create a class called Customer with properties customerNumber, name, and age. Your Actionform would then have a property called customers of type Customer[].

Then in your JSP, your code would look like this:



Note that your ActionForm will have a property named selectedCustomers of type String[].
 
Jobin Mathew
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I am not iterating a DTO class.

I ma iterating a ArraList that contains many ArrayList.
Look this

ArrayList table = new ArrayList();
for(int i=0;....)
{
ArrayList row = new ArrayList ();
row.add(i);
row.add("ID "+i);
table.add(row)
}



So I need identify the first iteration.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic