Permalink
Browse files

RF-12291 reproduced

  • Loading branch information...
1 parent 34aeb7c commit 6ded424f7dcac41fadfa8134937722028a19b0d8 Juraj Huska committed Oct 2, 2012
View
3 metamer/application/pom.xml
@@ -172,6 +172,9 @@
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
</resources>
<plugins>
View
78 .../main/java/org/richfaces/tests/metamer/bean/issues/rf12291/ClasspathResourceResolver.java
@@ -0,0 +1,78 @@
+package org.richfaces.tests.metamer.bean.issues.rf12291;
+
+import java.net.URL;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.faces.facelets.impl.DefaultResourceResolver;
+
+/**
+ * Resolves Facelets pages based on classpath
+ */
+public class ClasspathResourceResolver extends DefaultResourceResolver {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private static String SLASH = "/";
+ private static String BASE_PATH_PAGES = "/WEB-INF/classes/";
+
+ @Override
+ public URL resolveUrl(final String url) {
+
+ logger.info("url: " + url);
+
+ URL resolvedUrl = super.resolveUrl(url);
+
+ if (resolvedUrl == null) {// if1
+ String urlPath = toModulePagePath(url);
+ logger.info("urlPath: " + urlPath);
+ resolvedUrl = super.resolveUrl(BASE_PATH_PAGES + urlPath);
+ logger.info("resolverUrl: " + resolvedUrl);
+ }// if1
+
+ if (resolvedUrl == null) {
+ logger.info("Page url: " + url + " not found. Showing wrongUrl page...");
+ String wrongPageUrl = BASE_PATH_PAGES + "org/richfaces/tests/metamer/bean/issues/rf12291/wrongUrl.xhtml";
+ resolvedUrl = super.resolveUrl(wrongPageUrl);
+ }
+
+ if (resolvedUrl == null) {
+ throw new IllegalStateException("Unexpected error: wrongUrl.xhtml page not found");
+ }
+
+ logger.info("resolvedUrl: " + resolvedUrl.toString());
+
+ return resolvedUrl;
+ }
+
+ private String toModulePagePath(String url) {
+ String normalizedUrl = normalizeUrl(url);
+
+ int moduleAcronymStartIdx = normalizedUrl.lastIndexOf("/module/") + "/module/".length();
+ int moduleAcronymEndIdx = moduleAcronymStartIdx + normalizedUrl.substring(moduleAcronymStartIdx).indexOf(SLASH);
+
+ String moduleAcronymPath = normalizedUrl.substring(0, moduleAcronymEndIdx);
+ logger.info("moduleAcronymPath: " + moduleAcronymPath);
+ String pageRelativePath = normalizedUrl.substring(moduleAcronymEndIdx + 1);
+ logger.info("pageRelativePath: " + pageRelativePath);
+ return "org/richfaces/tests/metamer/bean/issues/rf12291/" + pageRelativePath;
+ }
+
+ private String normalizeUrl(String url) {
+ logger.info("Unnormalized Url: " + url);
+ if (url == null || url.length() == 0) {
+ throw new IllegalStateException("Received a null or empty url String");
+ }
+ String normalizedUrl = url;
+ if (!normalizedUrl.startsWith(SLASH)) {
+ normalizedUrl = SLASH + normalizedUrl;
+ }
+ if (!normalizedUrl.toLowerCase().startsWith("/module")) {
+ normalizedUrl = "/module" + normalizedUrl;
+ }
+ logger.info("Normalized Url: " + normalizedUrl);
+ return normalizedUrl;
+ }
+
+}
View
2 ...cation/src/main/java/org/richfaces/tests/metamer/bean/issues/rf12291/CoreJsfConstant.java
@@ -2,6 +2,6 @@
public class CoreJsfConstant {
- public static final String EMPTY_INCLUDE_PATH = "/richfaces/tests/metamer/bean/issues/rf12291/emptyInclude.xhtml";
+ public static final String EMPTY_INCLUDE_PATH = "/module/core/emptyInclude.xhtml";
}
View
58 ...src/main/java/org/richfaces/tests/metamer/bean/issues/rf12291/CustomExceptionHandler.java
@@ -0,0 +1,58 @@
+package org.richfaces.tests.metamer.bean.issues.rf12291;
+
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExceptionHandlerWrapper;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ExceptionQueuedEvent;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CustomExceptionHandler extends ExceptionHandlerWrapper {
+
+ protected static final Logger logger = LoggerFactory.getLogger(AbstractAction.class);
+
+ private ExceptionHandler wrapped;
+
+ public CustomExceptionHandler(ExceptionHandler wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ @Override
+ public ExceptionHandler getWrapped() {
+ return wrapped;
+ }
+
+ @Override
+ public void handle() throws FacesException {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ if (context.getPartialViewContext().isAjaxRequest()) {
+ // Iterate over all unhandled exceptions
+ Iterator<ExceptionQueuedEvent> it = getUnhandledExceptionQueuedEvents().iterator();
+
+ while (it.hasNext()) {// w
+
+ Throwable t = it.next().getContext().getException();
+
+ long ts = System.currentTimeMillis();
+ logger.error("Exception in CustomExceptionHandler was handled [" + ts + "]", t);
+
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ context.setViewRoot(context.getApplication().getViewHandler().createView(context, "/module/core/error.xhtml"));
+ context.getPartialViewContext().setRenderAll(true);
+
+ ctx.renderResponse();
+ it.remove();
+ }// w
+ }
+
+ getWrapped().handle();
+
+ }
+
+}
View
21 ...n/java/org/richfaces/tests/metamer/bean/issues/rf12291/CustomExceptionHandlerFactory.java
@@ -0,0 +1,21 @@
+package org.richfaces.tests.metamer.bean.issues.rf12291;
+
+import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExceptionHandlerFactory;
+
+public class CustomExceptionHandlerFactory extends ExceptionHandlerFactory {
+
+ private ExceptionHandlerFactory parent;
+
+ // this injection handles jsf
+ public CustomExceptionHandlerFactory(ExceptionHandlerFactory parent) {
+ this.parent = parent;
+ }
+
+ // create your own ExceptionHandler
+ @Override
+ public ExceptionHandler getExceptionHandler() {
+ return new CustomExceptionHandler(parent.getExceptionHandler());
+ }
+
+}
View
66 metamer/application/src/main/java/org/richfaces/tests/metamer/bean/issues/rf12291/test.xhtml
@@ -1,40 +1,42 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich"
- contentType="text/html; charset=utf-8">
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ contentType="text/html; charset=utf-8">
<html>
-
- <h:head>
- <link rel="stylesheet" type="text/css" href="#{request.contextPath}/css/richfaces.css" />
- </h:head>
-
- <body>
-
- <h:form id="testTabPnlFrmId">
-
- <rich:tabPanel id="testTabPnlId" itemChangeListener="#{testTabPanelItemChangeListener.processItemChange}"
- activeItem="#{sessionScope.userInfoDO.activeTabId}" width="100%" immediate="true"
- headerAlignment="left" switchType="ajax">
-
- <rich:tab id="firstTabId" header="First">
- <ui:include src="#{testAction.getTabIncludePath('firstTabId')}" />
- </rich:tab>
-
- <rich:tab id="secondTabId" header="Second">
- <ui:include src="#{testAction.getTabIncludePath('secondTabId')}" />
- </rich:tab>
- </rich:tabPanel>
-
- </h:form>
-
- </body>
-
+
+<h:head>
+ <link rel="stylesheet" type="text/css"
+ href="#{request.contextPath}/css/richfaces.css" />
+</h:head>
+
+<body>
+
+ <h:form id="testTabPnlFrmId">
+
+ <rich:tabPanel id="testTabPnlId"
+ itemChangeListener="#{testTabPanelItemChangeListener.processItemChange}"
+ activeItem="#{sessionScope.userInfoDO.activeTabId}" width="100%"
+ immediate="true" headerAlignment="left" switchType="ajax">
+
+ <rich:tab id="firstTabId" header="First">
+ <ui:include src="#{testAction.getTabIncludePath('firstTabId')}" />
+ </rich:tab>
+
+ <rich:tab id="secondTabId" header="Second">
+ <ui:include src="#{testAction.getTabIncludePath('secondTabId')}" />
+ </rich:tab>
+ </rich:tabPanel>
+
+ </h:form>
+
+</body>
+
</html>
</f:view>
View
6 metamer/application/src/main/webapp/WEB-INF/faces-config.xml
@@ -27,6 +27,12 @@
</application>
+ <factory>
+ <exception-handler-factory>
+ org.richfaces.tests.metamer.bean.issues.rf12291.CustomExceptionHandlerFactory
+ </exception-handler-factory>
+ </factory>
+
<lifecycle>
<phase-listener>org.richfaces.tests.metamer.RichPhaseListener</phase-listener>
<phase-listener>org.richfaces.tests.metamer.ResponseDelayListener</phase-listener>
View
8 metamer/application/src/main/webapp/WEB-INF/web.xml
@@ -51,6 +51,14 @@
<param-name>org.richfaces.skin</param-name>
<param-value>#{richBean.skin}</param-value>
</context-param>
+ <context-param>
+ <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
+ <param-value>org.richfaces.tests.metamer.bean.issues.rf12291.ClasspathResourceResolver</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
<filter>
<filter-name>Test Identity Filter</filter-name>
View
54 metamer/application/src/main/webapp/components/richTabPanel/rf-12291.xhtml
@@ -1,43 +1,25 @@
-<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
+
+<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
- xmlns:rich="http://richfaces.org/rich"
- xmlns:c="http://java.sun.com/jsp/jstl/core">
-
-<!--
-JBoss, Home of Professional Open Source
-Copyright 2010-2012, Red Hat, Inc. and individual contributors
-by the @authors tag. See the copyright.txt in the distribution for a
-full listing of individual contributors.
-
-This is free software; you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as
-published by the Free Software Foundation; either version 2.1 of
-the License, or (at your option) any later version.
-
-This software is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this software; if not, write to the Free
-Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-02110-1301 USA, or see the FSF site: http://www.fsf.org.
- -->
-
-<ui:composition template="/templates/template.xhtml">
- <ui:define name="component">
+ xmlns:f="http://java.sun.com/jsf/core" contentType="text/html">
+
+ <html>
+
+<head>
+
+</head>
+
+<body>
+
+ <h:outputText value="RF4 bug" />
+ <h:form id="tabPnlFrmId">
<h:commandLink id="testCmdLnkId" action="#{testAction.startAction}"
value="Go To Tab Panel" />
+ </h:form>
- </ui:define>
+</body>
-</ui:composition>
-</html>
+ </html>
+</f:view>
View
60 metamer/application/src/main/webapp/css/richfaces.css
@@ -0,0 +1,60 @@
+.rich-extdt-maindiv {
+ height: auto !important;
+}
+
+.rich-extdt-maindiv,.extdt-innerdiv {
+ position: relative !important;
+}
+
+.extdt-outerdiv {
+ height: auto !important;
+ overflow-x: scroll !important;
+ overflow-y: visible !important;
+}
+
+.extdt-content {
+ height: auto !important;
+}
+
+.rf-dt {
+ height: auto !important;
+}
+
+.rf-tab-lbl {
+ font-size: 11px !important;
+ font-weight: bold !important;
+}
+
+.rf-au-fnt {
+ font-size: 11px;
+ font-family: Arial, Verdana, sans-serif;
+ text-align: left;
+}
+
+.rf-au-lst-scrl {
+ width: 300px !important;
+ overflow-x: scroll !important;
+ overflow-y: visible !important;
+}
+
+.rf-au-tbl {
+ white-space: nowrap !important;
+ text-align: left !important;
+}
+
+.autoWidth {
+ width: auto !important;
+}
+
+.rf-msgs-wrn {
+ color:#00008B;
+ padding-left: 10px;
+}
+
+.rf-sel-opt {
+ padding: 2px;
+ white-space: nowrap;
+ cursor: default;
+ list-style-type: none;
+ text-align:left;
+}

0 comments on commit 6ded424

Please sign in to comment.