I need to develop a tree to display the hierarchy of categories on a retail site. For example
-Clothing
- Men
- Trousers
- Shirts
- Women
I’m working on struts and using the struts dojo plugin to use this tag :
<sx:tree id="root" label="Category">
For the other child nodes, the data is stored in a database. If I use
.......
while( rs.next())
{
%>
<sx:tree id="child1" label ="<%=rs.getString("Category")%>" />
<%
}
......
the compiler tells me that expressions can’t be used as value for the label attribute.
Can anyone suggest a workaround or any alternative for this?
I’m not too familiar with Struts 2, but looking at the documentation does the following work:
That being said, it is probably a better idea to iterate over the result set and create a collection based off of it in Java code and have the JSP iterate over that collection instead of the result set. The code would end up being cleaner.