One challenge I'm facing involves a navigation bar with elements rendered using the Struts2 iterator
tag. Here is an example:
<ul>
<li><a href="#">Home</a></li>
<s:iterator var="row" value="#session.PrivMenu.children" status="stat">
<li>
<a href="#" rel="ddsubmenu<s:property value="#stat.index+1"/>">
<s:property value="#row.moduleName"/>
</a>
</li>
</s:iterator>
</ul>
My current task involves adding an individual icon to each <a>
element. Since each icon differs, unique styling is necessary for each <a>
tag.
How can I accomplish this in Struts2?
One idea I had was to utilize a dynamic cssClass
attribute.
cssClass = '<s:property value="#row.moduleName"/>' + icon
However, I am concerned that if the module name were to change, I would need to update the CSS class, too. Am I on the right track? Any alternative suggestions?