myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmarinsc...@apache.org
Subject svn commit: r439060 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util: ./ DirectNavigationHandler.java
Date Thu, 31 Aug 2006 21:55:23 GMT
Author: mmarinschek
Date: Thu Aug 31 14:55:23 2006
New Revision: 439060

URL: http://svn.apache.org/viewvc?rev=439060&view=rev
Log:
new util - a direct navigation handler which allows not setting navigation rules at all

Added:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util/
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util/DirectNavigationHandler.java

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util/DirectNavigationHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util/DirectNavigationHandler.java?rev=439060&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util/DirectNavigationHandler.java
(added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/util/DirectNavigationHandler.java
Thu Aug 31 14:55:23 2006
@@ -0,0 +1,48 @@
+/*
+  * Copyright 2006 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.myfaces.tomahawk.util;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * This is an alternative
+ * implementation of the NavigationHandler,
+ * directly using the outcome of an action
+ * as the name of the page.
+ */
+public class DirectNavigationHandler extends NavigationHandler{
+
+	/**
+	 * Gives the handleNavigation() method an alternative behaviour. Linking
+	 * is now processed directly to the given url (e.g. action="/pages/site.jsp").
+     *
+	 * There is no check if the outcome value really points to a valid page.
+	 */
+	public void handleNavigation(FacesContext context, String fromAction, String outcome) {
+
+        if(outcome == null || outcome.length()==0)
+            return;
+
+        ViewHandler viewHandler=context.getApplication().getViewHandler();
+		UIViewRoot viewRoot=viewHandler.createView(context,outcome);
+		context.setViewRoot(viewRoot);
+		context.renderResponse();
+	}
+}



Mime
View raw message