• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Displaying the fields in an order

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a requirement where i need to display the fields in a 2 column layout like left to right and these fields are displayed dynamically. I am using struts , here tiles wont work as the fields are dynamic in nature as well <c:forEach> and <logic:iterate> wont work either as they are used to display the 1 field at a time and will be displayed sequentially, which is one after another. Hence i need to use the while or for loop in the JSP with scriplet to do it.

Something like :-

This will allow me display the fields in the left to right manner,but i dont wnat to use scriplet , is there the same can be done using <c:forEach> or <logic:iterate> or we whether we can use a custom tag to do it? please shed some light into it.

thanks

JCE: please use code tags
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand what you are asking, you can use nested iterator tags (the example below has a List of line item objects, each of which has an ID field and a List of fields):



 
Rithanya Laxmi
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, the problem is not with displaying the data , but how ro display the fields in 2 columns layout (left to right)
like

Name: hjgfjgfjg Age : 23
Contact: iiii Address : 67 street

I am not using struts2 and i am using struts1.1 , whether the same code which i have send can be rewritten with logic:iterate with indexId?
Please let me know your opinion.

thanks.

 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rithanya Laxmi wrote:
I am not using struts2 and i am using struts1.1



That's why we ask you at the top of the page to indicate which version you're using Struts 1.1 has been unsupported for what, 6 years now?
As for making columns, you can surround the Struts tags with regular HTML TR's and TD's. I haven't worked with Struts 1.x in a while, so I can't recall exactly how to do it.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

One solution can be:

You can iterate the collection for twice, once for the first column details ie.
Name : XYZ
City : XYZQW

and the second iteration for the other column info.

Basically, you have to go for even sequence once and then for odd sequence.



Thanks,

Sriram
 
Rithanya Laxmi
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please provide me with an example?
 
And inside of my fortune cookie was this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic