myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [myfaces-test] 03/24: MYFACESTEST-8 Implement ViewHandler.getBookmarkableURL() for MyFaces test 2.0
Date Thu, 03 May 2018 18:26:31 GMT
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit e55dcae34ae69267f14d62945c8db1f25991a0c5
Author: Jakob Korherr <jakobk@apache.org>
AuthorDate: Mon Apr 19 19:39:39 2010 +0000

    MYFACESTEST-8 Implement ViewHandler.getBookmarkableURL() for MyFaces test 2.0
---
 .../myfaces/test/mock/MockApplication20.java       |  3 ++
 .../myfaces/test/mock/MockViewHandler20.java       | 50 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
index b1d6080..72dce99 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
@@ -47,6 +47,9 @@ public class MockApplication20 extends MockApplication12
     public MockApplication20()
     {
         super();
+        
+        // install the 2.0-ViewHandler-Mock
+        this.setViewHandler(new MockViewHandler20());
     }
 
     private static class SystemListenerEntry
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockViewHandler20.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockViewHandler20.java
new file mode 100644
index 0000000..0663440
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockViewHandler20.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.test.mock;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * Mock for a JSF 2.0 ViewHandler.
+ * This ViewHandler is used by MockApplication20.
+ * 
+ * @author Jakob Korherr (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class MockViewHandler20 extends MockViewHandler
+{
+
+    @Override
+    public String getBookmarkableURL(FacesContext context, String viewId,
+            Map<String, List<String>> parameters, boolean includeViewParams)
+    {
+        // the standard impl only calls getActionURL(context, viewId)
+        // but we want to include the parameters too
+        
+        String actionEncodedViewId = getActionURL(context, viewId);
+        ExternalContext externalContext = context.getExternalContext();
+        String bookmarkEncodedURL = externalContext.encodeBookmarkableURL(actionEncodedViewId,
parameters);
+        return externalContext.encodeActionURL(bookmarkEncodedURL);
+    }
+    
+}

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

Mime
View raw message