craigmcc 2003/12/29 14:45:52 Modified: contrib/struts-faces README.txt contrib/struts-faces/src/java/org/apache/struts/faces/application ActionListenerImpl.java contrib/struts-faces/src/java/org/apache/struts/faces/taglib LifecycleListener.java contrib/struts-faces/web/example/WEB-INF struts-config.xml Log: Modify the way that an application is configured to use the struts-faces integration library such that you must explicitly identify the request processor class to use in a <controller> element in struts-config.xml. This will pave the way for integration with Tiles, as well as support the use of the integration library in Struts apps with multiple sub-app modules. Revision Changes Path 1.5 +19 -2 jakarta-struts/contrib/struts-faces/README.txt Index: README.txt =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/README.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- README.txt 24 Dec 2003 04:47:55 -0000 1.4 +++ README.txt 29 Dec 2003 22:45:52 -0000 1.5 @@ -159,7 +159,7 @@ application -- Integrate with ActionListener, custom PropertyResolver, - custom RequestProcessor + custom RequestProcessor(s) component -- Custom JavaServer Faces component implementations (only Form for now) @@ -209,6 +209,7 @@ http://java.sun.com/j2se/ + Install a Servlet Container: --------------------------- @@ -453,6 +454,17 @@ library counterparts, and the expression language syntax is the same as that used for value reference expressions. +* Modify your struts-config.xml file to include identification of the custom + request processor implementation class to be used, by adding the following + element in the appropriate location (typically just before any existing + <message-resources> and <plug-in> elements): + + <controller> + <set-property property="processorClass" + value="org.apache.struts.faces.application.FacesRequestProcessor"/> + </controller> + + * For each JSP page that you have modified to use JavaServer Faces components instead of traditional Struts tags, modify any <forward> elements in your webapp's struts-config.xml file to include "/faces" @@ -478,6 +490,11 @@ immediate="false" (which is the default value) that are nested inside a Struts-Faces <s:form> tag will be forwarded through the normal Struts request processing lifecycle. + +* If your application contains cancel buttons rendered by the <html:cancel> + tag, you should replace them with an <h:command_button> that has an + "id" attribute set to "cancel" in order for this button to be recognized + by Struts as a cancel button. * If your application itself provides additional UIComponent and/or Renderer implementations, you must register them with the default 1.4 +58 -7 jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/application/ActionListenerImpl.java Index: ActionListenerImpl.java =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/application/ActionListenerImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ActionListenerImpl.java 24 Dec 2003 03:21:01 -0000 1.3 +++ ActionListenerImpl.java 29 Dec 2003 22:45:52 -0000 1.4 @@ -80,6 +80,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.Globals; +import org.apache.struts.action.ActionServlet; import org.apache.struts.action.RequestProcessor; import org.apache.struts.config.ModuleConfig; import org.apache.struts.faces.Constants; @@ -186,9 +187,8 @@ log.trace("Assigned to module with prefix '" + moduleConfig.getPrefix() + "'"); } - RequestProcessor processor = (RequestProcessor) - servletContext.getAttribute - (Globals.REQUEST_PROCESSOR_KEY + moduleConfig.getPrefix()); + RequestProcessor processor = + getRequestProcessor(moduleConfig, servletContext); if (log.isTraceEnabled()) { log.trace("Invoking request processor instance " + processor); } @@ -205,5 +205,56 @@ // ------------------------------------------------------ Protected Methods + + /** + * <p>Look up and return the <code>RequestProcessor</code> responsible for + * the specified module, creating a new one if necessary. This method is + * based on the corresponding code in <code>ActionServlet</code>, which + * cannot be used directly because it is a protected method.</p> + * + * @param config The module configuration for which to + * acquire and return a RequestProcessor + * @param context The <code>ServletContext</code> instance + * for this web application + * + * @exception IllegalStateException if we cannot instantiate a + * RequestProcessor instance + */ + protected RequestProcessor getRequestProcessor(ModuleConfig config, + ServletContext context) { + + String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix(); + RequestProcessor processor = + (RequestProcessor) context.getAttribute(key); + + if (processor == null) { + try { + if (log.isDebugEnabled()) { + log.debug("Instantiating RequestProcessor of class " + + config.getControllerConfig().getProcessorClass()); + } + ActionServlet servlet = (ActionServlet) + context.getAttribute(Globals.ACTION_SERVLET_KEY); + processor = + (RequestProcessor) RequestUtils.applicationInstance( + config.getControllerConfig().getProcessorClass()); + processor.init(servlet, config); + context.setAttribute(key, processor); + } catch (Exception e) { + log.error("Cannot instantiate RequestProcessor of class " + + config.getControllerConfig().getProcessorClass(), + e); + throw new IllegalStateException( + "Cannot initialize RequestProcessor of class " + + config.getControllerConfig().getProcessorClass() + + ": " + + e); + } + + } + return (processor); + + } + } 1.5 +8 -6 jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/taglib/LifecycleListener.java Index: LifecycleListener.java =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/taglib/LifecycleListener.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- LifecycleListener.java 24 Dec 2003 03:21:01 -0000 1.4 +++ LifecycleListener.java 29 Dec 2003 22:45:52 -0000 1.5 @@ -131,8 +131,8 @@ log.info("attributeAdded(" + name + "," + event.getValue() + ")"); if (name.equals(Globals.ACTION_SERVLET_KEY)) { servlet = (ActionServlet) event.getValue(); - } else if (name.startsWith(Globals.MODULE_KEY)) { - createProcessor(servlet, (ModuleConfig) event.getValue()); + // } else if (name.startsWith(Globals.MODULE_KEY)) { + // createProcessor(servlet, (ModuleConfig) event.getValue()); } } @@ -210,6 +210,7 @@ * @param servlet ActionServlet instance we are associated with * @param modConfig ModuleConfig instance we are associated with */ + /* private RequestProcessor createProcessor(ActionServlet servlet, ModuleConfig modConfig) { @@ -228,6 +229,7 @@ return (processor); } + */ /** 1.3 +2 -0 jakarta-struts/contrib/struts-faces/web/example/WEB-INF/struts-config.xml Index: struts-config.xml =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/web/example/WEB-INF/struts-config.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- struts-config.xml 24 Dec 2003 03:21:02 -0000 1.2 +++ struts-config.xml 29 Dec 2003 22:45:52 -0000 1.3 @@ -144,6 +144,8 @@ <!-- The "input" parameter on "action" elements is the name of a local or global "forward" rather than a subapp-relative path --> <set-property property="inputForward" value="true"/> + <set-property property="processorClass" + value="org.apache.struts.faces.application.FacesRequestProcessor"/> </controller>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]