The writeMenu macro has the extra call to check the user roles:
#if ($topMenu.isUserInRoles() || $topMenu.isUserInChildMenuRoles())
where the sample application has removed this line

So I dug a little further to see why the use of my own AccessController was not getting called, and found the Menu.isUserInRoles() method returns false when no roles have been defined in menu.xml. The below for loop does nothing and so the method returns false:

public boolean isUserInRoles() {
if (getAccessController() == null) {
String msg = "Menu accessController has not been defined";
throw new IllegalStateException(msg);
}

HttpServletRequest request = getContext().getRequest();

for (int i = 0, size = getRoles().size(); i < size; i++) {
String rolename = getRoles().get(i);
if (getAccessController().hasAccess(request, rolename)) {
return true;
}
}

return false;
}

This is all expected behavior, my bad. Just one of those scenarios where you spend a lot of time finding out the state of your settings is out-of-sync. The combination of having role checking active without defining any roles on each menu item quietly suppresses the entire menu. Maybe this method could/should throw an exception if called when getRoles().size() == 0 ? Not sure if this would be undesirable but it would alert a user the menu item will never be accessed.

thanks…Roy




On 15/10/2010 09:41, Bob Schellink wrote:
Hi Roy,

I assume you ran the quickstart and use the macro.vm it produced? Do you have 
any roles defined in
your menu.xml?

The macro.vm uses code like this:
#if ($topMenu.isUserInRoles() || $topMenu.isUserInChildMenuRoles())

This code basically asks the menu if the currently logged in user is allowed to 
view the menu.
However if the menu doesn't have any roles, this method returns false.

You can customize the macro and add this check:]
#if ($topMenu.isUserInRoles() || $topMenu.isUserInChildMenuRoles()) || 
!$topMenu.hasRoles())


This change basically says: if no menu role is defined, show the menu as well.

In Click 2.2.0 you can render menus without a macro too. Just do:

$rootMenu

Wrt to activity, there is daily commits to trunk. You can get a better feel 
looking at the nightly
builds:

https://hudson.apache.org/hudson/view/Click/job/Click/
https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/roadmap-changes.html

You can also use the FishEye tool to view svn activity amongst other things:
https://fisheye6.atlassian.com/changelog/click/?max=30&view=all&@asv=all

I'll update the website over the weekend and change the June date to October. 
Over the years we've
tried to indicate the next release date, but I've found it's quite difficult to 
meet those dates
since open source is generally developed when people have an itch to scratch or 
feel inspired.
Perhaps we shouldn't give any indication of the next release lest we give the 
wrong impression of an
inactive project :)

Kind regards

Bob



On 15/10/2010 16:29, Roy Bailey wrote:
  Yes, the standard sample velocity macro is getting called, so the rootMenu 
object has been added
and from java code I can see entire menu.

thanks...Roy


On 14/10/2010 23:30, Malcolm Edgar wrote:
Hi Roy,

I think the main drivers very much have their heads down doing work. With the 
Menu control often
the rendering is done via a velocity macro. How is it done in your application?

regards Malcolm Edgar

On Fri, Oct 15, 2010 at 5:18 AM, Roy 
Bailey<[email protected]<mailto:[email protected]>>  wrote:

      Hi,

     I've been playing around with sample click app that used basic menu and 
Tomcat security model.
      Very impressed and pleased with the speed and simplicity I've been able 
to put something
     useful together, including the use of PagingDataProvider for large 
datasets and easy
     form/navigation.

     Now I'm ready to show my employer and I need to take out the security 
model so I can put a
     custom model in place.  Having taken out the security-constraint, 
login-config and
     security-role elements from web.xml I no longer get the menu rendered.  
I've checked
     everywhere but cannot seem to get the menu to render, even though the 
#if($rootMenu) condition
     is true and from debug I can see the menu object in java has all children 
etc.  The sample
     does not have security on but doesn't seem to do anything different, 
though the menu is shown.
      Any ideas where I need to look?  I just get blank bar, like the root menu 
was empty?  I've
     even given my own AccessController that simply returns true for all 
requests, but this is
     never called.

     One other concern is the lack of updated information on main site.  It 
still states June for
     v2.3 and the low volume of traffic here and activity on the project raises 
the question of
     whether the framework will be supported and continue to be evolved.  Have 
the main drivers of
     this project moved on? or just busy with every intention to continue this 
project?

     Great work, take my hat off to those involved, appreciate any help and 
comments on above.

     thanks...Roy



Reply via email to