Hi Oscar,
That was a helpful idea, thanks! But I still think AppFuse should be able to
handle this scenario with just standard configurations in menu-config.xml. I
think ROLE_ANONYMOUS should work the same way ROLE_USER and ROLE_ADMIN do in
menu-config.xml to prevent hacking in menu.jsp but...
Let me describe how I implemented it in case someone else needs it or want
to point me a better approach:
1. I added a method to class UserUtil named isAdmin which returns true it
the logged user has the ROLE_ADMIN role;
2. In menu.jsp I added a call to this method and conditions to present
certain menu items only if isAdmin if false, like the following example:
<%
boolean isAdmin = com.myproject.util.UserUtil.isAdmin();
if (!isAdmin) {
%>
<menu:displayMenu name="ProductMenu"/>
<menu:displayMenu name="ShoppingCart"/>
<%
}
%>
After that it worked fine.
oscar perez wrote:
>
> How about doing it programmatically in menu.jsp in the same fashion the
> logout link is done?
>
> <c:when test="${pageContext.request.remoteUser ....
>
>
>
> On Thu, Jul 10, 2008 at 9:40 PM, pedro_burglin <[EMAIL PROTECTED]>
> wrote:
>
>>
>> Hi All,
>>
>> I am using AppFuse 2.0.2, JSF archetype, full source.
>>
>> I am having trouble hiding a menu item from ROLE_ADMIN users.
>>
>> I have this entry in my menu-config.xml:
>>
>> <Menu name="ProductMenu" title="productList.title" page="products.html"
>> />
>>
>> Which makes this menu item to appear to all roles, even anonymous users.
>> I
>> need to hide it only from users with role ROLE_ADMIN. I then modified
>> this
>> line so it looks like this:
>>
>> <Menu name="ProductMenu" title="productList.title" page="products.html"
>> roles="anonymous,ROLE_ANONYMOUS,ROLE_USER"/>
>>
>> And now it hides the item from the admin user AND the anonymous
>> non-logged
>> user too. When I log in with a regular non-admin user (member of
>> ROLE_USER)
>> the menu item shows up fine. The question is, how can I keep it hidden
>> from
>> ROLE_ADMIN users AND present it to anonymous users?
>>
>> I looked for a similar question in the forum and found few entries. The
>> most
>> promissing was this one here
>> (
>> http://www.nabble.com/menu-config.xml-show-hide-menu-item-with-roles-td12336948s2369.html#a12337790
>> )
>> but that did not solve the problem.
>>
>> Any help in the right direction is greatly appreciated,
>> Pedro Burglin
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-hide-menu-items-only-for-ROLE_ADMIN-users-tp18389212s2369p18389212.html
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/how-to-hide-menu-items-only-for-ROLE_ADMIN-users-tp18389212s2369p18449740.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]