incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r420644 - in /incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal: renderkit/AdfRenderingContext.java ui/laf/xml/parse/SkinExtensionParser.java
Date Mon, 10 Jul 2006 22:07:47 GMT
Author: awiner
Date: Mon Jul 10 15:07:46 2006
New Revision: 420644

URL: http://svn.apache.org/viewvc?rev=420644&view=rev
Log:
Improve error reporting of SkinExtension parsing;  and improve handling of missing skinning
translation keys.

Modified:
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/AdfRenderingContext.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/ui/laf/xml/parse/SkinExtensionParser.java

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/AdfRenderingContext.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/AdfRenderingContext.java?rev=420644&r1=420643&r2=420644&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/AdfRenderingContext.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/AdfRenderingContext.java
Mon Jul 10 15:07:46 2006
@@ -13,146 +13,158 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.renderkit;
-
-import java.util.Map;
-
-import org.apache.myfaces.adf.logging.ADFLogger;
-
-import org.apache.myfaces.adfinternal.agent.AdfFacesAgent;
-import org.apache.myfaces.adfinternal.renderkit.core.ppr.PartialPageContext;
-import org.apache.myfaces.adfinternal.renderkit.core.xhtml.FormData;
-import org.apache.myfaces.adfinternal.share.config.AccessibilityMode;
-import org.apache.myfaces.adfinternal.share.nls.LocaleContext;
-import org.apache.myfaces.adfinternal.skin.Skin;
-import org.apache.myfaces.adfinternal.skin.icon.Icon;
-import org.apache.myfaces.adfinternal.style.StyleContext;
-
-/**
- * @todo REMOVE DEPENDENCY ON AcessibilityMode
- */
-abstract public class AdfRenderingContext
-{
-  /**
-   * Retrieves the AdfRenderingContext active for the current thread.
-   */
-  static public AdfRenderingContext getCurrentInstance()
-  {
-    return (AdfRenderingContext) _CURRENT_CONTEXT.get();
-  }
-
-  static public final Object INACCESSIBLE_MODE =
-   AccessibilityMode.INACCESSIBLE_MODE;
-  static public final Object SCREEN_READER_MODE =
-   AccessibilityMode.SCREEN_READER_MODE;
-
-  public AdfRenderingContext()
-  {
-    attach();
-  }
-
-  /**
-   * A map of properties specific to rendering.
-   */
-  abstract public Map           getProperties();
-
-  abstract public AdfFacesAgent getAgent();
-  /**
-   * @todo REMOVE LocaleContext
-   */
-  abstract public LocaleContext getLocaleContext();
-  abstract public StyleContext getStyleContext();
-  abstract public FormData getFormData();
-  abstract public void setFormData(FormData data);
-  abstract public void clearFormData();
-
-  //
-  // Skin methods.
-  //
-
-  /**
-   * Get the Skin.  Icons, properties, etc. should never be retrieved directly
-   * from the skin, but always through the AdfRenderingContext so they
-   * can be properly transformed.
-   */
-  abstract public Skin getSkin();
-
-  public String getTranslatedString(String key)
-  {
-    if (key == null)
-      return null;
-
-    return getSkin().getTranslatedString(getLocaleContext(), key);
-  }
-
-  abstract public Icon getIcon(String iconName);
-
-
-  abstract public String getStyleClass(String styleClass);
-  abstract public void   setSkinResourceKeyMap(Map mapping);
-  abstract public Map    getSkinResourceKeyMap();
-  abstract public boolean isRightToLeft();
-  abstract public String getOutputMode();
-  abstract public Object getAccessibilityMode();
-
-  /**
-   * @TODO This is a hack API to enable caching of the client ID.
-   *  All fine, but we should have a more general mechanism.
-   */
-  public String getCurrentClientId() { return _currentClientId; }
-  public void setCurrentClientId(String currentClientId)
-  {
-    _currentClientId = currentClientId;
-  }
-
-  private String _currentClientId;
-
-
-
-  abstract public PartialPageContext getPartialPageContext();
-
-
-  public void release()
-  {
-    Object o = _CURRENT_CONTEXT.get();
-    // Clean up first...
-    _CURRENT_CONTEXT.set(null);
-
-    // Then see if there's a problem, and scream if there is one
-    if (o == null)
-      throw new IllegalStateException("AdfRenderingContext was already " +
-                                      "released or had never been attached.");
-    if (o != this)
-      throw new IllegalStateException("Trying to release a different " +
-                     "AdfRenderingContext than the current context.");
-  }
-
-  /**
-   * Attaches an AdfRenderingContext to the current thread.  This method is
-   * protected, and therefore can only be called by an AdfRenderingContext
-   * object itself.
-   */
-  protected void attach()
-  {
-    Object o = _CURRENT_CONTEXT.get();
-    // We want to catch two different problems:
-    // (1) A failure to call release()
-    // (2) An attempt to attach an instance when the thread already has one
-    // For #1, anything more than a warning is dangerous, because throwing
-    // an exception would permanently make the thread unusable.
-    // For #2, I'd like to throw an exception, but I can't distinguish
-    // this scenario from #1.
-    if (o != null)
-    {
-      _LOG.warning("Trying to attach AdfRenderingContext " +
-                   "to a thread that already had one.");
-    }
-
-    _CURRENT_CONTEXT.set(this);
-  }
-
-
-  static private final ThreadLocal _CURRENT_CONTEXT = new ThreadLocal();
-  static private final ADFLogger _LOG =
-    ADFLogger.createADFLogger(AdfRenderingContext.class);
-}
+package org.apache.myfaces.adfinternal.renderkit;
+
+import java.util.Map;
+import java.util.MissingResourceException;
+
+import org.apache.myfaces.adf.logging.ADFLogger;
+
+import org.apache.myfaces.adfinternal.agent.AdfFacesAgent;
+import org.apache.myfaces.adfinternal.renderkit.core.ppr.PartialPageContext;
+import org.apache.myfaces.adfinternal.renderkit.core.xhtml.FormData;
+import org.apache.myfaces.adfinternal.share.config.AccessibilityMode;
+import org.apache.myfaces.adfinternal.share.nls.LocaleContext;
+import org.apache.myfaces.adfinternal.skin.Skin;
+import org.apache.myfaces.adfinternal.skin.icon.Icon;
+import org.apache.myfaces.adfinternal.style.StyleContext;
+
+/**
+ * @todo REMOVE DEPENDENCY ON AcessibilityMode
+ */
+abstract public class AdfRenderingContext
+{
+  /**
+   * Retrieves the AdfRenderingContext active for the current thread.
+   */
+  static public AdfRenderingContext getCurrentInstance()
+  {
+    return (AdfRenderingContext) _CURRENT_CONTEXT.get();
+  }
+
+  static public final Object INACCESSIBLE_MODE =
+   AccessibilityMode.INACCESSIBLE_MODE;
+  static public final Object SCREEN_READER_MODE =
+   AccessibilityMode.SCREEN_READER_MODE;
+
+  public AdfRenderingContext()
+  {
+    attach();
+  }
+
+  /**
+   * A map of properties specific to rendering.
+   */
+  abstract public Map           getProperties();
+
+  abstract public AdfFacesAgent getAgent();
+  /**
+   * @todo REMOVE LocaleContext
+   */
+  abstract public LocaleContext getLocaleContext();
+  abstract public StyleContext getStyleContext();
+  abstract public FormData getFormData();
+  abstract public void setFormData(FormData data);
+  abstract public void clearFormData();
+
+  //
+  // Skin methods.
+  //
+
+  /**
+   * Get the Skin.  Icons, properties, etc. should never be retrieved directly
+   * from the skin, but always through the AdfRenderingContext so they
+   * can be properly transformed.
+   */
+  abstract public Skin getSkin();
+
+  public String getTranslatedString(String key)
+  {
+    if (key == null)
+      return null;
+
+    try
+    {
+      return getSkin().getTranslatedString(getLocaleContext(), key);
+    }
+    catch (MissingResourceException mre)
+    {
+      // Instead of halting execution, return "???<key>???",
+      // just like JSF and JSTL will do, and log a severe error
+      _LOG.severe("Could not get resource key {0} from skin {1}",
+                  new String[]{key, getSkin().getId()});
+      return "???" + key + "???";
+    }
+  }
+
+  abstract public Icon getIcon(String iconName);
+
+
+  abstract public String getStyleClass(String styleClass);
+  abstract public void   setSkinResourceKeyMap(Map mapping);
+  abstract public Map    getSkinResourceKeyMap();
+  abstract public boolean isRightToLeft();
+  abstract public String getOutputMode();
+  abstract public Object getAccessibilityMode();
+
+  /**
+   * @TODO This is a hack API to enable caching of the client ID.
+   *  All fine, but we should have a more general mechanism.
+   */
+  public String getCurrentClientId() { return _currentClientId; }
+  public void setCurrentClientId(String currentClientId)
+  {
+    _currentClientId = currentClientId;
+  }
+
+  private String _currentClientId;
+
+
+
+  abstract public PartialPageContext getPartialPageContext();
+
+
+  public void release()
+  {
+    Object o = _CURRENT_CONTEXT.get();
+    // Clean up first...
+    _CURRENT_CONTEXT.set(null);
+
+    // Then see if there's a problem, and scream if there is one
+    if (o == null)
+      throw new IllegalStateException("AdfRenderingContext was already " +
+                                      "released or had never been attached.");
+    if (o != this)
+      throw new IllegalStateException("Trying to release a different " +
+                     "AdfRenderingContext than the current context.");
+  }
+
+  /**
+   * Attaches an AdfRenderingContext to the current thread.  This method is
+   * protected, and therefore can only be called by an AdfRenderingContext
+   * object itself.
+   */
+  protected void attach()
+  {
+    Object o = _CURRENT_CONTEXT.get();
+    // We want to catch two different problems:
+    // (1) A failure to call release()
+    // (2) An attempt to attach an instance when the thread already has one
+    // For #1, anything more than a warning is dangerous, because throwing
+    // an exception would permanently make the thread unusable.
+    // For #2, I'd like to throw an exception, but I can't distinguish
+    // this scenario from #1.
+    if (o != null)
+    {
+      _LOG.warning("Trying to attach AdfRenderingContext " +
+                   "to a thread that already had one.");
+    }
+
+    _CURRENT_CONTEXT.set(this);
+  }
+
+
+  static private final ThreadLocal _CURRENT_CONTEXT = new ThreadLocal();
+  static private final ADFLogger _LOG =
+    ADFLogger.createADFLogger(AdfRenderingContext.class);
+}

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/ui/laf/xml/parse/SkinExtensionParser.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/ui/laf/xml/parse/SkinExtensionParser.java?rev=420644&r1=420643&r2=420644&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/ui/laf/xml/parse/SkinExtensionParser.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/ui/laf/xml/parse/SkinExtensionParser.java
Mon Jul 10 15:07:46 2006
@@ -80,7 +80,13 @@
     if (baseSkin == null)
     {
       if (_extends != null)
-        _LOG.severe(_UNKNOWN_BASE_SKIN_ERROR + _extends);
+      {
+        _LOG.severe("Unable to locate base skin \"{0}\" for " +
+                    "use in defining skin of id \"{1}\", family " +
+                    "\"{2}\", renderkit ID \"{3}\"",
+                    new String[]{_extends, _id, _family, _renderKitId});
+      }
+
       baseSkin = _getDefaultBaseSkin(context, _renderKitId);
     }
 



Mime
View raw message