Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29970/src/net/jspcontrols/dialogs/actions Modified Files: DialogAction.java DialogMapping.java DialogRuleSet.java EventForward.java Added Files: TransferForward.java Log Message: --- NEW FILE: TransferForward.java --- package net.jspcontrols.dialogs.actions; import org.apache.struts.action.ActionForward; /** * Created by IntelliJ IDEA. * User: mjouravlev * Date: Jul 20, 2005 * Time: 11:21:22 AM * To change this template use Options | File Templates. */ public class TransferForward extends ActionForward { public static final ActionForward DIALOG_RELOAD = new ActionForward(); /** * <p>Construct a new instance of an <code>ActionForward</code> * object with values, default for an event forward object: * <code>path</code> is set to null, <code>redirect</code> is * set to true.</p> * * <p>Event forward objects are intended to handle the first phase * of two-phase request processing, thus they use redirect * by default.</p> */ public TransferForward() { super(null, true); } /** * <p>Construct a new instance with the specified path.</p> * * @param path Path for this instance */ public TransferForward(String path) { super(path, true); } } Index: DialogAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DialogAction.java 23 Sep 2005 06:37:56 -0000 1.3 --- DialogAction.java 9 Nov 2005 03:20:42 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- import org.apache.struts.action.ActionMessages; import org.apache.struts.Globals; + import org.apache.struts.config.ForwardConfig; import javax.servlet.http.HttpServletRequest; *************** *** 27,30 **** --- 28,33 ---- import javax.servlet.http.HttpSession; import java.util.Enumeration; + import java.util.Map; + import java.util.HashMap; /** *************** *** 192,196 **** * @author Michael Jouravlev */ ! public abstract class DialogAction extends SelectAction { /** --- 195,228 ---- * @author Michael Jouravlev */ ! public class DialogAction extends SelectAction { ! ! ! /** ! * <p>Return the logical names of all locally defined forwards for this ! * mapping. If there are no such forwards, a zero-length array ! * is returned.</p> ! */ ! synchronized public void resolveEvents(ActionMapping mapping) { ! System.out.println("DialogAction.resolveEvents <--"); ! if (keyMethodMap == null) { ! System.out.println("DialogAction.resolveEvents: initializing frozenMethodMap"); ! Map methodMap = new HashMap(); ! ForwardConfig fcs[] = mapping.findForwardConfigs(); ! for (int i = 0; i < fcs.length; i++) { ! if (fcs[i] instanceof EventForward) { ! EventForward eventForward = (EventForward ) fcs[i]; ! methodMap.put(eventForward.getName(), ! eventForward.getHandler()); ! System.out.println("DialogAction.resolveEvents: " + ! "added (" + eventForward.getName() + ", " + ! eventForward.getHandler() + ")"); ! } ! } ! if (!methodMap.isEmpty()) { ! keyMethodMap = methodMap; ! } ! } ! System.out.println("DialogAction.resolveEvents -->"); ! } /** *************** *** 326,329 **** --- 358,378 ---- /** + * Provides mapping between event names (keys) and handler methods (values). + * This method may be overriden by a subclass. Important: if you define + * action mappings using new syntax (with "component" element), then if + * "event" subelements are defined for a component, getKeyMethodMap will + * not be called. + * <p> + * In other words, define the event-to-method mapping either in + * struts-config.xml file, or in the code using getKeyMethodMap method. + * + * @return Map, containing association between event names (keys) and + * handler methods (values). + */ + protected Map getKeyMethodMap() { + return keyMethodMap; + } + + /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). *************** *** 344,347 **** --- 393,399 ---- HttpServletResponse response) throws Exception { + // Load event-to-method mapping from struts-config.xml file, if defined + resolveEvents(mapping); + // Is this an input process with POST? boolean isInput = isInput(request); *************** *** 375,389 **** return null; ! } else if (actionForward == EventForward.DIALOG_RELOAD) { // Use reload path if defined in <component input=... /> if (mapping instanceof DialogMapping && mapping.getInput() != null) { ! return new EventForward(mapping.getInput()); // If no reload path defined in the action mapping, use real // address since we are redirecting through browser anyway. } else { ! return new EventForward(request.getServletPath()); } --- 427,441 ---- return null; ! } else if (actionForward == TransferForward.DIALOG_RELOAD) { // Use reload path if defined in <component input=... /> if (mapping instanceof DialogMapping && mapping.getInput() != null) { ! return new TransferForward(mapping.getInput()); // If no reload path defined in the action mapping, use real // address since we are redirecting through browser anyway. } else { ! return new TransferForward(request.getServletPath()); } *************** *** 443,450 **** } - //System.out.println("Dialog reload mapping: " + reloadPath); - //System.out.println("request," + - // " request.getServletPath(): " + request.getServletPath() + - // "\n, request.getRequestURI(): " + request.getRequestURI() + - // "\n, request.getPathInfo(): " + request.getPathInfo() + - // "\n, request.getQueryString(): " + request.getQueryString()); --- 495,496 ---- Index: DialogMapping.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogMapping.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DialogMapping.java 4 Aug 2005 07:39:44 -0000 1.1 --- DialogMapping.java 9 Nov 2005 03:20:42 -0000 1.2 *************** *** 60,64 **** public ActionForward reload() { ! return EventForward.DIALOG_RELOAD; } --- 60,64 ---- public ActionForward reload() { ! return TransferForward.DIALOG_RELOAD; } Index: DialogRuleSet.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogRuleSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DialogRuleSet.java 23 Sep 2005 06:37:56 -0000 1.2 --- DialogRuleSet.java 9 Nov 2005 03:20:42 -0000 1.3 *************** *** 57,63 **** // digester.addFactoryCreate ! // ("struts-config/action-mappings/component/event", // new DialogForwardFactory()); digester.addObjectCreate ("struts-config/action-mappings/component/event", --- 57,67 ---- // digester.addFactoryCreate ! // ("struts-config/action-mappings/component/transfer", // new DialogForwardFactory()); + /* + * Event (based on ForwardConfig) + */ + digester.addObjectCreate ("struts-config/action-mappings/component/event", *************** *** 76,79 **** --- 80,106 ---- "property", "value"); + /* + * Transfer forward (with redirection) + */ + + digester.addObjectCreate + ("struts-config/action-mappings/component/transfer", + "net.jspcontrols.dialogs.actions.TransferForward"); + + digester.addSetProperties + ("struts-config/action-mappings/component/transfer"); + + digester.addSetNext + ("struts-config/action-mappings/component/transfer", + "addForwardConfig", + "net.jspcontrols.dialogs.actions.TransferForward"); + + digester.addSetProperty + ("struts-config/action-mappings/component/transfer/set-property", + "property", "value"); + + /* + * Render forward (no redirection) + */ digester.addObjectCreate Index: EventForward.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/EventForward.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EventForward.java 4 Aug 2005 07:39:44 -0000 1.1 --- EventForward.java 9 Nov 2005 03:20:42 -0000 1.2 *************** *** 6,39 **** * Created by IntelliJ IDEA. * User: mjouravlev ! * Date: Jul 20, 2005 ! * Time: 11:21:22 AM * To change this template use Options | File Templates. */ public class EventForward extends ActionForward { ! public static final ActionForward DIALOG_RELOAD = ! new ActionForward(); /** * <p>Construct a new instance of an <code>ActionForward</code> ! * object with values, default for an event forward object: * <code>path</code> is set to null, <code>redirect</code> is ! * set to true.</p> * ! * <p>Event forward objects are intended to handle the first phase ! * of two-phase request processing, thus they use redirect ! * by default.</p> */ public EventForward() { ! super(null, true); } ! /** ! * <p>Construct a new instance with the specified path.</p> ! * ! * @param path Path for this instance ! */ ! public EventForward(String path) { ! super(path, true); } --- 6,42 ---- * Created by IntelliJ IDEA. * User: mjouravlev ! * Date: Nov 8, 2005 ! * Time: 11:28:20 AM * To change this template use Options | File Templates. */ public class EventForward extends ActionForward { ! String handler; ! ! public String getHandler() { ! return handler; ! } ! ! public void setHandler(String handler) { ! this.handler = handler; ! } /** * <p>Construct a new instance of an <code>ActionForward</code> ! * object with values, default for an render forward object: * <code>path</code> is set to null, <code>redirect</code> is ! * set to false.</p> * ! * <p>Render forward objects are intended to handle the second phase ! * of two-phase request processing, thus they use server-side ! * forwarding by default.</p> */ public EventForward() { ! super(); } ! public EventForward(String name, String handler) { ! super(name, null, false); ! this.handler = handler; } |