This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Displaying the fields in an order  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Displaying the fields in an order  " Watch "Displaying the fields in an order  " New topic
Author

Displaying the fields in an order

Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 136
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

Joined: Oct 29, 2001
Posts: 8843
    
    7

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):




"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 136
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

Joined: Oct 29, 2001
Posts: 8843
    
    7

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

Joined: Aug 20, 2010
Posts: 23
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

Joined: Jan 24, 2011
Posts: 136
Could you please provide me with an example?
 
Consider Paul's rocket mass heater.
 
subject: Displaying the fields in an order
 
Similar Threads
Jsp Array Iteration
How to pass data from selected rows using checkboxes from JSP to the server
JSP column name hyperlink help
javascript error: object expected
dynamic text box value into database