Reputation: 1397
I have Map type. I want to iterate over it using struts tag library. now want to generate a token using { id + '_nav' } and set this token to id field of href.
Can You please help me out how to do that in struts?
The JSP Code :
<div class="box-heading">Quick Links</div>
<ul>
<s:set name="currentPage" value="currentNavigationPage"></s:set>
<s:iterator value="orderedSectionName_StartPageMap" >
<s:if test="%{#currentPage > key}">
<li><a id="{key + '_nav'}" href="#" ><s:property value="value"/></a></li>
</s:if>
<s:else>
<li><a href="#" ><s:property value="value"/></a></li>
</s:else>
</s:iterator>
</ul>
Can u please suggest me , how can i appen key from map with '_nav' token ? Thanks.
Upvotes: 0
Views: 3033
Reputation:
Try this,
<s:a id="%{key}__nav" href="#" ><s:property value="value"/></s:a>
instead of
<a id="%{#key}__nav" href="#" ><s:property value="value"/></a>
Upvotes: 0
Reputation: 23587
Not tested you can try something like
<s:iterator value="orderedSectionName_StartPageMap" var="mapObject" >
<s:if test="%{#currentPage > key}">
<li><a id="%{#key}__nav" href="#" ><s:property value="value"/></a></li>
</s:if>
<s:else>
<li><a href="#" ><s:property value="value"/></a></li>
</s:else>
</s:iterator>
or
<li><a id='%{#key+"__nav"}' href="#" ><s:property value="value"/></a></li>
Honestly i have not tested both of them myself
As update by the Zuned it will work with <s:propert>
also
<li><a id='<s:property value="key"/>' href="#" ><s:property value="value"/></a></li>
Upvotes: 1