I'm just throwng this out there but, is this something that could be solved a little easier with annotations? I just got my Thinking in Java (4th ed) recently, so don't hate on me. Peace
On 3/24/06, Brantley Hobbs <[EMAIL PROTECTED]> wrote: > > > At runtime I need to get a list of /all/ the actions that are > defined in > > > Struts. I'd rather not extract them directly from the conf file(s) > > > unless it's absolutely necessary, but I don't (readily) see an API > for > > > doing this so I might be forced into it. > > > > > > > It seems a bit difficult but... It seems that ModuleConfigImpl has a > > list of ActionConfig, that is what you need. > > The problem is that only ActionServlet can access to ModuleConfig. But > > you have to subclass ModuleConfigImpl to get the actionConfigList > field, > > because it seems that there is no getter method. > > I hope this is a good hint. > > Ciao > > Antonio > > This hint pointed me in the right direction. In case anyone is > interested, this is how I did it: > > - Subclass ActionServlet > - Override process() > - Inside process, add the following code: > > if(this.getServletContext().getAttribute("actionList") == null) { > String actionList = new String(); > ModuleConfig theConfig = this.getModuleConfig(request); > > ActionConfig[] actionConfigurations = > theConfig.findActionConfigs(); > > for(int i = 0; i < actionConfigurations.length; i++) { > ActionConfig thisAction = actionConfigurations[i]; > actionList += thisAction.getPath(); > } > this.getServletContext().setAttribute("actionList", actionList); > } > super.process(request, response); > > What this does is create a new context parameter called "actionList". > It's a "/" separated string of the action paths. It's only called if > the parameter doesn't exist, so if you're already using a parameter by > that name it won't clobber it, and so that it is only called once (the > first time any action is called). Of course, you now have to update > your application descriptor to use your new actionservlet instead of the > struts one. > > This is a quick and dirty proof-of-concept, but it is functional. If > anyone has a better idea, please share. > > Cheers, and thanks Antonio! > Brantley > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Ghetto Java: http://www.ghettojava.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]