You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/02/26 15:44:59 UTC
svn commit: r631234 [1/2] - in /myfaces/orchestra/trunk/core/src:
main/java/org/apache/myfaces/orchestra/
main/java/org/apache/myfaces/orchestra/conversation/jsf/
main/java/org/apache/myfaces/orchestra/conversation/spring/
main/java/org/apache/myfaces/...
Author: skitching
Date: Tue Feb 26 06:44:53 2008
New Revision: 631234
URL: http://svn.apache.org/viewvc?rev=631234&view=rev
Log:
Tabs to spaces
Modified:
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/_JsfConversationUtils.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContext.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/_SpringUtils.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProvider.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProviderManager.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterResponseWrapper.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterServletFilter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/jsf/RequestParameterFacesContextFactory.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterViewHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerExecutor.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerExecutor.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerNameMapper.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerNameMapper.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/InterfaceViewControllerExecutor.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewController.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerExecutor.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerNameMapper.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerVariableResolver.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/spring/SpringViewControllerScope.java
myfaces/orchestra/trunk/core/src/main/tld/misc/web-jsptaglibrary_1_2.dtd
myfaces/orchestra/trunk/core/src/main/tld/myfaces_orchestra.tld
myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/DummyBean.java
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java Tue Feb 26 06:44:53 2008
@@ -27,67 +27,67 @@
*/
public final class CoreConfig
{
- private static final String BASE = CoreConfig.class.getName();
+ private static final String BASE = CoreConfig.class.getName();
- /**
- * Value "org.apache.myfaces.orchestra.CoreConfig:SERIALIZE_REQUESTS".
- * <p>
- * Controls whether two threads are prevented from accessing the same
- * ConversationContext concurrently, or not. This is generally a bad idea as it
- * can lead to ugly race conditions, so it is TRUE by default.
- * <p>
- * It is possible for multiple requests associated with the same http session to be
- * received concurrently. By default, a servlet engine simply processes all requests
- * concurrently in different threads. However that can cause all sorts of unexpected
- * problems with objects in scopes that are visible to both threads (session-scoped
- * and conversation-scoped objects).
- * <p>
- * When enabled, this option will block the thread for any request which will
- * access the same Orchestra ConversationContext as a thread that is already
- * running, and release it only when the earlier request has completed. This protects
- * all orchestra conversation-scoped objects from concurrent access, but
- * <i>does not</i> protect any session-scoped objects.
- * <p>
- * When using Orchestra, it is recommended that session-scoped objects are avoided
- * conversation-scoped beans used instead. If there is no session-scoped data in
- * use by an application then it is safe to allow concurrent requests to the
- * same http session. If you do wish to protect normal session-scoped objects as
- * well, then the standard solution is to write a filter that uses standard java
- * synchronisation on a session-scoped object, taking the lock on request entry
- * and releasing it on request exit.
- * <p>
- * Note that the expression "serialize requests" as used here means requests are
- * processed serially, ie one after the other rather than concurrently. This has
- * nothing to do with java.io.Serializable.
- */
- public static final String SERIALIZE_REQUESTS = BASE + ":SERIALIZE_REQUESTS";
+ /**
+ * Value "org.apache.myfaces.orchestra.CoreConfig:SERIALIZE_REQUESTS".
+ * <p>
+ * Controls whether two threads are prevented from accessing the same
+ * ConversationContext concurrently, or not. This is generally a bad idea as it
+ * can lead to ugly race conditions, so it is TRUE by default.
+ * <p>
+ * It is possible for multiple requests associated with the same http session to be
+ * received concurrently. By default, a servlet engine simply processes all requests
+ * concurrently in different threads. However that can cause all sorts of unexpected
+ * problems with objects in scopes that are visible to both threads (session-scoped
+ * and conversation-scoped objects).
+ * <p>
+ * When enabled, this option will block the thread for any request which will
+ * access the same Orchestra ConversationContext as a thread that is already
+ * running, and release it only when the earlier request has completed. This protects
+ * all orchestra conversation-scoped objects from concurrent access, but
+ * <i>does not</i> protect any session-scoped objects.
+ * <p>
+ * When using Orchestra, it is recommended that session-scoped objects are avoided
+ * conversation-scoped beans used instead. If there is no session-scoped data in
+ * use by an application then it is safe to allow concurrent requests to the
+ * same http session. If you do wish to protect normal session-scoped objects as
+ * well, then the standard solution is to write a filter that uses standard java
+ * synchronisation on a session-scoped object, taking the lock on request entry
+ * and releasing it on request exit.
+ * <p>
+ * Note that the expression "serialize requests" as used here means requests are
+ * processed serially, ie one after the other rather than concurrently. This has
+ * nothing to do with java.io.Serializable.
+ */
+ public static final String SERIALIZE_REQUESTS = BASE + ":SERIALIZE_REQUESTS";
- /**
- * Value "org.apache.myfaces.orchestra.CoreConfig:CLEANUP_CONNECTIONS".
- * <p>
- * Controls whether Orchestra should monitor the set of JDBC connections borrowed
- * during a request, and clean up any that are still open at the end of the request.
- * <p>
- * Orchestra provides a special DataSource wrapper that can be configured for any
- * datasource used by the application. The datasource simply wraps all real Connection
- * objects it returns in a proxy, and keeps track of them. At the end of each request,
- * any connections borrowed by this thread but not returned can be returned
- * automatically. See ConnectionManagerDataSource for more details.
- * <p>
- * If this special DataSource is not configured, then checking for unreleased
- * connections is harmless, and always finds nothing. Therefore this option is
- * enabled by default.
- */
- public static final String CLEANUP_CONNECTIONS = BASE + ":CLEANUP_CONNECTIONS";
+ /**
+ * Value "org.apache.myfaces.orchestra.CoreConfig:CLEANUP_CONNECTIONS".
+ * <p>
+ * Controls whether Orchestra should monitor the set of JDBC connections borrowed
+ * during a request, and clean up any that are still open at the end of the request.
+ * <p>
+ * Orchestra provides a special DataSource wrapper that can be configured for any
+ * datasource used by the application. The datasource simply wraps all real Connection
+ * objects it returns in a proxy, and keeps track of them. At the end of each request,
+ * any connections borrowed by this thread but not returned can be returned
+ * automatically. See ConnectionManagerDataSource for more details.
+ * <p>
+ * If this special DataSource is not configured, then checking for unreleased
+ * connections is harmless, and always finds nothing. Therefore this option is
+ * enabled by default.
+ */
+ public static final String CLEANUP_CONNECTIONS = BASE + ":CLEANUP_CONNECTIONS";
- /**
- * Value "org.apache.myfaces.orchestra.CoreConfig:CONVERSATION_MESSAGER".
- * <p>
- * Controls what class is used to present Orchestra-related error messages to
- * the user. When not specified, the default implementation for the current
- * FrameworkAdapter (eg JsfFrameworkAdapter) is used.
- * <p>
- * See class ConversationMessager for further details.
- */
- public static final String CONVERSATION_MESSAGER = BASE + ":CONVERSATION_MESSAGER";
+ /**
+ * Value "org.apache.myfaces.orchestra.CoreConfig:CONVERSATION_MESSAGER".
+ * <p>
+ * Controls what class is used to present Orchestra-related error messages to
+ * the user. When not specified, the default implementation for the current
+ * FrameworkAdapter (eg JsfFrameworkAdapter) is used.
+ * <p>
+ * See class ConversationMessager for further details.
+ */
+ public static final String CONVERSATION_MESSAGER = BASE + ":CONVERSATION_MESSAGER";
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/_JsfConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/_JsfConversationUtils.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/_JsfConversationUtils.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/_JsfConversationUtils.java Tue Feb 26 06:44:53 2008
@@ -38,81 +38,81 @@
*/
public class _JsfConversationUtils
{
- private _JsfConversationUtils()
- {
- }
-
- /**
- * Find the first parent which is a command
- */
- public static UICommand findParentCommand(UIComponent base)
- {
- UIComponent parent = base;
- do
- {
- parent = parent.getParent();
- if (parent instanceof UICommand)
- {
- return (UICommand) parent;
- }
- }
- while (parent != null);
-
- return null;
- }
-
- /**
- * Find a child start or end conversation component for the given conversation name
- */
- public static AbstractConversationComponent findEndConversationComponent(UIComponent component, String conversationName)
- {
- Iterator iterComponents = component.getFacetsAndChildren();
- while (iterComponents.hasNext())
- {
- Object child = iterComponents.next();
- AbstractConversationComponent conversation;
-
- if (child instanceof UIEndConversation)
- {
- conversation = (AbstractConversationComponent) child;
- if (conversation.getName().equals(conversationName))
- {
- return conversation;
- }
- }
- else if (child instanceof UIComponent)
- {
- conversation = findEndConversationComponent((UIComponent) child, conversationName);
- if (conversation != null)
- {
- return conversation;
- }
- }
- }
-
- return null;
- }
-
- /**
- * end and restart a conversation
- */
- public static void endAndRestartConversation(FacesContext context, String conversationName, Boolean restart, MethodBinding restartAction)
- {
- ConversationManager conversationManager = ConversationManager.getInstance();
- Conversation conversation = conversationManager.getConversation(conversationName);
- if (conversation != null)
- {
- conversation.invalidate();
- }
-
- if (restart != null && restart.booleanValue())
- {
- FrameworkAdapter.getCurrentInstance().getBean(conversationName);
-
- if (restartAction != null)
- {
- restartAction.invoke(context, null);
- }
- }
- }
+ private _JsfConversationUtils()
+ {
+ }
+
+ /**
+ * Find the first parent which is a command
+ */
+ public static UICommand findParentCommand(UIComponent base)
+ {
+ UIComponent parent = base;
+ do
+ {
+ parent = parent.getParent();
+ if (parent instanceof UICommand)
+ {
+ return (UICommand) parent;
+ }
+ }
+ while (parent != null);
+
+ return null;
+ }
+
+ /**
+ * Find a child start or end conversation component for the given conversation name
+ */
+ public static AbstractConversationComponent findEndConversationComponent(UIComponent component, String conversationName)
+ {
+ Iterator iterComponents = component.getFacetsAndChildren();
+ while (iterComponents.hasNext())
+ {
+ Object child = iterComponents.next();
+ AbstractConversationComponent conversation;
+
+ if (child instanceof UIEndConversation)
+ {
+ conversation = (AbstractConversationComponent) child;
+ if (conversation.getName().equals(conversationName))
+ {
+ return conversation;
+ }
+ }
+ else if (child instanceof UIComponent)
+ {
+ conversation = findEndConversationComponent((UIComponent) child, conversationName);
+ if (conversation != null)
+ {
+ return conversation;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * end and restart a conversation
+ */
+ public static void endAndRestartConversation(FacesContext context, String conversationName, Boolean restart, MethodBinding restartAction)
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ Conversation conversation = conversationManager.getConversation(conversationName);
+ if (conversation != null)
+ {
+ conversation.invalidate();
+ }
+
+ if (restart != null && restart.booleanValue())
+ {
+ FrameworkAdapter.getCurrentInstance().getBean(conversationName);
+
+ if (restartAction != null)
+ {
+ restartAction.invoke(context, null);
+ }
+ }
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContext.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContext.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContext.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContext.java Tue Feb 26 06:44:53 2008
@@ -28,21 +28,21 @@
*/
public interface PersistenceContext
{
- /**
- * Make the underlying object available via the standard APIs for the underlying
- * real ORM implementation. Typically this involves doing something like binding
- * the object to the current thread.
- */
- public void bind();
+ /**
+ * Make the underlying object available via the standard APIs for the underlying
+ * real ORM implementation. Typically this involves doing something like binding
+ * the object to the current thread.
+ */
+ public void bind();
- /**
- * Unbind the underlying object, so it is no longer available via the standard
- * APIs for the underlying ORM implementation.
- */
- public void unbind();
+ /**
+ * Unbind the underlying object, so it is no longer available via the standard
+ * APIs for the underlying ORM implementation.
+ */
+ public void unbind();
- /**
- * Close the underlying persistence context.
- */
- public void close();
+ /**
+ * Close the underlying persistence context.
+ */
+ public void close();
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/_SpringUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/_SpringUtils.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/_SpringUtils.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/_SpringUtils.java Tue Feb 26 06:44:53 2008
@@ -189,17 +189,17 @@
* There is currently no way of testing whether this will happen, ie null will never
* be returned from this method.
*/
- public static Object getRealBean(Object proxy) throws Exception
- {
- Advised advised = (Advised) proxy;
- TargetSource targetSource = advised.getTargetSource();
- Object real = targetSource.getTarget();
-
- // Possibly we could add a method on the ScopedBeanTargetSource class to test
- // whether the target bean exists. Then here we could cast TargetSource to
- // ScopedBeanTargetSource and return null if the target does not exist. This
- // might be useful, but let's leave that until someone actually has a use-case
- // for that functionality.
- return real;
- }
+ public static Object getRealBean(Object proxy) throws Exception
+ {
+ Advised advised = (Advised) proxy;
+ TargetSource targetSource = advised.getTargetSource();
+ Object real = targetSource.getTarget();
+
+ // Possibly we could add a method on the ScopedBeanTargetSource class to test
+ // whether the target bean exists. Then here we could cast TargetSource to
+ // ScopedBeanTargetSource and return null if the target does not exist. This
+ // might be useful, but let's leave that until someone actually has a use-case
+ // for that functionality.
+ return real;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProvider.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProvider.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProvider.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProvider.java Tue Feb 26 06:44:53 2008
@@ -30,15 +30,15 @@
*/
public interface RequestParameterProvider
{
- /**
- * Return the names of fields this instance wants to add to the url. Each value in the
- * returned array is then used as a parameter to the getFieldValue method.
- */
- public String[] getFields();
+ /**
+ * Return the names of fields this instance wants to add to the url. Each value in the
+ * returned array is then used as a parameter to the getFieldValue method.
+ */
+ public String[] getFields();
- /**
- * Return the value for the given field (which should be one of the values returned
- * by the getFields method).
- */
- public String getFieldValue(String field);
+ /**
+ * Return the value for the given field (which should be one of the values returned
+ * by the getFields method).
+ */
+ public String getFieldValue(String field);
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProviderManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProviderManager.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProviderManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterProviderManager.java Tue Feb 26 06:44:53 2008
@@ -47,138 +47,138 @@
*/
public class RequestParameterProviderManager implements Serializable
{
- private final Log LOG = LogFactory.getLog(RequestParameterProviderManager.class);
+ private final Log LOG = LogFactory.getLog(RequestParameterProviderManager.class);
- private static final String PAGE_LINK_SEP = "#";
- private static final String PAGE_PARAMETER_SEP = "?";
- private static final String PARAMETER_SEP = "&";
- private static final String PARAMETER_PROVIDER_MANAGER_KEY = RequestParameterProviderManager.class.getName();
-
- // TODO: investigate why this is transient. At least some callers of register call
- // it only once per session, so if the session data is passed to another machine or is
- // saved then restored then it seems the registered providers will be lost when they
- // should not be...
- private transient List providers;
-
- private RequestParameterProviderManager()
- {
- }
-
- public static RequestParameterProviderManager getInstance()
- {
- RequestParameterProviderManager manager =
- (RequestParameterProviderManager) FrameworkAdapter.getCurrentInstance().getSessionAttribute(PARAMETER_PROVIDER_MANAGER_KEY);
-
- if (manager == null)
- {
- // TODO: remove this factory code. Not IOC-friendly.
- manager = new RequestParameterProviderManager();
- FrameworkAdapter.getCurrentInstance().setSessionAttribute(PARAMETER_PROVIDER_MANAGER_KEY, manager);
- }
-
- return manager;
- }
-
-
- /**
- * Register the given provider.
- *
- * @param provider the provider to register.
- */
-
- public void register(RequestParameterProvider provider)
- {
- if (provider == null)
- {
- LOG.warn("RequestParameterProvider is null -> no registration!");
- }
- else
- {
- getProviders().add(provider);
- }
- }
-
-
- /**
- * Encode all fields of all providers, and attach the name-value pairs to url.
- *
- * @param url the URL to which the fields should be attached.
- * @return the url after attaching all fields.
- */
-
- public String encodeAndAttachParameters(String url)
- {
- if (!isResponseIntercepted())
- {
- throw new IllegalStateException("RequestParameterServletFilter not called. Please configure the filter " + RequestParameterServletFilter.class.getName() + " in your web.xml to cover your faces requests.");
- }
-
- if (PAGE_LINK_SEP.equals(url))
- {
- // just an inner page link, ignore
- return url;
- }
-
- StringBuffer sb = new StringBuffer();
- if (url == null)
- {
- LOG.warn("URL is null -> empty string is returned.");
- return sb.toString();
- }
-
- int nuofParams = -1;
- String firstSeparator = url.indexOf(PAGE_PARAMETER_SEP) == -1 ? PAGE_PARAMETER_SEP : PARAMETER_SEP;
- int pageLinkPos = url.indexOf(PAGE_LINK_SEP);
- if (pageLinkPos < 0)
- {
- sb.append(url);
- }
- else
- {
- sb.append(url.substring(0, pageLinkPos));
- }
-
- for (Iterator it = getProviders().iterator(); it.hasNext();)
- {
- RequestParameterProvider provider = (RequestParameterProvider) it.next();
- String[] fields = provider.getFields();
- if (fields == null)
- {
- continue;
- }
- for (int i = 0; i < fields.length; i++)
- {
- nuofParams++;
-
- sb.append(nuofParams == 0 ? firstSeparator : PARAMETER_SEP);
- sb.append(fields[i]);
- sb.append("=");
- sb.append(provider.getFieldValue(fields[i]));
- }
- }
-
- if (pageLinkPos > -1)
- {
- sb.append(url.substring(pageLinkPos));
- }
- return sb.toString();
- }
-
- protected boolean isResponseIntercepted()
- {
- FrameworkAdapter fa = FrameworkAdapter.getCurrentInstance();
-
- return Boolean.TRUE.equals(fa.getRequestAttribute(RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED))
- || Boolean.TRUE.equals(fa.getRequestAttribute(RequestParameterServletFilter.REQUEST_PARAM_RESPONSE_WRAPPED));
- }
-
- protected List getProviders()
- {
- if (providers == null)
- {
- providers = new ArrayList();
- }
+ private static final String PAGE_LINK_SEP = "#";
+ private static final String PAGE_PARAMETER_SEP = "?";
+ private static final String PARAMETER_SEP = "&";
+ private static final String PARAMETER_PROVIDER_MANAGER_KEY = RequestParameterProviderManager.class.getName();
+
+ // TODO: investigate why this is transient. At least some callers of register call
+ // it only once per session, so if the session data is passed to another machine or is
+ // saved then restored then it seems the registered providers will be lost when they
+ // should not be...
+ private transient List providers;
+
+ private RequestParameterProviderManager()
+ {
+ }
+
+ public static RequestParameterProviderManager getInstance()
+ {
+ RequestParameterProviderManager manager =
+ (RequestParameterProviderManager) FrameworkAdapter.getCurrentInstance().getSessionAttribute(PARAMETER_PROVIDER_MANAGER_KEY);
+
+ if (manager == null)
+ {
+ // TODO: remove this factory code. Not IOC-friendly.
+ manager = new RequestParameterProviderManager();
+ FrameworkAdapter.getCurrentInstance().setSessionAttribute(PARAMETER_PROVIDER_MANAGER_KEY, manager);
+ }
+
+ return manager;
+ }
+
+
+ /**
+ * Register the given provider.
+ *
+ * @param provider the provider to register.
+ */
+
+ public void register(RequestParameterProvider provider)
+ {
+ if (provider == null)
+ {
+ LOG.warn("RequestParameterProvider is null -> no registration!");
+ }
+ else
+ {
+ getProviders().add(provider);
+ }
+ }
+
+
+ /**
+ * Encode all fields of all providers, and attach the name-value pairs to url.
+ *
+ * @param url the URL to which the fields should be attached.
+ * @return the url after attaching all fields.
+ */
+
+ public String encodeAndAttachParameters(String url)
+ {
+ if (!isResponseIntercepted())
+ {
+ throw new IllegalStateException("RequestParameterServletFilter not called. Please configure the filter " + RequestParameterServletFilter.class.getName() + " in your web.xml to cover your faces requests.");
+ }
+
+ if (PAGE_LINK_SEP.equals(url))
+ {
+ // just an inner page link, ignore
+ return url;
+ }
+
+ StringBuffer sb = new StringBuffer();
+ if (url == null)
+ {
+ LOG.warn("URL is null -> empty string is returned.");
+ return sb.toString();
+ }
+
+ int nuofParams = -1;
+ String firstSeparator = url.indexOf(PAGE_PARAMETER_SEP) == -1 ? PAGE_PARAMETER_SEP : PARAMETER_SEP;
+ int pageLinkPos = url.indexOf(PAGE_LINK_SEP);
+ if (pageLinkPos < 0)
+ {
+ sb.append(url);
+ }
+ else
+ {
+ sb.append(url.substring(0, pageLinkPos));
+ }
+
+ for (Iterator it = getProviders().iterator(); it.hasNext();)
+ {
+ RequestParameterProvider provider = (RequestParameterProvider) it.next();
+ String[] fields = provider.getFields();
+ if (fields == null)
+ {
+ continue;
+ }
+ for (int i = 0; i < fields.length; i++)
+ {
+ nuofParams++;
+
+ sb.append(nuofParams == 0 ? firstSeparator : PARAMETER_SEP);
+ sb.append(fields[i]);
+ sb.append("=");
+ sb.append(provider.getFieldValue(fields[i]));
+ }
+ }
+
+ if (pageLinkPos > -1)
+ {
+ sb.append(url.substring(pageLinkPos));
+ }
+ return sb.toString();
+ }
+
+ protected boolean isResponseIntercepted()
+ {
+ FrameworkAdapter fa = FrameworkAdapter.getCurrentInstance();
+
+ return Boolean.TRUE.equals(fa.getRequestAttribute(RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED))
+ || Boolean.TRUE.equals(fa.getRequestAttribute(RequestParameterServletFilter.REQUEST_PARAM_RESPONSE_WRAPPED));
+ }
+
+ protected List getProviders()
+ {
+ if (providers == null)
+ {
+ providers = new ArrayList();
+ }
- return providers;
- }
+ return providers;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterResponseWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterResponseWrapper.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterResponseWrapper.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterResponseWrapper.java Tue Feb 26 06:44:53 2008
@@ -26,36 +26,36 @@
*/
public class RequestParameterResponseWrapper extends HttpServletResponseWrapper
{
- public RequestParameterResponseWrapper(HttpServletResponse httpServletResponse)
- {
+ public RequestParameterResponseWrapper(HttpServletResponse httpServletResponse)
+ {
super(httpServletResponse);
- }
+ }
/**
- * @param url the url to encode
- * @return wrappedResponse.encodeUrl(url);
- */
- public String encodeURL(String url)
- {
- if (url != null)
- {
+ * @param url the url to encode
+ * @return wrappedResponse.encodeUrl(url);
+ */
+ public String encodeURL(String url)
+ {
+ if (url != null)
+ {
url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
- }
+ }
- return super.encodeURL(url);
- }
+ return super.encodeURL(url);
+ }
- /**
- * Override deprecated form of this method, in case users call it.
- * <p>
- * The inherited implementation of this method calls super.encodeUrl(url)
- * directly, which would bypass our custom code.
- *
- * @since 1.1
- * @deprecated
- */
- public String encodeUrl(String url)
- {
- return encodeURL(url);
- }
+ /**
+ * Override deprecated form of this method, in case users call it.
+ * <p>
+ * The inherited implementation of this method calls super.encodeUrl(url)
+ * directly, which would bypass our custom code.
+ *
+ * @since 1.1
+ * @deprecated
+ */
+ public String encodeUrl(String url)
+ {
+ return encodeURL(url);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterServletFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterServletFilter.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterServletFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/RequestParameterServletFilter.java Tue Feb 26 06:44:53 2008
@@ -35,35 +35,35 @@
*/
public class RequestParameterServletFilter implements Filter
{
- public final static String REQUEST_PARAM_FILTER_CALLED = RequestParameterServletFilter.class.getName() + ".CALLED";
- public final static String REQUEST_PARAM_RESPONSE_WRAPPED = RequestParameterServletFilter.class.getName() + ".WRAPPED";
+ public final static String REQUEST_PARAM_FILTER_CALLED = RequestParameterServletFilter.class.getName() + ".CALLED";
+ public final static String REQUEST_PARAM_RESPONSE_WRAPPED = RequestParameterServletFilter.class.getName() + ".WRAPPED";
- public RequestParameterServletFilter()
- {
- }
+ public RequestParameterServletFilter()
+ {
+ }
- public void init(FilterConfig filterConfig)
- {
- }
+ public void init(FilterConfig filterConfig)
+ {
+ }
- public void doFilter(ServletRequest servletRequest,
- ServletResponse servletResponse,
- FilterChain filterChain) throws IOException, ServletException
- {
- if (servletResponse instanceof HttpServletResponse)
- {
- HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
- if (!Boolean.TRUE.equals(httpServletRequest.getAttribute(REQUEST_PARAM_FILTER_CALLED)))
- {
- httpServletRequest.setAttribute(REQUEST_PARAM_FILTER_CALLED, Boolean.TRUE);
- servletResponse = new RequestParameterResponseWrapper((HttpServletResponse) servletResponse);
- }
- }
+ public void doFilter(ServletRequest servletRequest,
+ ServletResponse servletResponse,
+ FilterChain filterChain) throws IOException, ServletException
+ {
+ if (servletResponse instanceof HttpServletResponse)
+ {
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+ if (!Boolean.TRUE.equals(httpServletRequest.getAttribute(REQUEST_PARAM_FILTER_CALLED)))
+ {
+ httpServletRequest.setAttribute(REQUEST_PARAM_FILTER_CALLED, Boolean.TRUE);
+ servletResponse = new RequestParameterResponseWrapper((HttpServletResponse) servletResponse);
+ }
+ }
- filterChain.doFilter(servletRequest, servletResponse);
- }
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
- public void destroy()
- {
- }
+ public void destroy()
+ {
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/jsf/RequestParameterFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/jsf/RequestParameterFacesContextFactory.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/jsf/RequestParameterFacesContextFactory.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/requestParameterProvider/jsf/RequestParameterFacesContextFactory.java Tue Feb 26 06:44:53 2008
@@ -42,31 +42,31 @@
*/
public class RequestParameterFacesContextFactory extends FacesContextFactory
{
- private final FacesContextFactory original;
+ private final FacesContextFactory original;
- public RequestParameterFacesContextFactory(FacesContextFactory original)
- {
- this.original = original;
- }
-
- /**
- * Invokes the getFacesContext method on the original factory in order to return a
- * perfectly normal FacesContext instance. However the ServletResponse object passed
- * to that FacesContext instance is a modified one that tweaks every url that is
- * processed by the ServletResponse.encodeUrl method.
- */
- public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) throws FacesException
- {
- if (response instanceof HttpServletResponse)
- {
- HttpServletRequest httpServletRequest = (HttpServletRequest) request;
-
- // Wrap this request only if something else (eg a RequestParameterServletFilter) has not already wrapped it.
- if (!Boolean.TRUE.equals(httpServletRequest.getAttribute(RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED)))
- {
- // No servlet filter has wrapped the response, so do it now for the response referenced by this FacesContext.
- // Note that this wrapper will therefore apply to all output generated via the FacesContext, but not to
- // anything that might be written by filters etc.
+ public RequestParameterFacesContextFactory(FacesContextFactory original)
+ {
+ this.original = original;
+ }
+
+ /**
+ * Invokes the getFacesContext method on the original factory in order to return a
+ * perfectly normal FacesContext instance. However the ServletResponse object passed
+ * to that FacesContext instance is a modified one that tweaks every url that is
+ * processed by the ServletResponse.encodeUrl method.
+ */
+ public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) throws FacesException
+ {
+ if (response instanceof HttpServletResponse)
+ {
+ HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+
+ // Wrap this request only if something else (eg a RequestParameterServletFilter) has not already wrapped it.
+ if (!Boolean.TRUE.equals(httpServletRequest.getAttribute(RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED)))
+ {
+ // No servlet filter has wrapped the response, so do it now for the response referenced by this FacesContext.
+ // Note that this wrapper will therefore apply to all output generated via the FacesContext, but not to
+ // anything that might be written by filters etc.
response = new RequestParameterResponseWrapper((HttpServletResponse) response);
// We now need to reassure the RequestParameterProviderManager that the response has indeed been
@@ -74,16 +74,16 @@
//
// However we can not just set the REQUEST_PARAMETER_FILTER_CALLED flag here. If code creates its own
// FacesContext instance for any reason while a request is running, then this method is called again.
- // On the second call this flag would already be set and the response would not be wrapped as required.
- //
- // Therefore we have two separate flags; RequestParameterProviderManager checks whether either
+ // On the second call this flag would already be set and the response would not be wrapped as required.
+ //
+ // Therefore we have two separate flags; RequestParameterProviderManager checks whether either
// REQUEST_PARAM_FILTER_CALLED or REQUEST_PARAM_RESPONSE_WRAPPED has been set.
httpServletRequest.setAttribute(RequestParameterServletFilter.REQUEST_PARAM_RESPONSE_WRAPPED, Boolean.TRUE);
- }
- }
+ }
+ }
- return original.getFacesContext(context, request, response, lifecycle);
- }
+ return original.getFacesContext(context, request, response, lifecycle);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterNavigationHandler.java Tue Feb 26 06:44:53 2008
@@ -31,15 +31,15 @@
*/
public class UrlParameterNavigationHandler extends NavigationHandler
{
- private final NavigationHandler original;
+ private final NavigationHandler original;
- public UrlParameterNavigationHandler(final NavigationHandler original)
- {
- this.original = original;
- }
+ public UrlParameterNavigationHandler(final NavigationHandler original)
+ {
+ this.original = original;
+ }
- public void handleNavigation(final FacesContext context, String fromAction, String outcome)
- {
- original.handleNavigation(context, fromAction, outcome);
- }
+ public void handleNavigation(final FacesContext context, String fromAction, String outcome)
+ {
+ original.handleNavigation(context, fromAction, outcome);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterViewHandler.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterViewHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/urlParamNav/UrlParameterViewHandler.java Tue Feb 26 06:44:53 2008
@@ -36,107 +36,107 @@
*/
public class UrlParameterViewHandler extends ViewHandler
{
- private final ViewHandler original;
+ private final ViewHandler original;
- public UrlParameterViewHandler(final ViewHandler original)
- {
- this.original = original;
- }
-
- public Locale calculateLocale(FacesContext context)
- {
- return original.calculateLocale(context);
- }
-
- public String calculateRenderKitId(FacesContext context)
- {
- return original.calculateRenderKitId(context);
- }
-
- public UIViewRoot createView(FacesContext context, String viewId)
- {
- return original.createView(context, viewId);
- }
-
- public String getActionURL(FacesContext context, String viewId)
- {
- if (viewId != null)
- {
- // Expand any EL expression in the URL.
- //
- // This handles a call from a NavigationHandler which is processing a redirect
- // navigation case. A NavigationHandler must call the following in order:
- // * ViewHandler.getActionURL,
- // * ExternalContext.encodeActionURL
- // * ExternalContext.redirect
- //
- // Orchestra hooks into ExternalContext.encodeActionURL to trigger the
- // RequestParameterProviderManager whch then inserts various query params
- // into the URL.
- //
- // So here, ensure that any EL expressions are expanded before the
- // RequestParameterProviderManager is invoked. An alternative would be for
- // the RequestParameterProviderManager to do the encoding, but at the current
- // time that class is not JSF-dependent in any way, so calling JSF expression
- // expansion from there is not possible.
- //
- // Note that this method is also called from a Form component when rendering
- // its 'action' attribute. This code therefore has the side-effect of
- // permitting EL expressions in a form's action. This is not particularly
- // useful, however, as they are expected to have been expanded before this
- // method is invoked..
- viewId = expandExpressions(context, viewId);
-
- // Hide query parameters from the standard ViewHandlerImpl. The standard
- // implementation of ViewHandlerImpl.getActionUrl method does not handle
- // query params well. So strip them off, invoke the processing, then reattach
- // them afterwards.
- int pos = viewId.indexOf('?');
- if (pos > -1)
- {
- String realViewId = viewId.substring(0, pos);
- String params = viewId.substring(pos);
-
- return original.getActionURL(context, realViewId) + params;
- }
- }
- return original.getActionURL(context, viewId);
- }
-
- public String getResourceURL(FacesContext context, String path)
- {
- return original.getResourceURL(context, path);
- }
-
- public void renderView(FacesContext context, UIViewRoot viewToRender)
- throws IOException, FacesException
- {
- original.renderView(context, viewToRender);
- }
-
- public UIViewRoot restoreView(FacesContext context, String viewId)
- {
- return original.restoreView(context, viewId);
- }
-
- public void writeState(FacesContext context)
- throws IOException
- {
- original.writeState(context);
- }
-
- private static String expandExpressions(FacesContext context, String url)
- {
- int pos = url.indexOf("#{");
- if (pos > -1 && url.indexOf("}", pos) > -1)
- {
- // There is at least one EL expression, so evaluate the whole url string.
- // Note that something like "aaa#{foo}bbb#{bar}ccc" is fine; both the
- // el expressions will get replaced.
- ValueBinding vb = context.getApplication().createValueBinding(url);
- return (String) vb.getValue(context);
- }
+ public UrlParameterViewHandler(final ViewHandler original)
+ {
+ this.original = original;
+ }
+
+ public Locale calculateLocale(FacesContext context)
+ {
+ return original.calculateLocale(context);
+ }
+
+ public String calculateRenderKitId(FacesContext context)
+ {
+ return original.calculateRenderKitId(context);
+ }
+
+ public UIViewRoot createView(FacesContext context, String viewId)
+ {
+ return original.createView(context, viewId);
+ }
+
+ public String getActionURL(FacesContext context, String viewId)
+ {
+ if (viewId != null)
+ {
+ // Expand any EL expression in the URL.
+ //
+ // This handles a call from a NavigationHandler which is processing a redirect
+ // navigation case. A NavigationHandler must call the following in order:
+ // * ViewHandler.getActionURL,
+ // * ExternalContext.encodeActionURL
+ // * ExternalContext.redirect
+ //
+ // Orchestra hooks into ExternalContext.encodeActionURL to trigger the
+ // RequestParameterProviderManager whch then inserts various query params
+ // into the URL.
+ //
+ // So here, ensure that any EL expressions are expanded before the
+ // RequestParameterProviderManager is invoked. An alternative would be for
+ // the RequestParameterProviderManager to do the encoding, but at the current
+ // time that class is not JSF-dependent in any way, so calling JSF expression
+ // expansion from there is not possible.
+ //
+ // Note that this method is also called from a Form component when rendering
+ // its 'action' attribute. This code therefore has the side-effect of
+ // permitting EL expressions in a form's action. This is not particularly
+ // useful, however, as they are expected to have been expanded before this
+ // method is invoked..
+ viewId = expandExpressions(context, viewId);
+
+ // Hide query parameters from the standard ViewHandlerImpl. The standard
+ // implementation of ViewHandlerImpl.getActionUrl method does not handle
+ // query params well. So strip them off, invoke the processing, then reattach
+ // them afterwards.
+ int pos = viewId.indexOf('?');
+ if (pos > -1)
+ {
+ String realViewId = viewId.substring(0, pos);
+ String params = viewId.substring(pos);
+
+ return original.getActionURL(context, realViewId) + params;
+ }
+ }
+ return original.getActionURL(context, viewId);
+ }
+
+ public String getResourceURL(FacesContext context, String path)
+ {
+ return original.getResourceURL(context, path);
+ }
+
+ public void renderView(FacesContext context, UIViewRoot viewToRender)
+ throws IOException, FacesException
+ {
+ original.renderView(context, viewToRender);
+ }
+
+ public UIViewRoot restoreView(FacesContext context, String viewId)
+ {
+ return original.restoreView(context, viewId);
+ }
+
+ public void writeState(FacesContext context)
+ throws IOException
+ {
+ original.writeState(context);
+ }
+
+ private static String expandExpressions(FacesContext context, String url)
+ {
+ int pos = url.indexOf("#{");
+ if (pos > -1 && url.indexOf("}", pos) > -1)
+ {
+ // There is at least one EL expression, so evaluate the whole url string.
+ // Note that something like "aaa#{foo}bbb#{bar}ccc" is fine; both the
+ // el expressions will get replaced.
+ ValueBinding vb = context.getApplication().createValueBinding(url);
+ return (String) vb.getValue(context);
+ }
- return url;
- }
+ return url;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerExecutor.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerExecutor.java Tue Feb 26 06:44:53 2008
@@ -30,18 +30,18 @@
*/
public abstract class AbstractViewControllerExecutor implements ViewControllerExecutor
{
- public boolean invokeInitView(String beanName, Object bean)
- {
- return false;
- }
+ public boolean invokeInitView(String beanName, Object bean)
+ {
+ return false;
+ }
- public boolean invokePreRenderView(String beanName, Object bean)
- {
- return false;
- }
+ public boolean invokePreRenderView(String beanName, Object bean)
+ {
+ return false;
+ }
public boolean invokePreProcess(String beanName, Object bean)
{
- return false;
+ return false;
}
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/AbstractViewControllerManager.java Tue Feb 26 06:44:53 2008
@@ -39,57 +39,57 @@
*/
public abstract class AbstractViewControllerManager implements ViewControllerManager
{
- protected abstract ViewControllerNameMapper getViewControllerNameMapper();
- protected abstract ViewControllerExecutor getViewControllerExecutor();
+ protected abstract ViewControllerNameMapper getViewControllerNameMapper();
+ protected abstract ViewControllerExecutor getViewControllerExecutor();
- public String getViewControllerName(String viewId)
- {
- ViewControllerNameMapper nameMapper = getViewControllerNameMapper();
- return nameMapper.mapViewId(viewId);
- }
-
- public Object getViewController(String viewId)
- {
- String beanName = getViewControllerName(viewId);
- if (beanName == null)
- {
- return null;
- }
-
- return FrameworkAdapter.getCurrentInstance().getBean(beanName);
- }
-
- public void assertConversationState(String viewId)
- {
- }
-
- public void executeInitView(String viewId)
- {
- String beanName = getViewControllerNameMapper().mapViewId(viewId);
- Object viewController = getViewController(viewId);
- if (viewController != null)
- {
- getViewControllerExecutor().invokeInitView(beanName, viewController);
- }
- }
-
- public void executePreProcess(String viewId)
- {
- String beanName = getViewControllerNameMapper().mapViewId(viewId);
- Object viewController = getViewController(viewId);
- if (viewController != null)
- {
- getViewControllerExecutor().invokePreProcess(beanName, viewController);
- }
- }
-
- public void executePreRenderView(String viewId)
- {
- String beanName = getViewControllerNameMapper().mapViewId(viewId);
- Object viewController = getViewController(viewId);
- if (viewController != null)
- {
- getViewControllerExecutor().invokePreRenderView(beanName, viewController);
- }
- }
+ public String getViewControllerName(String viewId)
+ {
+ ViewControllerNameMapper nameMapper = getViewControllerNameMapper();
+ return nameMapper.mapViewId(viewId);
+ }
+
+ public Object getViewController(String viewId)
+ {
+ String beanName = getViewControllerName(viewId);
+ if (beanName == null)
+ {
+ return null;
+ }
+
+ return FrameworkAdapter.getCurrentInstance().getBean(beanName);
+ }
+
+ public void assertConversationState(String viewId)
+ {
+ }
+
+ public void executeInitView(String viewId)
+ {
+ String beanName = getViewControllerNameMapper().mapViewId(viewId);
+ Object viewController = getViewController(viewId);
+ if (viewController != null)
+ {
+ getViewControllerExecutor().invokeInitView(beanName, viewController);
+ }
+ }
+
+ public void executePreProcess(String viewId)
+ {
+ String beanName = getViewControllerNameMapper().mapViewId(viewId);
+ Object viewController = getViewController(viewId);
+ if (viewController != null)
+ {
+ getViewControllerExecutor().invokePreProcess(beanName, viewController);
+ }
+ }
+
+ public void executePreRenderView(String viewId)
+ {
+ String beanName = getViewControllerNameMapper().mapViewId(viewId);
+ Object viewController = getViewController(viewId);
+ if (viewController != null)
+ {
+ getViewControllerExecutor().invokePreRenderView(beanName, viewController);
+ }
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerExecutor.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerExecutor.java Tue Feb 26 06:44:53 2008
@@ -28,51 +28,51 @@
*/
public class CompositeViewControllerExecutor implements ViewControllerExecutor
{
- private final ViewControllerExecutor[] viewControllerExecutors;
+ private final ViewControllerExecutor[] viewControllerExecutors;
- public CompositeViewControllerExecutor(ViewControllerExecutor[] viewControllerExecutors)
- {
- this.viewControllerExecutors = new ViewControllerExecutor[viewControllerExecutors.length];
- System.arraycopy(viewControllerExecutors, 0, this.viewControllerExecutors, 0, viewControllerExecutors.length);
- }
-
-
- public boolean invokeInitView(String beanName, Object bean)
- {
- for (int i = 0; i< viewControllerExecutors.length; i++)
- {
- if (viewControllerExecutors[i].invokeInitView(beanName, bean))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean invokePreRenderView(String beanName, Object bean)
- {
- for (int i = 0; i< viewControllerExecutors.length; i++)
- {
- if (viewControllerExecutors[i].invokePreRenderView(beanName, bean))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean invokePreProcess(String beanName, Object bean)
- {
- for (int i = 0; i< viewControllerExecutors.length; i++)
- {
- if (viewControllerExecutors[i].invokePreProcess(beanName, bean))
- {
- return true;
- }
- }
+ public CompositeViewControllerExecutor(ViewControllerExecutor[] viewControllerExecutors)
+ {
+ this.viewControllerExecutors = new ViewControllerExecutor[viewControllerExecutors.length];
+ System.arraycopy(viewControllerExecutors, 0, this.viewControllerExecutors, 0, viewControllerExecutors.length);
+ }
+
+
+ public boolean invokeInitView(String beanName, Object bean)
+ {
+ for (int i = 0; i< viewControllerExecutors.length; i++)
+ {
+ if (viewControllerExecutors[i].invokeInitView(beanName, bean))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public boolean invokePreRenderView(String beanName, Object bean)
+ {
+ for (int i = 0; i< viewControllerExecutors.length; i++)
+ {
+ if (viewControllerExecutors[i].invokePreRenderView(beanName, bean))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public boolean invokePreProcess(String beanName, Object bean)
+ {
+ for (int i = 0; i< viewControllerExecutors.length; i++)
+ {
+ if (viewControllerExecutors[i].invokePreProcess(beanName, bean))
+ {
+ return true;
+ }
+ }
- return false;
- }
+ return false;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerNameMapper.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerNameMapper.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/CompositeViewControllerNameMapper.java Tue Feb 26 06:44:53 2008
@@ -28,25 +28,25 @@
*/
public class CompositeViewControllerNameMapper implements ViewControllerNameMapper
{
- private final ViewControllerNameMapper[] viewControllerNameMappers;
+ private final ViewControllerNameMapper[] viewControllerNameMappers;
- public CompositeViewControllerNameMapper(ViewControllerNameMapper[] viewControllerNameMappers)
- {
- this.viewControllerNameMappers = new ViewControllerNameMapper[viewControllerNameMappers.length];
- System.arraycopy(viewControllerNameMappers, 0, this.viewControllerNameMappers, 0, viewControllerNameMappers.length);
- }
+ public CompositeViewControllerNameMapper(ViewControllerNameMapper[] viewControllerNameMappers)
+ {
+ this.viewControllerNameMappers = new ViewControllerNameMapper[viewControllerNameMappers.length];
+ System.arraycopy(viewControllerNameMappers, 0, this.viewControllerNameMappers, 0, viewControllerNameMappers.length);
+ }
- public String mapViewId(String viewId)
- {
- for (int i = 0; i<viewControllerNameMappers.length; i++)
- {
- String beanName = viewControllerNameMappers[i].mapViewId(viewId);
- if (beanName != null)
- {
- return beanName;
- }
- }
+ public String mapViewId(String viewId)
+ {
+ for (int i = 0; i<viewControllerNameMappers.length; i++)
+ {
+ String beanName = viewControllerNameMappers[i].mapViewId(viewId);
+ if (beanName != null)
+ {
+ return beanName;
+ }
+ }
- return null;
- }
+ return null;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerNameMapper.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerNameMapper.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/DefaultViewControllerNameMapper.java Tue Feb 26 06:44:53 2008
@@ -102,85 +102,85 @@
*/
public class DefaultViewControllerNameMapper implements ViewControllerNameMapper
{
- /**
- * An unmodifiable set of strings which are not permitted as bean-names.
- * <p>
- * If the mapping of any viewId to a bean-name results in one of these values,
- * then the name-mapper must modify the result.
- * <p>
- * TODO: move this list to some shared class. Other ViewControllerNameMapper
- * implementations could find this list useful. Note, however, that it is
- * servlet-specific. This class is supposed to not assume any particular
- * request/response technology.
- */
- private static final Set RESERVED_WORDS = new HashSet(Arrays.asList(
- new String[]
- {
- "applicationScope",
- "cookie",
- "facesContext",
- "header",
- "headerValues",
- "initParam",
- "param",
- "paramValues",
- "requestScope",
- "sessionScope",
- "view"
- }
- ));
-
-
- public String mapViewId(String viewId)
- {
- if (viewId == null)
- {
- return null;
- }
-
- boolean nextUpper = false;
-
- StringBuffer sb = new StringBuffer(viewId);
- for (int i = 0; i < sb.length(); i++)
- {
- char c = sb.charAt(i);
- if (c == '/')
- {
- if (i > 0)
- {
- nextUpper = true;
- }
- sb.deleteCharAt(i);
- i--;
- }
- else if (c == '.')
- {
- sb.delete(i, sb.length());
- break;
- }
- else if (nextUpper)
- {
- sb.setCharAt(i, Character.toUpperCase(c));
- nextUpper = false;
- }
- }
-
- if (sb.length() > 0)
- {
- sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
- }
-
- String beanName = sb.toString();
- if (RESERVED_WORDS.contains(beanName))
- {
- return "_" + beanName;
- }
-
- if (beanName.length() > 0 && Character.isDigit(beanName.charAt(0)))
- {
- return "_" + beanName;
- }
+ /**
+ * An unmodifiable set of strings which are not permitted as bean-names.
+ * <p>
+ * If the mapping of any viewId to a bean-name results in one of these values,
+ * then the name-mapper must modify the result.
+ * <p>
+ * TODO: move this list to some shared class. Other ViewControllerNameMapper
+ * implementations could find this list useful. Note, however, that it is
+ * servlet-specific. This class is supposed to not assume any particular
+ * request/response technology.
+ */
+ private static final Set RESERVED_WORDS = new HashSet(Arrays.asList(
+ new String[]
+ {
+ "applicationScope",
+ "cookie",
+ "facesContext",
+ "header",
+ "headerValues",
+ "initParam",
+ "param",
+ "paramValues",
+ "requestScope",
+ "sessionScope",
+ "view"
+ }
+ ));
+
+
+ public String mapViewId(String viewId)
+ {
+ if (viewId == null)
+ {
+ return null;
+ }
+
+ boolean nextUpper = false;
+
+ StringBuffer sb = new StringBuffer(viewId);
+ for (int i = 0; i < sb.length(); i++)
+ {
+ char c = sb.charAt(i);
+ if (c == '/')
+ {
+ if (i > 0)
+ {
+ nextUpper = true;
+ }
+ sb.deleteCharAt(i);
+ i--;
+ }
+ else if (c == '.')
+ {
+ sb.delete(i, sb.length());
+ break;
+ }
+ else if (nextUpper)
+ {
+ sb.setCharAt(i, Character.toUpperCase(c));
+ nextUpper = false;
+ }
+ }
+
+ if (sb.length() > 0)
+ {
+ sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+ }
+
+ String beanName = sb.toString();
+ if (RESERVED_WORDS.contains(beanName))
+ {
+ return "_" + beanName;
+ }
+
+ if (beanName.length() > 0 && Character.isDigit(beanName.charAt(0)))
+ {
+ return "_" + beanName;
+ }
- return beanName;
- }
+ return beanName;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/InterfaceViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/InterfaceViewControllerExecutor.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/InterfaceViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/InterfaceViewControllerExecutor.java Tue Feb 26 06:44:53 2008
@@ -34,33 +34,33 @@
*/
public class InterfaceViewControllerExecutor extends AbstractViewControllerExecutor
{
- public boolean invokeInitView(String beanName, Object bean)
- {
- if (bean instanceof ViewController)
- {
- ((ViewController) bean).initView();
- return true;
- }
- return false;
- }
+ public boolean invokeInitView(String beanName, Object bean)
+ {
+ if (bean instanceof ViewController)
+ {
+ ((ViewController) bean).initView();
+ return true;
+ }
+ return false;
+ }
- public boolean invokePreRenderView(String beanName, Object bean)
- {
- if (bean instanceof ViewController)
- {
- ((ViewController) bean).preRenderView();
- return true;
- }
- return false;
- }
+ public boolean invokePreRenderView(String beanName, Object bean)
+ {
+ if (bean instanceof ViewController)
+ {
+ ((ViewController) bean).preRenderView();
+ return true;
+ }
+ return false;
+ }
public boolean invokePreProcess(String beanName, Object bean)
{
if (bean instanceof ViewController)
{
((ViewController) bean).preProcess();
- return true;
- }
- return false;
- }
+ return true;
+ }
+ return false;
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ReflectiveViewControllerExecutor.java Tue Feb 26 06:44:53 2008
@@ -41,45 +41,45 @@
*/
public class ReflectiveViewControllerExecutor extends AbstractViewControllerExecutor
{
- /**
- * Helper method to find the method which should get invoked.
- */
- protected boolean invokeOnViewController(Object bean, String methodName)
- {
- try
- {
- Method method = bean.getClass().getMethod(methodName, (Class[]) null); // NON-NLS
- method.invoke(bean, (Object[]) null);
- }
- catch (NoSuchMethodException e)
- {
- return false;
- }
- catch (IllegalAccessException e)
- {
- throw new OrchestraException(e);
- }
- catch (InvocationTargetException e)
- {
- throw new OrchestraException(e);
- }
+ /**
+ * Helper method to find the method which should get invoked.
+ */
+ protected boolean invokeOnViewController(Object bean, String methodName)
+ {
+ try
+ {
+ Method method = bean.getClass().getMethod(methodName, (Class[]) null); // NON-NLS
+ method.invoke(bean, (Object[]) null);
+ }
+ catch (NoSuchMethodException e)
+ {
+ return false;
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new OrchestraException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new OrchestraException(e);
+ }
- return true;
- }
+ return true;
+ }
- /* the ViewControllerExecutor interface */
- public boolean invokeInitView(String beanName, Object bean)
- {
- return invokeOnViewController(bean, "initView");
- }
+ /* the ViewControllerExecutor interface */
+ public boolean invokeInitView(String beanName, Object bean)
+ {
+ return invokeOnViewController(bean, "initView");
+ }
- public boolean invokePreRenderView(String beanName, Object bean)
- {
- return invokeOnViewController(bean, "preRenderView");
- }
+ public boolean invokePreRenderView(String beanName, Object bean)
+ {
+ return invokeOnViewController(bean, "preRenderView");
+ }
- public boolean invokePreProcess(String beanName, Object bean)
- {
- return invokeOnViewController(bean, "preProcess");
- }
+ public boolean invokePreProcess(String beanName, Object bean)
+ {
+ return invokeOnViewController(bean, "preProcess");
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewController.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewController.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewController.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewController.java Tue Feb 26 06:44:53 2008
@@ -33,9 +33,9 @@
*/
public interface ViewController
{
- public void initView();
+ public void initView();
public void preProcess();
- public void preRenderView();
+ public void preRenderView();
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerExecutor.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerExecutor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerExecutor.java Tue Feb 26 06:44:53 2008
@@ -35,9 +35,9 @@
*/
public interface ViewControllerExecutor
{
- public boolean invokeInitView(String beanName, Object bean);
+ public boolean invokeInitView(String beanName, Object bean);
- public boolean invokePreRenderView(String beanName, Object bean);
+ public boolean invokePreRenderView(String beanName, Object bean);
- public boolean invokePreProcess(String beanName, Object bean);
+ public boolean invokePreProcess(String beanName, Object bean);
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerManager.java Tue Feb 26 06:44:53 2008
@@ -59,53 +59,53 @@
*/
public interface ViewControllerManager
{
- public final static String VIEW_CONTROLLER_MANAGER_NAME = ViewControllerManager.class.getName();
+ public final static String VIEW_CONTROLLER_MANAGER_NAME = ViewControllerManager.class.getName();
- public Object getViewController(String viewId);
- public String getViewControllerName(String viewId);
+ public Object getViewController(String viewId);
+ public String getViewControllerName(String viewId);
- /**
- * Check whether any conversations required for the specified view currently exist.
- * <p>
- * TODO: Consider renaming this method. It is very Orchestra-specific, although this
- * ViewController framework is supposed to be generic. In fact this method
- * is really just a "validate view" hook, and one of the validations that can be hooked
- * in here is a conversation-check.
- */
- public void assertConversationState(String viewId);
+ /**
+ * Check whether any conversations required for the specified view currently exist.
+ * <p>
+ * TODO: Consider renaming this method. It is very Orchestra-specific, although this
+ * ViewController framework is supposed to be generic. In fact this method
+ * is really just a "validate view" hook, and one of the validations that can be hooked
+ * in here is a conversation-check.
+ */
+ public void assertConversationState(String viewId);
- /**
- * This method is guaranteed to be called before any other lifecycle method (ie any of
- * the other execute* methods on this interface. It is also guaranteed to be called
- * before any expression in a page is evaluated.
- * <p>
- * For component-based frameworks, the component tree may not yet exist.
- */
- public void executeInitView(String viewId);
+ /**
+ * This method is guaranteed to be called before any other lifecycle method (ie any of
+ * the other execute* methods on this interface. It is also guaranteed to be called
+ * before any expression in a page is evaluated.
+ * <p>
+ * For component-based frameworks, the component tree may not yet exist.
+ */
+ public void executeInitView(String viewId);
- /**
- * This method is called at most once per request for each view.
- * <p>
- * For component-based frameworks, this method gets called after all components have
- * transferred their state into associated backing beans. If validation errors have
- * occurred within the view, then this method is not invoked.
- */
- public void executePreProcess(String viewId);
+ /**
+ * This method is called at most once per request for each view.
+ * <p>
+ * For component-based frameworks, this method gets called after all components have
+ * transferred their state into associated backing beans. If validation errors have
+ * occurred within the view, then this method is not invoked.
+ */
+ public void executePreProcess(String viewId);
- /**
- * This method is called just before a view is required to render its representation
- * back to the user.
- * <p>
- * If a view X handles a "postback" event, and then navigates to a different view Y then
- * this callback does not occur for the controller bean for view X, but does get invoked
- * for the controller bean for view Y.
- * <p>
- * For component-based frameworks, the component tree may not yet exist at the time this
- * method is invoked.
- */
- public void executePreRenderView(String viewId);
-
- // TODO: implement an endView callback too (and corresponding annotation).
-
- // TODO: implement isPostback() for JSF1.1 users? This is of course built-in for JSF1.2 users...
+ /**
+ * This method is called just before a view is required to render its representation
+ * back to the user.
+ * <p>
+ * If a view X handles a "postback" event, and then navigates to a different view Y then
+ * this callback does not occur for the controller bean for view X, but does get invoked
+ * for the controller bean for view Y.
+ * <p>
+ * For component-based frameworks, the component tree may not yet exist at the time this
+ * method is invoked.
+ */
+ public void executePreRenderView(String viewId);
+
+ // TODO: implement an endView callback too (and corresponding annotation).
+
+ // TODO: implement isPostback() for JSF1.1 users? This is of course built-in for JSF1.2 users...
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerNameMapper.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerNameMapper.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/ViewControllerNameMapper.java Tue Feb 26 06:44:53 2008
@@ -30,5 +30,5 @@
*/
public interface ViewControllerNameMapper
{
- public String mapViewId(String viewId);
+ public String mapViewId(String viewId);
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java?rev=631234&r1=631233&r2=631234&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java Tue Feb 26 06:44:53 2008
@@ -50,187 +50,187 @@
*/
public class ViewControllerPhaseListener implements PhaseListener
{
- private static final long serialVersionUID = -3975277433747722402L;
+ private static final long serialVersionUID = -3975277433747722402L;
- /**
- * @since 1.1
- */
- public static class ViewControllerPhaseListenerState
- {
- private Set initedViews = new TreeSet();
-
- protected ViewControllerPhaseListenerState()
- {
- }
- }
-
- public void beforePhase(PhaseEvent event)
- {
- if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()) ||
- PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
- {
- assertConversationState(event.getFacesContext());
- if (event.getFacesContext().getResponseComplete())
- {
- // we have a redirect ... stop now
- return;
- }
- }
-
- // Try to init the view in every phase, just so we are sure to never miss it.
- // This skips the actual call if init has already happened.
- executeInitView(event.getFacesContext());
-
- if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
- {
- preRenderResponse(event.getFacesContext());
- }
-
- if (PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId()))
- {
- preInvokeApplication(event.getFacesContext());
- }
- }
-
- public void afterPhase(PhaseEvent event)
- {
- if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()))
- {
- assertConversationState(event.getFacesContext());
- if (event.getFacesContext().getResponseComplete())
- {
- // we have a redirect ... stop now
- return;
- }
- }
-
- executeInitView(event.getFacesContext());
- }
-
- public PhaseId getPhaseId()
- {
- return PhaseId.ANY_PHASE;
- }
-
- protected String getViewId(FacesContext facesContext)
- {
- UIViewRoot viewRoot = facesContext.getViewRoot();
- if (viewRoot == null)
- {
- return null;
- }
- return viewRoot.getViewId();
- }
-
- /**
- * invoked multiple times during the lifecycle to ensure the conversation(s)
- * to the associated viewController are running.
- *
- * @param facesContext
- */
- protected void assertConversationState(FacesContext facesContext)
- {
- ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
- if (manager == null)
- {
- return;
- }
-
- String viewId = getViewId(facesContext);
- if (viewId == null)
- {
- return;
- }
-
- manager.assertConversationState(viewId);
- }
-
- /**
- * invokes the preRenderView method on your view controller
- */
- protected void preRenderResponse(FacesContext facesContext)
- {
- ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
- if (manager == null)
- {
- return;
- }
-
- String viewId = getViewId(facesContext);
- if (viewId == null)
- {
- return;
- }
-
- manager.executePreRenderView(viewId);
- }
-
- /**
- * invokes the initView method on your view controller
- * @since 1.1
- */
- protected void executeInitView(FacesContext facesContext)
- {
- postRestoreView(facesContext);
- }
-
- /**
- * @deprecated overload/use {@link #executeInitView(javax.faces.context.FacesContext)} instead
- */
- protected void postRestoreView(FacesContext facesContext)
- {
- ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
- if (manager == null)
- {
- return;
- }
-
- String viewId = getViewId(facesContext);
- if (viewId == null)
- {
- return;
- }
-
- ViewControllerPhaseListenerState state = getState(facesContext);
-
- if (state.initedViews.contains(viewId))
- {
- // already inited
- return;
- }
- state.initedViews.add(viewId);
-
- manager.executeInitView(viewId);
- }
-
- protected ViewControllerPhaseListenerState getState(FacesContext facesContext)
- {
- ViewControllerPhaseListenerState state = (ViewControllerPhaseListenerState) facesContext.getExternalContext().getRequestMap().get(ViewControllerPhaseListenerState.class.getName());
- if (state == null)
- {
- state = new ViewControllerPhaseListenerState();
- facesContext.getExternalContext().getRequestMap().put(ViewControllerPhaseListenerState.class.getName(), state);
- }
- return state;
- }
-
- /**
- * invokes the preProcess method on your view controller
- */
- protected void preInvokeApplication(FacesContext facesContext)
- {
- ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
- if (manager == null)
- {
- return;
- }
-
- String viewId = getViewId(facesContext);
- if (viewId == null)
- {
- return;
- }
+ /**
+ * @since 1.1
+ */
+ public static class ViewControllerPhaseListenerState
+ {
+ private Set initedViews = new TreeSet();
+
+ protected ViewControllerPhaseListenerState()
+ {
+ }
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()) ||
+ PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
+ {
+ assertConversationState(event.getFacesContext());
+ if (event.getFacesContext().getResponseComplete())
+ {
+ // we have a redirect ... stop now
+ return;
+ }
+ }
+
+ // Try to init the view in every phase, just so we are sure to never miss it.
+ // This skips the actual call if init has already happened.
+ executeInitView(event.getFacesContext());
+
+ if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
+ {
+ preRenderResponse(event.getFacesContext());
+ }
+
+ if (PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId()))
+ {
+ preInvokeApplication(event.getFacesContext());
+ }
+ }
+
+ public void afterPhase(PhaseEvent event)
+ {
+ if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()))
+ {
+ assertConversationState(event.getFacesContext());
+ if (event.getFacesContext().getResponseComplete())
+ {
+ // we have a redirect ... stop now
+ return;
+ }
+ }
+
+ executeInitView(event.getFacesContext());
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+
+ protected String getViewId(FacesContext facesContext)
+ {
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ if (viewRoot == null)
+ {
+ return null;
+ }
+ return viewRoot.getViewId();
+ }
+
+ /**
+ * invoked multiple times during the lifecycle to ensure the conversation(s)
+ * to the associated viewController are running.
+ *
+ * @param facesContext
+ */
+ protected void assertConversationState(FacesContext facesContext)
+ {
+ ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+ if (manager == null)
+ {
+ return;
+ }
+
+ String viewId = getViewId(facesContext);
+ if (viewId == null)
+ {
+ return;
+ }
+
+ manager.assertConversationState(viewId);
+ }
+
+ /**
+ * invokes the preRenderView method on your view controller
+ */
+ protected void preRenderResponse(FacesContext facesContext)
+ {
+ ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+ if (manager == null)
+ {
+ return;
+ }
+
+ String viewId = getViewId(facesContext);
+ if (viewId == null)
+ {
+ return;
+ }
+
+ manager.executePreRenderView(viewId);
+ }
+
+ /**
+ * invokes the initView method on your view controller
+ * @since 1.1
+ */
+ protected void executeInitView(FacesContext facesContext)
+ {
+ postRestoreView(facesContext);
+ }
+
+ /**
+ * @deprecated overload/use {@link #executeInitView(javax.faces.context.FacesContext)} instead
+ */
+ protected void postRestoreView(FacesContext facesContext)
+ {
+ ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+ if (manager == null)
+ {
+ return;
+ }
+
+ String viewId = getViewId(facesContext);
+ if (viewId == null)
+ {
+ return;
+ }
+
+ ViewControllerPhaseListenerState state = getState(facesContext);
+
+ if (state.initedViews.contains(viewId))
+ {
+ // already inited
+ return;
+ }
+ state.initedViews.add(viewId);
+
+ manager.executeInitView(viewId);
+ }
+
+ protected ViewControllerPhaseListenerState getState(FacesContext facesContext)
+ {
+ ViewControllerPhaseListenerState state = (ViewControllerPhaseListenerState) facesContext.getExternalContext().getRequestMap().get(ViewControllerPhaseListenerState.class.getName());
+ if (state == null)
+ {
+ state = new ViewControllerPhaseListenerState();
+ facesContext.getExternalContext().getRequestMap().put(ViewControllerPhaseListenerState.class.getName(), state);
+ }
+ return state;
+ }
+
+ /**
+ * invokes the preProcess method on your view controller
+ */
+ protected void preInvokeApplication(FacesContext facesContext)
+ {
+ ViewControllerManager manager = ViewControllerVariableResolver.getViewControllerManager(facesContext);
+ if (manager == null)
+ {
+ return;
+ }
+
+ String viewId = getViewId(facesContext);
+ if (viewId == null)
+ {
+ return;
+ }
- manager.executePreProcess(viewId);
- }
+ manager.executePreProcess(viewId);
+ }
}