You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2007/03/12 14:16:31 UTC

svn commit: r517201 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/config/ core/src/main/java/org/apache/myfaces/tobago/context/ core/src/main/java/org/apache/myfaces/tobago/renderkit/ theme/standard/ theme/standard/src/main/j...

Author: lofwyr
Date: Mon Mar 12 06:16:30 2007
New Revision: 517201

URL: http://svn.apache.org/viewvc?view=rev&rev=517201
Log:
TOBAGO-296: NPE when client supports wml

Added:
    myfaces/tobago/trunk/theme/standard/src/main/java/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java   (contents, props changed)
      - copied, changed from r511749, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java
    myfaces/tobago/trunk/theme/standard/pom.xml

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java?view=diff&rev=517201&r1=517200&r2=517201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java Mon Mar 12 06:16:30 2007
@@ -46,18 +46,26 @@
       String name) {
 
     CacheKey key = new CacheKey(facesContext.getViewRoot(), component, name);
-    Map cache = (Map) facesContext.getExternalContext()
-        .getApplicationMap().get(THEME_CONFIG_CACHE);
+    Map<CacheKey, Integer> cache
+        = (Map<CacheKey, Integer>) facesContext.getExternalContext().getApplicationMap().get(THEME_CONFIG_CACHE);
 
-    Integer value = (Integer) cache.get(key);
+    Integer value = cache.get(key);
     if (value == null) {
       value = createValue(facesContext, component, name);
       cache.put(key, value);
     }
-    return value.intValue();
+    if (value != null) {
+      return value;
+    } else {
+      // todo: remove condition, is only temporary to ignore wml errors.
+      if (! ClientProperties.getInstance(facesContext.getViewRoot()).getContentType().equals("wml")) {
+        throw new NullPointerException("No value configured");
+      }
+      // todo: remove, is only temporary to ignore wml errors.
+      return 0;
+    }
   }
 
-
   private static Integer createValue(FacesContext facesContext,
       UIComponent component, String name) {
     String family;
@@ -95,9 +103,12 @@
       }
       clazz = clazz.getSuperclass();
     }
-    LOG.error("Theme property not found for renderer: " + renderer.getClass()
-        + " with clientProperties='" + ClientProperties.getInstance(viewRoot).getId() + "'"
-        + " and locale='" + viewRoot.getLocale() + "'");
+    // todo: remove condition, is only temporary to ignore wml errors.
+    if (! ClientProperties.getInstance(viewRoot).getContentType().equals("wml")) {
+      LOG.error("Theme property not found for renderer: " + renderer.getClass()
+          + " with clientProperties='" + ClientProperties.getInstance(viewRoot).getId() + "'"
+          + " and locale='" + viewRoot.getLocale() + "'");
+    }
     return null;
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java?view=diff&rev=517201&r1=517200&r2=517201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java Mon Mar 12 06:16:30 2007
@@ -357,13 +357,9 @@
     final String clientPropertyId;
     final Locale locale;
     final String type = "tag";
-//    final Object key;
     CacheKey key;
     if (name != null) {
       if (viewRoot instanceof org.apache.myfaces.tobago.component.UIViewRoot) {
-//        key = new StringBuilder(((org.apache.myfaces.tobago.component.UIViewRoot)viewRoot)
-//            .getRendererCachePrefix()).append(name).toString();
-//      key = new RendererCacheKey(clientPropertyId, locale, name);
         key = ((org.apache.myfaces.tobago.component.UIViewRoot) viewRoot).getRendererCacheKey();
         key.setName(name);
         renderer = (Renderer) cache.get(key);
@@ -377,7 +373,6 @@
       } else {
         clientPropertyId = ClientProperties.getInstance(viewRoot).getId();
         locale = viewRoot.getLocale();
-//      key = key(clientPropertyId, locale, type, name);
 
         key = new CacheKey(clientPropertyId, locale, name, CacheType.RENDERER);
         renderer = (Renderer) cache.get(key);
@@ -390,22 +385,19 @@
 
       try {
         name = getRendererClassName(name);
-        Class clazz = null;
-        List classes =  getPaths(clientPropertyId, locale, "", type, name,
-            "", false, true, true, null, false, false);
+        List<Class> classes
+            = getPaths(clientPropertyId, locale, "", type, name, "", false, true, true, null, false, false);
         if (classes != null && classes.size() > 0) {
-          clazz = (Class) classes.get(0);
+          Class clazz = classes.get(0);
+          renderer = (Renderer) clazz.newInstance();
+          cache.put(key, renderer);
         } else {
-          throw new RuntimeException("Don't find any RendererClass for " + name + ". Please check you configuration.");
+          LOG.error("Don't find any RendererClass for " + name + ". Please check you configuration.");
         }
-        renderer = (Renderer) clazz.newInstance();
-        cache.put(key, renderer);
       } catch (InstantiationException e) {
         LOG.error("name = '" + name + "' clientProperties = '" + clientPropertyId + "'", e);
-        throw new RuntimeException(name, e);
       } catch (IllegalAccessException e) {
         LOG.error("name = '" + name + "' clientProperties = '" + clientPropertyId + "'", e);
-        throw new RuntimeException(name, e);
       }
     }
     return renderer;

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java?view=diff&rev=517201&r1=517200&r2=517201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java Mon Mar 12 06:16:30 2007
@@ -71,7 +71,7 @@
     }
     if (renderer == null) {
       LOG.error("The class witch was found by the ResourceManager can't be "
-          + "found, or instanciated: classname='" + rendererType + "'");
+          + "found, or instanciated: rendererType='" + rendererType + "'");
     }
     return renderer;
   }

Modified: myfaces/tobago/trunk/theme/standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/pom.xml?view=diff&rev=517201&r1=517200&r2=517201
==============================================================================
--- myfaces/tobago/trunk/theme/standard/pom.xml (original)
+++ myfaces/tobago/trunk/theme/standard/pom.xml Mon Mar 12 06:16:30 2007
@@ -33,4 +33,84 @@
     <url>http://svn.apache.org/viewcvs.cgi/myfaces/tobago/trunk/theme/standard</url>
   </scm>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.myfaces.core</groupId>
+      <artifactId>myfaces-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.myfaces.tobago</groupId>
+      <artifactId>tobago-core</artifactId>
+      <version>${project.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>sun.jdk</groupId>
+          <artifactId>tools</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+  <profiles>
+    <profile>
+      <id>jdk14retro</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>retrotranslator-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>retrotranslate</id>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <artifactId>maven-jar-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>create-jdk14retro-jar</id>
+                <goals><goal>jar</goal></goals>
+                <configuration>
+                  <classesDirectory>${project.build.directory}/classes-retro</classesDirectory>
+                  <classifier>jdk14retro</classifier>
+                  <archive>
+                    <manifestEntries>
+                      <Extension-Name>${project.artifactId}-jdk14retro</Extension-Name>
+                      <Specification-Vendor>${project.organization.name}</Specification-Vendor>
+                      <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
+                      <Implementation-Title>${project.description}</Implementation-Title>
+                      <Implementation-Version>${project.version}</Implementation-Version>
+                      <Revision>${scm.revision}</Revision>
+                    </manifestEntries>
+                   </archive>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+       <dependencies>
+        <dependency>
+          <groupId>sun.jdk</groupId>
+          <artifactId>rt</artifactId>
+          <version>1.4.0</version>
+          <scope>system</scope>
+          <systemPath>${java14.home}/lib/rt.jar</systemPath>
+        </dependency>
+        <dependency>
+          <groupId>net.sf.retrotranslator</groupId>
+          <artifactId>retrotranslator-runtime</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
 </project>

Copied: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java (from r511749, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java?view=diff&rev=517201&p1=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java&r1=511749&p2=myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java&r2=517201
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java Mon Mar 12 06:16:30 2007
@@ -17,21 +17,13 @@
  * limitations under the License.
  */
 
-/*
- * Created 07.02.2003 16:00:00.
- * : $
- */
-
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.renderkit.PageRendererBase;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
 import java.io.IOException;
-import java.io.StringWriter;
 
 public class PageRenderer extends PageRendererBase {
 
@@ -40,6 +32,15 @@
           + "<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN'\n"
           + " 'http://www.wapforum.org/DTD/wml_1.1.xml'>";
 
+  @Override
+  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+  }
+
+  @Override
+  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
+  }
+
+  @Override
   public void encodeEnd(FacesContext facesContext, UIComponent component)
       throws IOException {
 
@@ -48,14 +49,6 @@
     TobagoResponseWriter writer
         = (TobagoResponseWriter) facesContext.getResponseWriter();
 
-    // replace responseWriter and render page content
-    StringWriter content = new StringWriter();
-    ResponseWriter contentWriter = new TobagoResponseWriter(
-        content, writer.getContentType(), writer.getCharacterEncoding());
-    facesContext.setResponseWriter(contentWriter);
-
-    RenderUtil.encodeChildren(facesContext, page);
-
     // reset responseWriter and render page
     facesContext.setResponseWriter(writer);
 
@@ -65,11 +58,19 @@
     writer.startElement("wml", page);
     writer.startElement("card", page);
 
-    writer.writeText("", null);
-    writer.write(content.toString());
+    writer.writeText("WML currently not supported!", null);
+//    writer.write(content.toString());
 
     writer.endElement("card");
     writer.endElement("wml");
+
+    // fixme, this is only a workaround for bug TOBAGO-296
+    facesContext.responseComplete();
   }
-}
 
+  @Override
+  public boolean getRendersChildren() {
+    // fixme, this is only a workaround for bug TOBAGO-296
+    return true;
+  }
+}

Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/wml/standard/standard/tag/PageRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision