I don't use it, but the struts-menu add on may do what you want.

      http://struts-menu.sourceforge.net/

Otherwise, the ModuleConfig class has a method findActionConfigs() which
returns an array of ActionConfig elements. In an Action you can get the
ModuleConfig from the ActionMapping. From ActionConfig you can get the path
and the role names associated.

Something like:

      ModuleConfig moduleConfig = mapping.getModuleConfig();
      ActionConfig[] actionConfigs = moduleConfig.findActionConfigs();
      for (int i = 0; i < actionConfigs .length; i++) {
         String path = actionConfigs[i].getPath();
         String[] roleNames = actionsConfigs[i].getRoleNames();
         boolean accessAllowed = false;
         for (int j = 0; j < roleNames.length; j++) {
            if (request.isUserInRole(roleNames[j])
               accessAllowed = true;
         }

      }

Niall

----- Original Message ----- 
From: "Frank Seaton Taylor" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, March 08, 2004 4:11 PM
Subject: roles filtered list of actions


> Good day all,
>
> I'm a three month old web developer and have been trying to figure out
> how to do something described below. I've read a bunch of documentation
> and searched mailing lists and the web for answers, but fear that my
> inexperience is hampering me in that my tenuous grasp of this new
> vocabulary might mislead me when what I'm reading contains the answer I
> seek, but I don't comprehend it. Here's a stab at describing my goal:
>
> In our struts-config.xml we have a number of actions which have roles
> attributes. I would like to produce a table of links that initiate
> those actions, but with some restrictions. It should only be actions
> whose path has a certain form. (Specifically, I need to produce a list
> of actions whose paths begin with a certain string.) In addition, only
> those actions whose roles are valid with the current user should be
> included. The fact that we use a custom
> RequestProcessor.processRoles(...) may complicate matters, but I hope
> that it doesn't.
>
> My naive plan of attack is that since struts-config.xml is parsed and
> stored somewhere that I ought to be able to access it's information,
> loop through the actions and easily restrict that list to those whose
> path matches a certain form. I'll less clear on weeding out the actions
> whose roles apply, (What arguments would I need to
> RequestProcessor.processRoles(...)?) but that might be clearer if I
> knew the data structures that store struts-config.xml.
>
> Is this a reasonable approach? If not, how about some other ideas? If
> so, could someone point me to the data structures that store
> struts-config.xml?
>
> Thanks for your consideration,
> ---Frank
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to