I am creating a menu and for each menu component, I have a specific id:
<li id="ll1"><a href="javascript:{}" id="al1">Component</a></li>
Retrieving the components from the DB, I used the iterator tag to display them dynamically:
<s:iterator value="#session.loggedinUser.compNames" status="statusObject" var="parent">
<s:if test="#session.loggedinUser.compAccess[#statusObject.index] == 0">
<li id="ll<s:property value="#statusObject.index"/>">
<a href="javascript:{}" id="al<s:property value="#statusObject.index"/>" onclick="menuBar('none')">
<s:property value="#parent"/>
</a>
</li>
</s:if>
The iterator works as I want it to and the menu list is generated perfectly. However, it starts at List id = 0, as such:
<li id="ll0"><a href="javascript:{}" id="al0" onclick="menuBar('Component')">Component</a>
Is there any way to start list id assignation at 1 while keeping the initial reading index of my iterator list at 0? (I don’t want to lose the first value in my list!)
If I have confused you anywhere, please ask for clarification.
Thanks!
You mean
<s:property value="#statusObject.index + 1"/>instead of<s:property value="#statusObject.index"/>If this is the case… you might want to give http://commons.apache.org/ognl/language-guide.html a quick scan. Struts2 uses OGNL as the EL, usually… If you want the list to come back differently then you’ll need to use JS to modify the parameters before you submit.