You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by gv...@apache.org on 2006/07/01 02:43:13 UTC

svn commit: r418427 - in /struts/shale/trunk/shale-clay/src/main: java/org/apache/shale/clay/convert/ java/org/apache/shale/clay/convert/TimeZoneConverter.java resources/META-INF/faces-config.xml

Author: gvanmatre
Date: Fri Jun 30 17:43:12 2006
New Revision: 418427

URL: http://svn.apache.org/viewvc?rev=418427&view=rev
Log:
Fix for SHALE-206 reported by Daniel del Rico.  We were missing a TimeZone converter resulting in an exception when using the convertDateTime converter's timeZone property.  The Clay component uses the core shale ConverterHelper to convert string metadata values into the target object property types.  This utility is a JSF flavor of the commons bean utils converter.

Added:
    struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/
    struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java   (with props)
Modified:
    struts/shale/trunk/shale-clay/src/main/resources/META-INF/faces-config.xml

Added: struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java
URL: http://svn.apache.org/viewvc/struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java?rev=418427&view=auto
==============================================================================
--- struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java (added)
+++ struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java Fri Jun 30 17:43:12 2006
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ * 
+ * $Id$
+ */
+
+package org.apache.shale.clay.convert;
+
+import java.util.TimeZone;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+public class TimeZoneConverter implements Converter {
+
+    /**
+     * <p>Converts the string zone ID into a TimeZone object.</p>
+     */
+    public Object getAsObject(FacesContext facesContext, UIComponent component, String value)
+            throws ConverterException {
+        
+        TimeZone zone = TimeZone.getTimeZone(value);
+        return zone;
+    }
+
+    /**
+     * <p>Converts a TimeZone object into the string zone id.</p>
+     */
+    public String getAsString(FacesContext facesContext, UIComponent component, Object value)
+            throws ConverterException {
+           
+        TimeZone zone = (TimeZone) value;
+        if (value != null)
+           return zone.getID();
+             
+        return null;
+    }
+
+}

Propchange: struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/convert/TimeZoneConverter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: struts/shale/trunk/shale-clay/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/struts/shale/trunk/shale-clay/src/main/resources/META-INF/faces-config.xml?rev=418427&r1=418426&r2=418427&view=diff
==============================================================================
--- struts/shale/trunk/shale-clay/src/main/resources/META-INF/faces-config.xml (original)
+++ struts/shale/trunk/shale-clay/src/main/resources/META-INF/faces-config.xml Fri Jun 30 17:43:12 2006
@@ -7,23 +7,23 @@
 
 
 <!--
-
- Copyright 2004-2005 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.
-
- $Id$
-
+	
+	Copyright 2004-2005 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.
+	
+	$Id$
+	
 -->
 
 
@@ -32,41 +32,65 @@
 
 <faces-config>
 
-  <application>
-    <view-handler>
-       org.apache.shale.clay.faces.ClayViewHandler
-    </view-handler>
-  </application>
-
-  <component>
-    <description>
-      The "Clay" component dynamically composes a tree of child components
-      based on the specified properties, and performs specified substitutions
-      to customize this usage of the underlying template.
-    </description>
-    <display-name>Clay</display-name>
-    <component-type>org.apache.shale.clay.component.Clay</component-type>
-    <component-class>org.apache.shale.clay.component.Clay</component-class>
-  </component>
-
-  <component>
-    <description>
-      The "LoadBundle" component is meant to simulate the JSF loadBundle 
-      JSP tag for full Clay HTML views.
-    </description>
-    <display-name>LoadBundle</display-name>
-    <component-type>org.apache.shale.clay.component.LoadBundle</component-type>
-    <component-class>org.apache.shale.clay.component.LoadBundle</component-class>
-  </component>
-
-  <managed-bean>
-    <description>
-       The utility class used by the "Clay" component for extending runtime
-       capabilities.
-    </description>
-    <managed-bean-name>ClayAmalgam</managed-bean-name>
-    <managed-bean-class>org.apache.shale.clay.utils.ClayAmalgam</managed-bean-class>
-    <managed-bean-scope>application</managed-bean-scope>
-  </managed-bean>
+	<application>
+		<view-handler>
+			org.apache.shale.clay.faces.ClayViewHandler
+		</view-handler>
+	</application>
+
+	<component>
+		<description>
+			The "Clay" component dynamically composes a tree of child
+			components based on the specified properties, and performs
+			specified substitutions to customize this usage of the
+			underlying template.
+		</description>
+		<display-name>Clay</display-name>
+		<component-type>
+			org.apache.shale.clay.component.Clay
+		</component-type>
+		<component-class>
+			org.apache.shale.clay.component.Clay
+		</component-class>
+	</component>
+
+	<component>
+		<description>
+			The "LoadBundle" component is meant to simulate the JSF
+			loadBundle JSP tag for full Clay HTML views.
+		</description>
+		<display-name>LoadBundle</display-name>
+		<component-type>
+			org.apache.shale.clay.component.LoadBundle
+		</component-type>
+		<component-class>
+			org.apache.shale.clay.component.LoadBundle
+		</component-class>
+	</component>
+
+	<managed-bean>
+		<description>
+			The utility class used by the "Clay" component for extending
+			runtime capabilities.
+		</description>
+		<managed-bean-name>ClayAmalgam</managed-bean-name>
+		<managed-bean-class>
+			org.apache.shale.clay.utils.ClayAmalgam
+		</managed-bean-class>
+		<managed-bean-scope>application</managed-bean-scope>
+	</managed-bean>
+
+	<converter>
+		<description>
+			The TimeZone converter is registered using the target class.
+			This converter will be used by the
+			org.apache.shale.util.ConverterHelper to populate the target
+			object properties.
+		</description>
+		<converter-for-class>java.util.TimeZone</converter-for-class>
+		<converter-class>
+			org.apache.shale.clay.convert.TimeZoneConverter
+		</converter-class>
+	</converter>
 
 </faces-config>