I found a solution. Create more than one role, a list per system role. And when I will go to render the page I can use the Acegi taglib depending on which list I'm rendering.
if auth = roleA
forEach
render menu here
endif
if auth = roleB
forEach
render menu here
endif
I think the best solution for my problem is as following:
Code:
<c:forEach items="${tabList}" var="item">
<!--
unless item.link is the same as 'selected',
menu class is the default class (inherits CSS from elsewhere)
-->
<c:set var="menuClass" value=""/>
<c:if test="${item.link eq selected}">
<c:set var="menuClass" value="itemSelected"/>
</c:if>
<authz:authorize ifAnyGranted="${item.roles}">
<li class="${menuClass}">
<a href="${item.link}">
<img src="<c:url value="${item.icon}"/>" width="25" height="25"
class="navicon" alt="${item.tooltip}" />
${item.value}
</a>
</li>
</authz:authorize>
</c:forEach>
Then, create a class that implements MenuItem interface and add the new attribute "roles" to set up wich roles can see the content.
Also, its necessary change the template definition in the tiles configuration file.
Code:
<item value="Tab 1" tooltip="Tab 1 Tooltip" link="tab1.do" icon="/images/permission.gif" classtype="org.apache.struts.tiles.beans.SimpleMenuItem"/>
to
Code:
<bean classtype="tiles.RoleMenuItem" >
<set-property property="value" value="Clients"/>
<set-property property="tooltip" value="Clients"/>
<set-property property="link" value="list_clients.do"/>
<set-property property="icon" value="/images/client.png"/>
<set-property property="roles" value="ROLE_SALES_ACCT,ROLE_SYSTEM_ADMIN"/>
</bean>