You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Robin Mannering <Ro...@landmarkinfo.co.uk> on 2005/11/08 11:10:49 UTC

Dynamically adding ActionMappings after startup.

Hi all,

Wondering if anyone has tried this before...

I'd like to add a number of ActionConfig objects into the ModuleConfig after the start up of a struts app.  What I mean by this is I'd like to add ActionMappings dynamically to a struts application dependent on information available in a database.

The problem is, the ModuleConfig is frozen after struts finishes with it upon startup, so I cannot add a new ActionConfig to it in the init() method of my own startup servlet.

Does anyone have any ideas on how I can add these ActionMappings dynamically?  My current code snapshot is below:

        ModuleConfig modConfig =
            (ModuleConfig) context.getAttribute(Globals.MODULE_KEY);
        
        if (modConfig != null) {
            modConfig.getPrefix();
        }        
        
        ActionConfig actionConfig = new ActionConfig();
        actionConfig.setPath("/Test");
        actionConfig.setType("org.apache.struts.actions.ForwardAction");
        actionConfig.setParameter("/pages/myTest.vm");
        
        // note: a ForwardConfig could be added here rather than use the
        // standard org.apache.struts.actions.ForwardAction method for forwarding
        
        // add the newly constructed ActionConfig into the struts application
        LOG.debug("modConfig is configured : " + modConfig.getConfigured() );
        modConfig.addActionConfig(actionConfig);

This final line causes an IllegalStateException.

Many thanks in advance for any suggestions...

Robin


=====================================
This email and any files transmitted
with it are confidential and intended
solely for the use of the individual
or entity to whom they are addressed.

If you have received this email in 
error please notify Landmark 
Information Group on +44(0) 1392 
441700.

For more information about the 
Landmark Information Group visit
http://www.landmark-information.co.uk

This email and any attachments have
been scanned for viruses and to the
best of our knowledge are clean.
====================================


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org