Author: craigmcc
Date: Tue Oct 26 22:14:37 2004
New Revision: 55673
Added:
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/Constants.java
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplConstants.java
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplPhaseListener.java
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplViewHandler.java
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/package.html
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/package.html
Modified:
struts/trunk/contrib/struts-shale/src/conf/faces-config.xml
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/ViewController.java
Log:
Add some prototype implementations for the proposed ViewController
functionality (presuming JSF infrastructure) in the
org.apache.shale.impl package.
Add some Javadoc package comments to point people in the right direction
about the contents of each package.
Modified: struts/trunk/contrib/struts-shale/src/conf/faces-config.xml
==============================================================================
--- struts/trunk/contrib/struts-shale/src/conf/faces-config.xml (original)
+++ struts/trunk/contrib/struts-shale/src/conf/faces-config.xml Tue Oct 26 22:14:37
2004
@@ -27,631 +27,16 @@
-->
-<!-- ================== STRUTS-FACES CONFIGURATION FILE =================== -->
+<!-- ====================== SHALE CONFIGURATION FILE ======================= -->
<faces-config>
-
<!-- Custom JSF Lifecycle and Evaluator Objects -->
-<!--
<application>
- <action-listener>
- org.apache.struts.faces.application.ActionListenerImpl
- </action-listener>
- <property-resolver>
- org.apache.struts.faces.application.PropertyResolverImpl
- </property-resolver>
<view-handler>
- org.apache.struts.faces.application.ViewHandlerImpl
+ org.apache.shale.impl.ImplViewHandler
</view-handler>
</application>
--->
-
- <!-- Custom Components -->
-<!--
- <component>
-
- <component-type>org.apache.struts.faces.Base</component-type>
- <component-class>
- org.apache.struts.faces.component.BaseComponent
- </component-class>
-
- <property>
- <description>
- Target frame for this base reference.
- </description>
- <display-name>Target Frame</display-name>
- <property-name>target</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.CommandLink</component-type>
- <component-class>
- org.apache.struts.faces.component.CommandLinkComponent
- </component-class>
-
- <property>
- <description>
- Access key that, when pressed, transfers focus to
- this element.
- </description>
- <display-name>Access Key</display-name>
- <property-name>accesskey</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Character encoding of the resource identified by
- this hyperlink.
- </description>
- <display-name>Character Set</display-name>
- <property-name>charset</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Direction indication for text ("LTR" or "RTL").
- </description>
- <display-name>Direction</display-name>
- <property-name>dir</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Language code of the resource identified by
- this hyperlink.
- </description>
- <display-name>Resource Language Code</display-name>
- <property-name>hreflang</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Language code used for the generated markup of this element.
- </description>
- <display-name>Language Code</display-name>
- <property-name>lang</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when this element loses focus.
- </description>
- <display-name>Focus Off Script</display-name>
- <property-name>onblur</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is clicked
- over this element.
- </description>
- <display-name>Button Click Script</display-name>
- <property-name>onclick</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is double clicked
- over this element.
- </description>
- <display-name>Double Click Script</display-name>
- <property-name>ondblclick</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when this element receives focus.
- </description>
- <display-name>Focus On Script</display-name>
- <property-name>onfocus</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a key is pressed and released
- over this element.
- </description>
- <display-name>Key Down Script</display-name>
- <property-name>onkeydown</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a key is pressed and released
- over this element.
- </description>
- <display-name>Key Press Script</display-name>
- <property-name>onkeypress</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a key is pressed and released
- over this element.
- </description>
- <display-name>Key Up Script</display-name>
- <property-name>onkeyup</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is pressed down
- over this element.
- </description>
- <display-name>Mouse Down Script</display-name>
- <property-name>onmousedown</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is moved
- over this element.
- </description>
- <display-name>Mouse Move Script</display-name>
- <property-name>onmousemove</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is moved
- off of this element.
- </description>
- <display-name>Mouse Out Script</display-name>
- <property-name>onmouseout</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is moved
- onto this element.
- </description>
- <display-name>Mouse Over Script</display-name>
- <property-name>onmouseover</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Scripting code executed when a pointer button is released
- over this element.
- </description>
- <display-name>Mouse Up Script</display-name>
- <property-name>onmouseup</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Relationship from the current document to the resource
- specified by this hyperlink.
- </description>
- <display-name>Relationship</display-name>
- <property-name>rel</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Relationship from the resource identified by this hyperlink
- to the current document.
- </description>
- <display-name>Reverse Relationship</display-name>
- <property-name>rev</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- CSS style(s) to be applied when this component is rendered.
- </description>
- <display-name>CSS Styles</display-name>
- <property-name>style</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Space-separated list of CSS style class(es) to be applied when
- this element is rendered.
- </description>
- <display-name>CSS Style Classes</display-name>
- <property-name>styleClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Position of this element in the tabbing order for the current document.
- </description>
- <display-name>Tab Index</display-name>
- <property-name>tabindex</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Name of the frame where the resource identified by
- this hyperlink should be displayed.
- </description>
- <display-name>Target Frame</display-name>
- <property-name>target</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Advisory title information about markup elements generated
- for this component.
- </description>
- <display-name>Advisory Title</display-name>
- <property-name>title</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Content type of the resource identified by this hyperlink.
- </description>
- <display-name>Content Type</display-name>
- <property-name>type</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.Errors</component-type>
- <component-class>
- org.apache.struts.faces.component.ErrorsComponent
- </component-class>
-
- <property>
- <description>
- Application scope attribute key for the MessageResources
- instance to use for lookup. If not specified, the default
- MessageResources for the current module will be used.
- </description>
- <display-name>MessageResources Key</display-name>
- <property-name>bundle</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.Form</component-type>
- <component-class>
- org.apache.struts.faces.component.FormComponent
- </component-class>
-
- <property>
- <description>
- Struts action to be executed.
- </description>
- <display-name>Struts Action</display-name>
- <property-name>action</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Encoding type for form submit.
- </description>
- <display-name>Encoding Type</display-name>
- <property-name>enctype</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Name of focus component identifier.
- </description>
- <display-name>Focus Component Name</display-name>
- <property-name>focusIndex</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Index of focus component identifier.
- </description>
- <display-name>Focus Component Index</display-name>
- <property-name>focusIndex</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- JavaScript to execute on form reset.
- </description>
- <display-name>Form Reset Script</display-name>
- <property-name>onreset</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- JavaScript to execute on form submit.
- </description>
- <display-name>Form Submit Script</display-name>
- <property-name>onsubmit</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- CSS style(s) to render for this component.
- </description>
- <display-name>CSS Style(s)</display-name>
- <property-name>style</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- CSS style class(es) to render for this component.
- </description>
- <display-name>CSS Style Class(es)</display-name>
- <property-name>styleClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Target frame for the response to this form submit.
- </description>
- <display-name>Target Frame</display-name>
- <property-name>target</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.Html</component-type>
- <component-class>
- org.apache.struts.faces.component.HtmlComponent
- </component-class>
-
- <property>
- <description>
- Flag indicating whether a Locale should be stored in the
- user's session, based on the Accept-Language header, if
- one is not already present.
- </description>
- <display-name>Locale Flag</display-name>
- <property-name>locale</property-name>
- <property-class>boolean</property-class>
- </property>
-
- <property>
- <description>
- Flag indicating whether XHTML-compatible output should
- be rendered.
- </description>
- <display-name>XHTML Flag</display-name>
- <property-name>xhtml</property-name>
- <property-class>boolean</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.Message</component-type>
- <component-class>
- org.apache.struts.faces.component.MessageComponent
- </component-class>
-
- <property>
- <description>
- Application scope attribute key for the MessageResources
- instance to use for lookup. If not specified, the default
- MessageResources for the current module will be used.
- </description>
- <display-name>MessageResources Key</display-name>
- <property-name>bundle</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- Message key to use for message lookup
- </description>
- <display-name>Message Key</display-name>
- <property-name>key</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- CSS style(s) to render for this component.
- </description>
- <display-name>CSS Style(s)</display-name>
- <property-name>style</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- CSS style class(es) to render for this component.
- </description>
- <display-name>CSS Style Class(es)</display-name>
- <property-name>styleClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.Stylesheet</component-type>
- <component-class>
- org.apache.struts.faces.component.StylesheetComponent
- </component-class>
-
- <property>
- <description>
- Context-relative path (starting with a "/" character)
- of the stylesheet to which this link should point.
- </description>
- <display-name>Stylesheet Path</display-name>
- <property-name>path</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
-
-
- <component>
-
- <component-type>org.apache.struts.faces.Write</component-type>
- <component-class>
- org.apache.struts.faces.component.WriteComponent
- </component-class>
-
- <property>
- <description>
- Flag indicating that the rendered output should be filtered
- for characters that are sensitive in HTML. Default value is
- "true".
- </description>
- <display-name>Filtered Flag</display-name>
- <property-name>filter</property-name>
- <property-class>boolean</property-class>
- </property>
-
- <property>
- <description>
- CSS style(s) to render for this component.
- </description>
- <display-name>CSS Style(s)</display-name>
- <property-name>style</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <description>
- CSS style class(es) to render for this component.
- </description>
- <display-name>CSS Style Class(es)</display-name>
- <property-name>styleClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- </component>
--->
-
- <!-- Custom Managed Beans -->
-<!--
- <managed-bean>
- <managed-bean-name>struts</managed-bean-name>
- <managed-bean-class>
- org.apache.struts.faces.util.StrutsContext
- </managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- </managed-bean>
--->
-
- <!-- Custom Renderers -->
-<!--
- <render-kit>
-
- <renderer>
- <component-family>org.apache.struts.faces.Base</component-family>
- <renderer-type>org.apache.struts.faces.Base</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.BaseRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.CommandLink</component-family>
- <renderer-type>org.apache.struts.faces.CommandLink</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.CommandLinkRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.Errors</component-family>
- <renderer-type>org.apache.struts.faces.Errors</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.ErrorsRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.Form</component-family>
- <renderer-type>org.apache.struts.faces.Form</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.FormRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.Html</component-family>
- <renderer-type>org.apache.struts.faces.Html</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.HtmlRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.Message</component-family>
- <renderer-type>org.apache.struts.faces.Message</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.MessageRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.Stylesheet</component-family>
- <renderer-type>org.apache.struts.faces.Stylesheet</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.StylesheetRenderer
- </renderer-class>
- </renderer>
-
- <renderer>
- <component-family>org.apache.struts.faces.Write</component-family>
- <renderer-type>org.apache.struts.faces.Write</renderer-type>
- <renderer-class>
- org.apache.struts.faces.renderer.WriteRenderer
- </renderer-class>
- </renderer>
-
- </render-kit>
--->
</faces-config>
Added: struts/trunk/contrib/struts-shale/src/java/org/apache/shale/Constants.java
==============================================================================
--- (empty file)
+++ struts/trunk/contrib/struts-shale/src/java/org/apache/shale/Constants.java Tue
Oct 26 22:14:37 2004
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale;
+
+/**
+ * <p>Manifest constants defining global identifiers for the entire
+ * controller architecture, which are of interest to applications
+ * built on top of the framework.</p>
+ *
+ * $Id$
+ */
+public interface Constants {
+
+
+}
Modified:
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/ViewController.java
==============================================================================
--- struts/trunk/contrib/struts-shale/src/java/org/apache/shale/ViewController.java
(original)
+++ struts/trunk/contrib/struts-shale/src/java/org/apache/shale/ViewController.java
Tue Oct 26 22:14:37 2004
@@ -84,8 +84,9 @@
* <li>Whenever a JSF view with the appropriate <code>view identifier</code>
* is created or restored, an appropriate instance of the corresponding
* [EMAIL PROTECTED] ViewController} class will be created via the managed beans
- * facility (if such a bean does not already exist). As a side effect,
- * property setters will be called for any
+ * facility (if such a bean does not already exist), using a key derived
+ * from the [EMAIL PROTECTED] ViewControllerMapper} for this application. As a
+ * side effect, property setters wil be called for any
* <code><managed-property></code> configuration you have
* specified.</li>
* <li>Prior to any other method calls, the following additional property
Added:
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplConstants.java
==============================================================================
--- (empty file)
+++
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplConstants.java
Tue Oct 26 22:14:37 2004
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.impl;
+
+import org.apache.shale.ViewController;
+import org.apache.shale.ViewControllerMapper;
+
+/**
+ * <p>Manifest constants defining global identifiers shared across
+ * the internal implementation of the controller. These constants
+ * need not be referenced by applications built on the framework.</p>
+ *
+ * $Id$
+ */
+public interface ImplConstants {
+
+
+ /**
+ * <p>Application scope attribute under which the
+ * [EMAIL PROTECTED] ViewControllerMapper} for translating view identifiers
+ * to class names of the corresponding [EMAIL PROTECTED] ViewController}
+ * is stored.</p>
+ */
+ public static final String VIEW_MAPPER =
+ "org.apache.shale.impl.VIEW_MAPPER";
+
+
+ /**
+ * <p>Request scope attribute under which the [EMAIL PROTECTED] ViewController}
+ * for the view that will actually be rendered (if any) is stored.</p>
+ */
+ public static final String VIEW_RENDERED =
+ "org.apache.shale.impl.VIEW_RENDERED";
+
+
+ /**
+ * <p>Request scope attribute under which a <code>List</code>
+ * containing all [EMAIL PROTECTED] ViewController}s that have been initialized
+ * for the current request are stored.</p>
+ */
+ public static final String VIEWS_INITIALIZED =
+ "org.apache.shale.impl.VIEWS_INITIALIZED";
+
+
+}
Added:
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplPhaseListener.java
==============================================================================
--- (empty file)
+++
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplPhaseListener.java
Tue Oct 26 22:14:37 2004
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.impl;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.apache.shale.ViewController;
+
+/**
+ * <p>JavaServer Faces <code>PhaseListener</code> that implements phase
+ * related functionality. FIXME - register this with JSF appropriately.</p>
+ *
+ * $Id$
+ */
+
+public class ImplPhaseListener implements PhaseListener {
+
+
+ // --------------------------------------------------- PhaseListener Methods
+
+
+ /**
+ * <p>Perform after-phase processing for the phase defined in the
+ * specified event.</p>
+ *
+ * @param event <code>PhaseEvent</code> for the current event
+ */
+ public void afterPhase(PhaseEvent event) {
+
+ PhaseId phaseId = event.getPhaseId();
+ if (PhaseId.RENDER_RESPONSE.equals(phaseId)) {
+ afterRenderResponse(event);
+ }
+
+ }
+
+
+ /**
+ * <p>Perform before-phase processing for the phase defined in the
+ * specified event.</p>
+ *
+ * @param event <code>PhaseEvent</code> for the current event
+ */
+ public void beforePhase(PhaseEvent event) {
+
+ PhaseId phaseId = event.getPhaseId();
+ if (PhaseId.RENDER_RESPONSE.equals(phaseId)) {
+ beforeRenderResponse(event);
+ }
+
+ }
+
+
+ /**
+ * <p>Return <code>PhaseId.ANY_PHASE</code>, indicating our interest
+ * in all phases of the request processing lifecycle.</p>
+ */
+ public PhaseId getPhaseId() {
+
+ return PhaseId.ANY_PHASE;
+
+ }
+
+
+ // --------------------------------------------------------- Private Methods
+
+
+ /**
+ * <p>Call the <code>destroy()</code> method of the [EMAIL PROTECTED]
ViewController}s
+ * that have been registered during this request (if any).</p>
+ *
+ * @param event <code>PhaseEvent</code> for the current event
+ */
+ private void afterRenderResponse(PhaseEvent event) {
+
+ Map map = event.getFacesContext().getExternalContext().getRequestMap();
+ List list = (List) map.get(ImplConstants.VIEWS_INITIALIZED);
+ if (list == null) {
+ return;
+ }
+ Iterator vcs = list.iterator();
+ while (vcs.hasNext()) {
+ ViewController vc = (ViewController) vcs.next();
+ vc.destroy();
+ }
+ map.remove(ImplConstants.VIEWS_INITIALIZED);
+
+ }
+
+
+
+ /**
+ * <p>Call the <code>prepare()</code> method of the [EMAIL PROTECTED]
ViewController}
+ * for the view about to be rendered (if any).</p>
+ *
+ * @param event <code>PhaseEvent</code> for the current event
+ */
+ private void beforeRenderResponse(PhaseEvent event) {
+
+ Map map = event.getFacesContext().getExternalContext().getRequestMap();
+ ViewController vc = (ViewController)
+ map.get(ImplConstants.VIEW_RENDERED);
+ if (vc == null) {
+ return;
+ }
+ vc.prepare();
+ map.remove(ImplConstants.VIEW_RENDERED);
+
+ }
+
+
+}
Added:
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplViewHandler.java
==============================================================================
--- (empty file)
+++
struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/ImplViewHandler.java
Tue Oct 26 22:14:37 2004
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.shale.ViewController;
+import org.apache.shale.ViewControllerMapper;
+
+/**
+ * <p>Custom implementation of <code>ViewHandler</code> that adds support
+ * for on-demand creation and configuration of [EMAIL PROTECTED] ViewController}
+ * instances.</p>
+ *
+ * $Id$
+ */
+
+public class ImplViewHandler extends ViewHandler {
+
+
+ // ------------------------------------------------------------- Constructor
+
+
+ /**
+ * <p>Create a [EMAIL PROTECTED] ImplViewHandler} instance that decorates the
+ * specified <code>ViewHandler</code> provided by the JSF runtime
+ * implementation.</p>
+ *
+ * @param original Original <code>ViewHandler</code> to be decorated
+ */
+ public ImplViewHandler(ViewHandler original) {
+ this.original = original;
+ if (log.isDebugEnabled()) {
+ log.debug("ImplViewHandler instance is decorating " +
+ original.toString());
+ }
+ }
+
+
+ // -------------------------------------------------------- Static Variables
+
+
+ /**
+ * <p>Log instance for this class.</p>
+ */
+ private static final Log log = LogFactory.getLog(ImplViewHandler.class);
+
+
+ // ------------------------------------------------------ Instance Variables
+
+
+ /**
+ * <p>Cached [EMAIL PROTECTED] ViewControllerMapper} we will use to translate
+ * view identifiers to the class name of a [EMAIL PROTECTED] ViewController}.</p>
+ */
+ private ViewControllerMapper mapper = null;
+
+
+ /**
+ * <p>The <code>ViewHandler</code> instance we are decorating. All requests
+ * are delegated to this instance, before or after any special handling that
+ * is required.</p>
+ */
+ private ViewHandler original = null;
+
+
+ // ----------------------------------------------------- ViewHandler Methods
+
+
+ // Specified by ViewHandler
+ public Locale calculateLocale(FacesContext context) {
+ return original.calculateLocale(context);
+ }
+
+
+ // Specified by ViewHandler
+ public String calculateRenderKitId(FacesContext context) {
+ return original.calculateRenderKitId(context);
+ }
+
+
+ /**
+ * <p>After delegating to our original <code>ViewHandler</code>,
+ * create and initialize any [EMAIL PROTECTED] ViewController} associated with
+ * the specified view identifier.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ * @param viewId View identifier of the view to be created
+ */
+ public UIViewRoot createView(FacesContext context, String viewId) {
+ UIViewRoot view = original.createView(context, viewId);
+ setupViewController(context, view, false);
+ return view;
+ }
+
+
+ // Specified by ViewHandler
+ public String getActionURL(FacesContext context, String viewId) {
+ return original.getActionURL(context, viewId);
+ }
+
+
+ // Specified by ViewHandler
+ public String getResourceURL(FacesContext context, String path) {
+ return original.getResourceURL(context, path);
+ }
+
+
+ // Specified by ViewHandler
+ public void renderView(FacesContext context, UIViewRoot view)
+ throws IOException, FacesException {
+ original.renderView(context, view);
+ }
+
+
+ /**
+ * <p>After delegating to our original <code>ViewHandler</code>,
+ * create and initialize any [EMAIL PROTECTED] ViewController} associated with
+ * the specified view identifier.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ * @param viewId View identifier of the view to be restored
+ */
+ public UIViewRoot restoreView(FacesContext context, String viewId) {
+ UIViewRoot view = original.restoreView(context, viewId);
+ setupViewController(context, view, true);
+ return view;
+ }
+
+
+ // Specified by ViewHandler
+ public void writeState(FacesContext context) throws IOException {
+ original.writeState(context);
+ }
+
+
+ // --------------------------------------------------------- Private Methods
+
+
+ /**
+ * <p>Return the [EMAIL PROTECTED] ViewControllerMapper} instance we will use to
+ * map view identifiers to class names of the corresponding
+ * [EMAIL PROTECTED] ViewController} class.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ */
+ private ViewControllerMapper getViewControllerMapper(FacesContext context) {
+ if (mapper != null) {
+ Map map = context.getExternalContext().getApplicationMap();
+ mapper = (ViewControllerMapper) map.get(ImplConstants.VIEW_MAPPER);
+ }
+ return mapper;
+ }
+
+
+ /**
+ * <p>Create and initialize an appropriate [EMAIL PROTECTED] ViewController}
instance
+ * associated with the specified view, which was just created or just
+ * restored.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ * @param view <code>UIViewRoot</code> just created or restored
+ * (or <code>null</code> if there was no such view)
+ * @param postBack <code>true</code> if this is a post back to
+ * an existing view
+ */
+ private void setupViewController(FacesContext context, UIViewRoot view,
+ boolean postBack) {
+
+ // Is there actually a view for us to procses?
+ if (view == null) {
+ return;
+ }
+ String viewId = view.getViewId();
+ if (log.isDebugEnabled()) {
+ log.debug("setupViewController(" + viewId + ")");
+ }
+
+ // Map our view identifier to a corresponding managed bean name
+ ViewControllerMapper mapper = getViewControllerMapper(context);
+ if (mapper == null) {
+ log.warn("No ViewControllerMapper configured for this application");
+ return;
+ }
+ String viewName = mapper.mapViewId(viewId);
+
+ // Retrieve an existing instance, or one created and configured by
+ // the managed bean facility
+ ValueBinding vb =
+ context.getApplication().createValueBinding("#{" + viewName + "}");
+ ViewController vc = null;
+ try {
+ vc = (ViewController) vb.getValue(context);
+ } catch (ClassCastException e) {
+ log.warn("Bean for viewId '" + viewId + "' under name '" +
+ viewName + "' is not a ViewController");
+ return;
+ }
+ if (vc == null) {
+ log.warn("No ViewController for viewId '" + viewId +
+ "' found under name '" + viewName + "'");
+ return;
+ }
+
+ // Configure the instance properties and initialize it
+ vc.setPostBack(postBack);
+ vc.init();
+
+ // Schedule this instance for later processing as needed
+ Map map = context.getExternalContext().getRequestMap();
+ map.put(ImplConstants.VIEW_RENDERED, vc);
+ List list = (List) map.get(ImplConstants.VIEWS_INITIALIZED);
+ if (list == null) {
+ list = new ArrayList();
+ map.put(ImplConstants.VIEWS_INITIALIZED, list);
+ }
+ list.add(vc);
+
+ }
+
+
+}
Added: struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/package.html
==============================================================================
--- (empty file)
+++ struts/trunk/contrib/struts-shale/src/java/org/apache/shale/impl/package.html
Tue Oct 26 22:14:37 2004
@@ -0,0 +1,25 @@
+<!--
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!-- $Id$ -->
+
+<body>
+
+<p>This package contains the internal implementation of the core framework.
+Application deveopers will not need to utilize any APIs defined in this
+package directly.</p>
+
+</body>
Added: struts/trunk/contrib/struts-shale/src/java/org/apache/shale/package.html
==============================================================================
--- (empty file)
+++ struts/trunk/contrib/struts-shale/src/java/org/apache/shale/package.html Tue
Oct 26 22:14:37 2004
@@ -0,0 +1,24 @@
+<!--
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!-- $Id$ -->
+
+<body>
+
+<p>This package defines the fundamental interfaces and manifest constants
+for the overall controller architecture.</p>
+
+</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]