Well, this is a followup to my previous message regarding this subject.
I coded the Dispatcher, but I must say I didn't know what I was doing
exactly. Surprisingly, it works but only from time to time...the behaviour
is really weird...
I'm copying the code below and hope someone could review it. I'm afraid I'm
breaking something somewhere in my cocoon...
Thanks.
ps: remember that I was trying to code a Action that could dispatch other
actions, so I could call it for as many XMLForms as needed with a parameter
and it would choose the right action. Some kind of factory method...
-----------------------
package net.josema.xmtrader.forms;
import java.util.HashMap;
import java.util.Map;
import
net.josema.xmtrader.forms.xmldb.recordings.equipment.EquipmentTypeAction;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.acting.ConfigurableComposerAction;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
/**
* This action let decide which action to use at runtime based on
* a sitemap parameter with the name of the action to load.
*
*/
public class ActionDispatcher extends ConfigurableComposerAction implements
ThreadSafe {
public Map act(Redirector redirector, SourceResolver resolver, Map
objectModel,
String source, Parameters parameters)
throws Exception {
String actionName = parameters.getParameter("actionName");
Map resultMap = new HashMap();
//get the Action
if(actionName.equalsIgnoreCase("EquipmentTypeAction")) {
EquipmentTypeAction equipmentTypeAction = new EquipmentTypeAction();
//add this action to the manager
equipmentTypeAction.compose(this.manager);
resultMap = equipmentTypeAction.act(redirector, resolver, objectModel,
source, parameters);
}
//place for the rest of the if clauses for more actions
//return the map gotten from the chosen action
return resultMap;
}
}
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>