Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying the fields in an order

 
Rithanya Laxmi
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • 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
 
Joe Ess
Bartender
Posts: 9300
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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: 185
  • Mark post as helpful
  • send pies
  • 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: 9300
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Sriram Ture
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please provide me with an example?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic