shale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvanma...@apache.org
Subject svn commit: r475112 - in /shale/sandbox/shale-clay-trinidad: ./ src/main/java/org/apache/myfaces/trinidad/blank/ src/main/resources/ src/main/webapp/WEB-INF/ src/main/webapp/pages/
Date Wed, 15 Nov 2006 04:12:41 GMT
Author: gvanmatre
Date: Tue Nov 14 20:12:40 2006
New Revision: 475112

URL: http://svn.apache.org/viewvc?view=rev&rev=475112
Log:
Added a shale view controller managed error page and uncovered a Trinidad bug (http://issues.apache.org/jira/browse/ADFFACES-291).
 The error page is a Clay managed view and uses nested tr:iterator components.

Added:
    shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ErrorBacking.java
  (with props)
    shale/sandbox/shale-clay-trinidad/src/main/resources/log4j.xml   (with props)
    shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/error.html   (with props)
Modified:
    shale/sandbox/shale-clay-trinidad/pom.xml
    shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/HelloWorldBacking.java
    shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ShowDisplayElementBacking.java
    shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-config.xml
    shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-tiles-config.xml
    shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/web.xml
    shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/index.html

Modified: shale/sandbox/shale-clay-trinidad/pom.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/pom.xml?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/pom.xml (original)
+++ shale/sandbox/shale-clay-trinidad/pom.xml Tue Nov 14 20:12:40 2006
@@ -13,19 +13,6 @@
 
 	<build>
 		<finalName>${artifactId}</finalName>
-		<resources>
-			<resource>
-				<targetPath>
-					${project.build.outputDirectory}/META-INF
-				</targetPath>
-				<directory>
-					${project.build.outputDirectory}/src/main/resources/META-INF
-				</directory>
-				<includes>
-					<include>**/*.xml</include>
-				</includes>
-			</resource>
-		</resources>
 
 		<plugins>
 
@@ -164,6 +151,14 @@
 			<artifactId>commons-el</artifactId>
 			<version>1.0</version>
 		</dependency>
+		
+	    <dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.13</version>
+			<scope>compile</scope>
+		</dependency>
+		
 
 		<!-- Apache Trinidad 
 			You need to build for the source.

Added: shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ErrorBacking.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ErrorBacking.java?view=auto&rev=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ErrorBacking.java
(added)
+++ shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ErrorBacking.java
Tue Nov 14 20:12:40 2006
@@ -0,0 +1,145 @@
+/*
+ * 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.trinidad.blank;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Scope;
+import org.apache.shale.tiger.view.Prerender;
+import org.apache.shale.tiger.view.View;
+import org.apache.shale.view.AbstractRequestBean;
+import org.apache.shale.view.faces.FacesConstants;
+
+@Bean(name = "error", scope = Scope.REQUEST)
+@View
+public class ErrorBacking extends AbstractRequestBean {
+
+    /**
+     * <p>
+     * Common logger utility class.
+     * </p>
+     */
+    private static Log log;
+    static {
+        log = LogFactory.getLog(ErrorBacking.class);
+    }
+
+    private String httpErrorCode = null;
+
+    private String exceptionType = null;
+
+    private String message = null;
+
+    private String requestUri = null;
+
+    private String servletName = null;
+
+    @Prerender
+    public void load() {
+        if (log.isDebugEnabled()) {
+            log.debug("Removing exceptions stack");
+        }
+
+        Map requestMap = getRequestMap();
+        
+        Exception exception = (Exception) requestMap
+                .get("javax.servlet.error.exception");
+
+        FacesContext facesContext = getFacesContext();
+        if (facesContext == null) return;
+        
+        UIViewRoot root = facesContext.getViewRoot();
+        if (root == null) return;
+        
+        List exceptions = (List) requestMap.get(FacesConstants.EXCEPTIONS_LIST);
+        if (exception != null && exceptions != null) {
+            // save on the view root
+            getFacesContext().getViewRoot().getAttributes().put("errors", exceptions);
+            requestMap.remove(FacesConstants.EXCEPTIONS_LIST);
+
+            
+            Integer errorCode = (Integer) requestMap.get("javax.servlet.error.status_code");
+            if (errorCode != null) {
+            setHttpErrorCode(errorCode.toString());
+            }
+            
+            Object clazz = requestMap.get("javax.servlet.error.exception_type");
+            if (clazz != null) {
+               setExceptionType(clazz.toString());
+            }
+            setMessage((String) requestMap.get("javax.servlet.error.message"));
+            setRequestUri((String) requestMap
+                    .get("javax.servlet.error.request_uri"));
+            setServletName((String) requestMap
+                    .get("javax.servlet.error.servlet_name"));
+
+            
+            
+            log.error(exception);            
+        }
+        
+        
+
+    }
+
+    public String getExceptionType() {
+        return exceptionType;
+    }
+
+    public void setExceptionType(String exceptionType) {
+        this.exceptionType = exceptionType;
+    }
+
+    public String getHttpErrorCode() {
+        return httpErrorCode;
+    }
+
+    public void setHttpErrorCode(String httpErrorCode) {
+        this.httpErrorCode = httpErrorCode;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public String getRequestUri() {
+        return requestUri;
+    }
+
+    public void setRequestUri(String requestUri) {
+        this.requestUri = requestUri;
+    }
+
+    public String getServletName() {
+        return servletName;
+    }
+
+    public void setServletName(String servletName) {
+        this.servletName = servletName;
+    }
+}

Propchange: shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ErrorBacking.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/HelloWorldBacking.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/HelloWorldBacking.java?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/HelloWorldBacking.java
(original)
+++ shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/HelloWorldBacking.java
Tue Nov 14 20:12:40 2006
@@ -17,6 +17,7 @@
 package org.apache.myfaces.trinidad.blank;
 
 import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -81,4 +82,13 @@
         log.info(event);
     }
 
+    public String throwException() {
+    
+        throw new NullPointerException("action: Testing Exception page.");
+    }
+    
+    public void throwActionListener(ActionEvent event) {
+        throw new NullPointerException("actionListener: Testing Exception page.");
+        
+    }
 }

Modified: shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ShowDisplayElementBacking.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ShowDisplayElementBacking.java?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ShowDisplayElementBacking.java
(original)
+++ shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/myfaces/trinidad/blank/ShowDisplayElementBacking.java
Tue Nov 14 20:12:40 2006
@@ -42,10 +42,10 @@
 import org.apache.shale.tiger.managed.Scope;
 import org.apache.shale.tiger.view.Prerender;
 import org.apache.shale.tiger.view.View;
-import org.apache.shale.view.AbstractFacesBean;
+import org.apache.shale.view.AbstractRequestBean;
 
 @Bean(name="page3", scope=Scope.REQUEST)
-@View public class ShowDisplayElementBacking extends AbstractFacesBean {
+@View public class ShowDisplayElementBacking extends AbstractRequestBean {
 
     /**
      * <p>

Added: shale/sandbox/shale-clay-trinidad/src/main/resources/log4j.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/resources/log4j.xml?view=auto&rev=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/resources/log4j.xml (added)
+++ shale/sandbox/shale-clay-trinidad/src/main/resources/log4j.xml Tue Nov 14 20:12:40 2006
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<appender name="CA" class="org.apache.log4j.ConsoleAppender">
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%p-%m%n" />
+		</layout>
+	</appender>
+
+	<category name="org.apache.myfaces.lifecycle" additivity="false">
+		<priority value="trace" />
+		<appender-ref ref="CA" />
+	</category>
+	<category name="org.apache.shale.view" additivity="false">
+		<priority value="trace" />
+		<appender-ref ref="CA" />
+	</category>
+	<category name="org.apache.shale.clay.faces" additivity="false">
+		<priority value="trace" />
+		<appender-ref ref="CA" />
+	</category>
+	<root>
+		<priority value="info" />
+		<appender-ref ref="CA" />
+	</root>
+</log4j:configuration>

Propchange: shale/sandbox/shale-clay-trinidad/src/main/resources/log4j.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-config.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-config.xml?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-config.xml (original)
+++ shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-config.xml Tue Nov 14 20:12:40
2006
@@ -33,7 +33,7 @@
 		</attributes>
 		<symbols>
 			<set name="@title"
-				value="Apache MyFaces Trinidad Archetype Demo" />
+				value="Apache MyFaces Clay/Trinidad Demo" />
 			<set name="@bodycontent" value="space" />
 			<set name="@navigationPaneHint" value="bar"/>
 		</symbols>

Modified: shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-tiles-config.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-tiles-config.xml?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-tiles-config.xml (original)
+++ shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/clay-tiles-config.xml Tue Nov
14 20:12:40 2006
@@ -42,5 +42,14 @@
 			<set name="@bodycontent" value="/pages/showDisplayElement.html" />
 		</symbols>
 	</component>
+	
+	<component jsfid="/error.jsf" extends="basePage">
+		<symbols>
+			<set name="@bodycontent" value="/pages/error.html" />
+			<set name="@title" value="Application Exception" />
+			
+		</symbols>
+	</component>
+	
 
 </view>

Modified: shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/web.xml?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/web.xml (original)
+++ shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/web.xml Tue Nov 14 20:12:40
2006
@@ -79,6 +79,10 @@
 		<param-value>.jsf</param-value>
 	</context-param>
 
+    <context-param>
+       <param-name>org.apache.shale.view.EXCEPTION_DISPATCH_PATH</param-name>
+       <param-value>/error.jsf</param-value>
+    </context-param>
 	<!-- Clay XML View Suffix -->
 	<context-param>
 		<param-name>

Added: shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/error.html
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/error.html?view=auto&rev=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/error.html (added)
+++ shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/error.html Tue Nov 14 20:12:40
2006
@@ -0,0 +1,81 @@
+<!-- ### clay:page charset="UTF-8" /### -->
+<!-- ### clay:remove ### -->
+<!--
+ 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.
+-->
+<!-- ### /clay:remove ### -->
+<form>
+    <table border="0">
+	  <tr>
+	     <td>HTTP Error Error Status Code:</td>
+	     <td>
+	         <span jsfid="tr:outputText" value="#{@managed-bean-name.httpErrorCode}" allowBody=false>
+	           200
+	         </span>
+	         <span jsfid="h:inputHidden" value="#{@managed-bean-name.httpErrorCode}"/>
+	     </td>
+	   </tr>
+	   <tr>
+	       <td>Exception Type:</td>
+	       <td>
+	         <span jsfid="tr:outputText" value="#{@managed-bean-name.exceptionType}" allowBody=false>
+	           NullPointerException
+	         </span>
+	         <span jsfid="h:inputHidden" value="#{@managed-bean-name.exceptionType}"/>
+	       </td>
+	   </tr>
+	   <tr>
+	       <td>Message:</td>
+	       <td>
+	         <span jsfid="tr:outputText" value="#{@managed-bean-name.message}" allowBody=false>
+	           Something was null
+	         </span>
+	         <span jsfid="h:inputHidden" value="#{@managed-bean-name.message}"/>
+	       </td>
+	   </tr>
+	   <tr>
+	       <td>Request URI:</td>
+	       <td>
+	         <span jsfid="tr:outputText" value="#{@managed-bean-name.requestUri}" allowBody=false>
+	           /somepage.jsf
+	         </span>
+	         <span jsfid="h:inputHidden" value="#{@managed-bean-name.requestUri}"/>
+	       </td>
+	   </tr>
+	   <tr>
+	       <td>Servlet Name:</td>
+	       <td>
+	         <span jsfid="tr:outputText" value="#{@managed-bean-name.servletName}" allowBody=false>
+	           FacesServlet
+	         </span>
+	         <span jsfid="h:inputHidden" value="#{@managed-bean-name.servletName}"/>
+	       </td>
+	   </tr>
+	</table>    
+	
+	<dl>
+	<dt>Error Stack:</dt>
+	    <span jsfid="tr:iterator" var="e" value="#{facesContext.viewRoot.attributes.errors}">
+	       <dd><dl>
+	             <dt>#{e.message}</dt>
+	             <span jsfid="tr:iterator" var="s" value="#{e.stackTrace}">
+	                 <dd>#{s}</dd>
+	             </span>
+	           </dl>
+	       </dd>
+	    </span>
+	</dl>     	
+</form>

Propchange: shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/error.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/index.html
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/index.html?view=diff&rev=475112&r1=475111&r2=475112
==============================================================================
--- shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/index.html (original)
+++ shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/index.html Tue Nov 14 20:12:40
2006
@@ -36,6 +36,10 @@
 	<tr:form>
 	    <tr:panelPage>		
 		     <tr:commandLink id="button2" text="check it out" action="page3" />
+		     <tr:commandLink id="throw" text="throw exceptions" 
+		          action="#{helloWorldBacking.throwException}" />
 		</tr:panelPage>
 	</tr:form>
+	
+	
 </span>



Mime
View raw message