I have a need to do the following...
I have an xml configuration file that will contain actions that will be
called by struts.
I want to be able to parse the file and add the mappings to the controller
during setup. I do not want the action mappings placed in the
struts-config.xml file. In addition, I also need to add an initialized
action to the controller so that it does not attempt to create the instance,
rather it uses the one I have created and registered.
It looks like this should be possible. So far I have something like the
following...
private void addMappings(Parser parser) {
// retrieve benches-Each bench is a class that extends the Action class
java.util.List benches = parser.getBenches();
java.util.ListIterator iterator = benches.listIterator();
while (iterator.hasNext()) {
org.apache.struts.action.ActionMapping mapping = new
org.apache.struts.action.ActionMapping();
BenchImpl benchImpl = (BenchImpl)iterator.next();
mapping.setPath(benchImpl.getBenchUri());
mapping.setType(benchImpl.getClass().toString());
servlet.addMapping(mapping);
// Workbench is a servlet that extends ActionServlet
((org.apache.cafe.workbench.Workbench)servlet).addAction(benchImpl.getBenchN
ame(), benchImpl);
}
}
The addAction method is as follows
/**
*
* Adds action to map
* @param String
* @param org.apache.struts.action.Action
*
*/
protected void addAction(String actionName, Action action) {
actions.put(actionName, action);
}
Seems like it should work, but the controller is still trying to initialize
a new instance of the bench when the mapping is called.
Any suggestions or clarifications?
Thanks!
Scott A. Roehrig
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>