From: <jm...@us...> - 2005-09-23 06:38:12
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17798/src/net/jspcontrols/dialogs/actions Modified Files: DialogAction.java DialogConstants.java DialogRuleSet.java SelectAction.java Log Message: Added MailReader Demo; Added component RuleSet Index: DialogAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DialogAction.java 4 Aug 2005 07:39:43 -0000 1.2 --- DialogAction.java 23 Sep 2005 06:37:56 -0000 1.3 *************** *** 231,234 **** --- 231,242 ---- /** + * Returns suffix, used for action mapping. Default suffix is ".do" + * Needed to properly setup location for dialog reloading. + */ + protected String getActionSuffix() { + return ".do"; + } + + /** * Returns true if request is considered "input" request. By convention * dialog input is sent via POST, result page is loaded via GET. *************** *** 288,291 **** --- 296,329 ---- /** + * Returns the method name, given a prefix and a request object. + * This is a helper method, which should not normally be redefined + * by a subclass. + * + * @param mapping The ActionMapping used to select this instance + * @param form The optional ActionForm bean for this request (if any) + * @param request The HTTP request we are processing + * @param response The HTTP response we are creating + * @param parameter The <code>ActionMapping</code> parameter's name + * Contains prefix of submit button names, or several prefixes + * separated by comma or semicolon. + * + * @return The handler method name. + */ + protected String getMethodName(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response, + String parameter) + throws Exception { + + // If event prefix is not provided in action mapping parameter, + // use default dialog prefix + if (parameter == null || parameter.length() == 0) { + parameter = DialogConstants.DIALOG_EVENT_KEY; + } + return super.getMethodName(mapping, form, request, response, parameter); + } + + /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). *************** *** 330,344 **** } ! // Handler methods usually return valid ActionForward object. ! // Null is used to signify that On the other hand, null If mapping with DialogConstants.DIALOG_RELOAD_KEY is not defined, ! // build ActionForward object and redirect to self. if (actionForward == null ) { ! log.info("Action " + mapping.getPath() + " returned null as forward object"); return null; } else if (actionForward == EventForward.DIALOG_RELOAD) { ! // Use reload path if defined in <dialog input=... /> ! if (mapping instanceof DialogMapping && mapping.getInput() != null) { return new EventForward(mapping.getInput()); --- 368,383 ---- } ! // If mapping with DialogConstants.DIALOG_RELOAD_KEY is not defined, ! // build ActionForward object and redirect to self. Works if ! // actions use default ".do" suffix. if (actionForward == null ) { ! log.debug("Action did not return a forward object"); 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()); *************** *** 403,404 **** --- 442,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()); Index: DialogConstants.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DialogConstants.java 11 Jul 2005 07:13:06 -0000 1.1 --- DialogConstants.java 23 Sep 2005 06:37:56 -0000 1.2 *************** *** 60,62 **** --- 60,73 ---- */ String DIALOG_DONE_KEY = "DIALOG-DONE"; + + /** + * The default mapping for failed dialog + */ + String DIALOG_FAILURE = "DIALOG-FAILURE"; + + /** + * The default mapping for succeeded dialog + */ + String DIALOG_SUCCESS = "DIALOG-SUCCESS"; + } Index: DialogRuleSet.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogRuleSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DialogRuleSet.java 4 Aug 2005 07:39:44 -0000 1.1 --- DialogRuleSet.java 23 Sep 2005 06:37:56 -0000 1.2 *************** *** 27,94 **** digester.addObjectCreate ! ("struts-config/action-mappings/dialog", "net.jspcontrols.dialogs.actions.DialogMapping"); digester.addSetProperties ! ("struts-config/action-mappings/dialog"); digester.addSetNext ! ("struts-config/action-mappings/dialog", "addActionConfig", "org.apache.struts.config.ActionConfig"); digester.addSetProperty ! ("struts-config/action-mappings/dialog/set-property", "property", "value"); digester.addObjectCreate ! ("struts-config/action-mappings/dialog/exception", "org.apache.struts.config.ExceptionConfig", "className"); digester.addSetProperties ! ("struts-config/action-mappings/dialog/exception"); digester.addSetNext ! ("struts-config/action-mappings/dialog/exception", "addExceptionConfig", "org.apache.struts.config.ExceptionConfig"); digester.addSetProperty ! ("struts-config/action-mappings/dialog/exception/set-property", "property", "value"); // digester.addFactoryCreate ! // ("struts-config/action-mappings/dialog/event", // new DialogForwardFactory()); digester.addObjectCreate ! ("struts-config/action-mappings/dialog/event", "net.jspcontrols.dialogs.actions.EventForward"); digester.addSetProperties ! ("struts-config/action-mappings/dialog/event"); digester.addSetNext ! ("struts-config/action-mappings/dialog/event", "addForwardConfig", "net.jspcontrols.dialogs.actions.EventForward"); digester.addSetProperty ! ("struts-config/action-mappings/action/event/set-property", "property", "value"); digester.addObjectCreate ! ("struts-config/action-mappings/dialog/render", "net.jspcontrols.dialogs.actions.RenderForward"); digester.addSetProperties ! ("struts-config/action-mappings/dialog/render"); digester.addSetNext ! ("struts-config/action-mappings/dialog/render", "addForwardConfig", "net.jspcontrols.dialogs.actions.RenderForward"); digester.addSetProperty ! ("struts-config/action-mappings/action/render/set-property", "property", "value"); --- 27,94 ---- digester.addObjectCreate ! ("struts-config/action-mappings/component", "net.jspcontrols.dialogs.actions.DialogMapping"); digester.addSetProperties ! ("struts-config/action-mappings/component"); digester.addSetNext ! ("struts-config/action-mappings/component", "addActionConfig", "org.apache.struts.config.ActionConfig"); digester.addSetProperty ! ("struts-config/action-mappings/component/set-property", "property", "value"); digester.addObjectCreate ! ("struts-config/action-mappings/component/exception", "org.apache.struts.config.ExceptionConfig", "className"); digester.addSetProperties ! ("struts-config/action-mappings/component/exception"); digester.addSetNext ! ("struts-config/action-mappings/component/exception", "addExceptionConfig", "org.apache.struts.config.ExceptionConfig"); digester.addSetProperty ! ("struts-config/action-mappings/component/exception/set-property", "property", "value"); // digester.addFactoryCreate ! // ("struts-config/action-mappings/component/event", // new DialogForwardFactory()); digester.addObjectCreate ! ("struts-config/action-mappings/component/event", "net.jspcontrols.dialogs.actions.EventForward"); digester.addSetProperties ! ("struts-config/action-mappings/component/event"); digester.addSetNext ! ("struts-config/action-mappings/component/event", "addForwardConfig", "net.jspcontrols.dialogs.actions.EventForward"); digester.addSetProperty ! ("struts-config/action-mappings/component/event/set-property", "property", "value"); digester.addObjectCreate ! ("struts-config/action-mappings/component/render", "net.jspcontrols.dialogs.actions.RenderForward"); digester.addSetProperties ! ("struts-config/action-mappings/component/render"); digester.addSetNext ! ("struts-config/action-mappings/component/render", "addForwardConfig", "net.jspcontrols.dialogs.actions.RenderForward"); digester.addSetProperty ! ("struts-config/action-mappings/component/render/set-property", "property", "value"); Index: SelectAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/SelectAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SelectAction.java 4 Aug 2005 07:39:44 -0000 1.2 --- SelectAction.java 23 Sep 2005 06:37:56 -0000 1.3 *************** *** 21,24 **** --- 21,25 ---- import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForward; + import org.apache.struts.Globals; import javax.servlet.http.HttpServletResponse; *************** *** 179,182 **** --- 180,191 ---- /** + * Returns the cancel key.Override this method if you want to use prefix + * different from "DIALOG-EVENT-CANCEL" + */ + public String getCancelKey() { + return getInitKey() + "-CANCEL"; + } + + /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). *************** *** 235,239 **** * not used by <code>SelectAction</code> * ! * @return The handler method name. */ protected String getMethodName(ActionMapping mapping, --- 244,250 ---- * not used by <code>SelectAction</code> * ! * @return The handler method name if event recognized, or null if event ! * is notrecognized. For unrecognized event DispatchAction will ! * call "unspecified" handler. */ protected String getMethodName(ActionMapping mapping, *************** *** 246,249 **** --- 257,264 ---- // "parameter" is not required now; can use standard prefix or // redefine it with getInitKey() method + + + + String buttonPrefix = parameter != null ? parameter : getInitKey(); *************** *** 278,311 **** } ! // Event not recognized, DispatchAction will call "unspecified" method. ! if (keyName == null) { ! return null; ! } ! // Build param name to method map if it is not built yet buildLookupMap(); ! // Pull out a method name for request parameter Object mappedObj = keyMethodMap.get(keyName); - if (mappedObj == null || !(mappedObj instanceof String)) { ! // Uncomment this, if this action is included in ! // official Struts bundle; make sure that ! // LocationStrings.properties contains ! // dispatch.keyMethodMap.notstring key ! // String message = messages.getMessage( ! // "dispatch.keyMethodMap.notstring", ! // mapping.getPath(), keyName); ! // Delete this if action is included in Struts bundle ! String message = "Dispatch action " + mapping.getPath() + ! " returned null or non-string method name" + ! " for request key " + keyName; ! throw new ServletException(message); } ! // Method found ! return (String) mappedObj; } --- 293,336 ---- } ! // Event not recognized ! if (keyName == null) return null; ! // Build map of param name to method, if it is not has been built yet buildLookupMap(); ! // Look up method name for request parameter Object mappedObj = keyMethodMap.get(keyName); ! // Method recognized, return method name ! if (mappedObj != null && mappedObj instanceof String) { ! return (String) mappedObj; ! } ! // Check for dialog cancel event. If yes, use standard ! // cancelled() method and patch isCancelled() to return true. ! // If standard RequestProcessor is used, then form bean is ! // already populated at this point. To prevent form bean from ! // populating use standard <html:cancel/> button ! if (keyName.equals(getCancelKey())) { ! request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE); ! return "cancelled"; } ! // Uncomment this, if this action is included in ! // official Struts bundle; make sure that ! // LocationStrings.properties contains ! // dispatch.keyMethodMap.notstring key ! // ! // String message = messages.getMessage( ! // "dispatch.keyMethodMap.notstring", ! // mapping.getPath(), keyName); ! ! // Delete this inline message if action is included in Struts bundle ! String message = "Dispatch action " + mapping.getPath() + ! " returned null or non-string method name" + ! " for request key " + keyName; ! ! throw new ServletException(message); } |