简体   繁体   中英

tree structure in view file

I am facing an issue while displaying a collection in my jsp,the collection contains data something like Collection(col1,col2...) col1 is having name,value,iconname etc. Now the requirement is that for 2 particular object i have to make 3 object child just for display purpose(these three objects are also coming in collection).I am having a field level in DB withh value 1 and 2 so i want to display it something like

col1
col2
col3
 *col4
 *col5
 *col6
col7... and so on. .

any guesses

Split the problem.

First create a java method that takes the initial collection and returns the tree. That allows you to write unit tests for it until you get it right.

Afterwards, modify the JSP to render the new tree structure.

If you already know which 2 objects are having child nodes, you can use jstl c:if tag and check for the condition, and based on condition render them as a child elements.

Otherwise, it would be advisable as Aaron said, to create backing javabean and use it within your jsp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM