You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by me...@apache.org on 2011/11/04 12:01:52 UTC

svn commit: r1197500 - in /click/trunk/click: ./ extras/src/org/apache/click/extras/control/ extras/src/org/apache/click/extras/gae/ framework/src/org/apache/click/ framework/src/org/apache/click/service/ framework/src/org/apache/click/util/ framework/...

Author: medgar
Date: Fri Nov  4 11:01:51 2011
New Revision: 1197500

URL: http://svn.apache.org/viewvc?rev=1197500&view=rev
Log:
CLK-306

Removed:
    click/trunk/click/framework/src/org/apache/click/util/RequestTypeConverter.java
    click/trunk/click/framework/test/org/apache/click/util/RequestTypeConverterTest.java
Modified:
    click/trunk/click/.classpath
    click/trunk/click/extras/src/org/apache/click/extras/control/FieldColumn.java
    click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java
    click/trunk/click/framework/src/org/apache/click/ClickServlet.java
    click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
    click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java
    click/trunk/click/framework/src/org/apache/click/util/ContainerUtils.java
    click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java
    click/trunk/click/lib/   (props changed)

Modified: click/trunk/click/.classpath
URL: http://svn.apache.org/viewvc/click/trunk/click/.classpath?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/.classpath (original)
+++ click/trunk/click/.classpath Fri Nov  4 11:01:51 2011
@@ -10,7 +10,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
 	<classpathentry kind="lib" path="lib/junit-3.8.1.jar"/>
-	<classpathentry kind="lib" path="lib/ognl-2.6.9.jar"/>
 	<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
 	<classpathentry kind="lib" path="lib/commons-fileupload-1.2.1.jar"/>
 	<classpathentry kind="lib" path="lib/commons-lang-2.5.jar"/>
@@ -28,5 +27,6 @@
 	<classpathentry kind="lib" path="lib/commons-io-2.0.1.jar"/>
 	<classpathentry kind="lib" path="lib/velocity-1.7.jar"/>
 	<classpathentry kind="lib" path="lib/servlet-api-2.4.jar"/>
+	<classpathentry kind="lib" path="lib/mvel2-2.0.19.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/FieldColumn.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/FieldColumn.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/FieldColumn.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/FieldColumn.java Fri Nov  4 11:01:51 2011
@@ -18,11 +18,8 @@
  */
 package org.apache.click.extras.control;
 
-import java.util.HashMap;
 import java.util.Map;
 
-import ognl.OgnlException;
-
 import org.apache.click.Context;
 import org.apache.click.control.Column;
 import org.apache.click.control.Field;
@@ -68,9 +65,6 @@ public class FieldColumn extends Column 
     /** The columns field to process and render. */
     protected Field field;
 
-    /** The ognl context map. */
-    private transient Map<?, ?> ognlContext;
-
     // ----------------------------------------------------------- Constructors
 
     /**
@@ -181,19 +175,7 @@ public class FieldColumn extends Column 
             }
 
         } else {
-            if (ognlContext == null) {
-                ognlContext = new HashMap<Object, Object>();
-            }
-
-            try {
-                PropertyUtils.setValueOgnl(row,
-                                           propertyName,
-                                           value,
-                                           ognlContext);
-
-            } catch (OgnlException oe) {
-                throw new RuntimeException(oe);
-            }
+            PropertyUtils.setValue(row, propertyName, value);
         }
     }
 

Modified: click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/gae/GoogleAppEngineListener.java Fri Nov  4 11:01:51 2011
@@ -21,8 +21,6 @@ package org.apache.click.extras.gae;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import ognl.OgnlRuntime;
-
 /**
  * Provides <a href="http://code.google.com/appengine/docs/java/overview.html" class="external" target="_blank">Google App Engine</a>
  * (GAE) support for Click applications. GAE is a free Java hosting service
@@ -230,8 +228,7 @@ public class GoogleAppEngineListener imp
 
     /**
      * Sets the Ognl Runtime SecurityManager to <tt>null</tt> so as not to
-     * interfere with Google App Engine (GAE). GAE provides its own strict
-     * SecurityManager which clashes with Ognl security checks.
+     * interfere with Google App Engine (GAE).
      *
      * <pre class="prettyprint">
      * OgnlRuntime.setSecurityManager(null); </pre>
@@ -240,6 +237,5 @@ public class GoogleAppEngineListener imp
      * changes to the servlet context
      */
     public void contextInitialized(ServletContextEvent servletContextEvent) {
-        OgnlRuntime.setSecurityManager(null);
     }
 }

Modified: click/trunk/click/framework/src/org/apache/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ClickServlet.java Fri Nov  4 11:01:51 2011
@@ -39,24 +39,17 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
-import ognl.DefaultMemberAccess;
-import ognl.MemberAccess;
-import ognl.Ognl;
-import ognl.OgnlException;
-import ognl.TypeConverter;
-
 import org.apache.click.service.ConfigService;
+import org.apache.click.service.ConfigService.AutoBinding;
 import org.apache.click.service.LogService;
 import org.apache.click.service.ResourceService;
 import org.apache.click.service.TemplateException;
 import org.apache.click.service.XmlConfigService;
-import org.apache.click.service.ConfigService.AutoBinding;
 import org.apache.click.util.ClickUtils;
 import org.apache.click.util.ErrorPage;
 import org.apache.click.util.HtmlStringBuffer;
 import org.apache.click.util.PageImports;
 import org.apache.click.util.PropertyUtils;
-import org.apache.click.util.RequestTypeConverter;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.lang.StringUtils;
@@ -141,12 +134,6 @@ public class ClickServlet extends HttpSe
     protected final static String CONFIG_SERVICE_CLASS = "config-service-class";
 
     /**
-     * The custom TypeConverter classname as an init parameter name:
-     * &nbps; "<tt>type-converter-class</tt>".
-     */
-    protected final static String TYPE_CONVERTER_CLASS = "type-converter-class";
-
-    /**
      * The forwarded request marker attribute: &nbsp; "<tt>click-forward</tt>".
      */
     protected final static String CLICK_FORWARD = "click-forward";
@@ -164,15 +151,9 @@ public class ClickServlet extends HttpSe
     /** The application log service. */
     protected LogService logger;
 
-    /** The OGNL member access handler. */
-    protected MemberAccess memberAccess;
-
     /** The application resource service. */
     protected ResourceService resourceService;
 
-    /** The request parameters OGNL type converter. */
-    protected TypeConverter typeConverter;
-
     /** The thread local page listeners. */
     private static final ThreadLocal<List<PageInterceptor>>
         THREAD_LOCAL_INTERCEPTORS = new ThreadLocal<List<PageInterceptor>>();
@@ -1332,19 +1313,13 @@ public class ClickServlet extends HttpSe
      * returned by the {@link #getTypeConverter()} method.
      *
      * @param page the page whose fields are to be processed
-     * @throws OgnlException if an error occurs
      */
-    protected void processPageRequestParams(Page page) throws OgnlException {
+    protected void processPageRequestParams(Page page) {
 
         if (configService.getPageFields(page.getClass()).isEmpty()) {
             return;
         }
 
-        Map<?, ?> ognlContext = null;
-
-        boolean customConverter =
-            ! getTypeConverter().getClass().equals(RequestTypeConverter.class);
-
         HttpServletRequest request = page.getContext().getRequest();
 
         for (Enumeration<?> e = request.getParameterNames(); e.hasMoreElements();) {
@@ -1358,18 +1333,12 @@ public class ClickServlet extends HttpSe
                 if (field != null) {
                     Class<?> type = field.getType();
 
-                    if (customConverter
-                        || (type.isPrimitive()
-                            || String.class.isAssignableFrom(type)
-                            || Number.class.isAssignableFrom(type)
-                            || Boolean.class.isAssignableFrom(type))) {
-
-                        if (ognlContext == null) {
-                            ognlContext = Ognl.createDefaultContext(
-                                page, null, getTypeConverter(), getMemberAccess());
-                        }
+                    if (type.isPrimitive()
+                        || String.class.isAssignableFrom(type)
+                        || Number.class.isAssignableFrom(type)
+                        || Boolean.class.isAssignableFrom(type)) {
 
-                        PropertyUtils.setValueOgnl(page, name, value, ognlContext);
+                        PropertyUtils.setValue(page, name, value);
 
                         if (logger.isTraceEnabled()) {
                             logger.trace("   auto bound variable: " + name + "=" + value);
@@ -1619,37 +1588,6 @@ public class ClickServlet extends HttpSe
     }
 
     /**
-     * Return the request parameters OGNL <tt>TypeConverter</tt>. This method
-     * performs a lazy load of the TypeConverter object, using the classname
-     * defined in the Servlet init parameter <tt>type-converter-class</tt>,
-     * if this parameter is not defined this method will return a
-     * {@link RequestTypeConverter} instance.
-     *
-     * @return the request parameters OGNL <tt>TypeConverter</tt>
-     * @throws RuntimeException if the TypeConverter instance could not be created
-     */
-    @SuppressWarnings("unchecked")
-    protected TypeConverter getTypeConverter() throws RuntimeException {
-        if (typeConverter == null) {
-            Class<? extends TypeConverter> converter = RequestTypeConverter.class;
-
-            try {
-                String classname = getInitParameter(TYPE_CONVERTER_CLASS);
-                if (StringUtils.isNotBlank(classname)) {
-                    converter = ClickUtils.classForName(classname);
-                }
-
-                typeConverter = converter.newInstance();
-
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        return typeConverter;
-    }
-
-    /**
      * Creates and returns a new Context instance for this path, class and
      * request.
      * <p/>
@@ -1998,25 +1936,12 @@ public class ClickServlet extends HttpSe
     // ------------------------------------------------ Package Private Methods
 
     /**
-     * Return the OGNL <tt>MemberAccess</tt>. This method performs a lazy load
-     * of the MemberAccess object, using a {@link DefaultMemberAccess} instance.
+     * Create a Click application ConfigService instance.
      *
-     * @return the OGNL <tt>MemberAccess</tt>
+     * @param servletContext the Servlet Context
+     * @return a new application ConfigService instance
+     * @throws Exception if an initialization error occurs
      */
-    MemberAccess getMemberAccess() {
-        if (memberAccess == null) {
-            memberAccess = new DefaultMemberAccess(true);
-        }
-        return memberAccess;
-    }
-
-   /**
-    * Create a Click application ConfigService instance.
-    *
-    * @param servletContext the Servlet Context
-    * @return a new application ConfigService instance
-    * @throws Exception if an initialization error occurs
-    */
     @SuppressWarnings("unchecked")
     ConfigService createConfigService(ServletContext servletContext)
         throws Exception {

Modified: click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java (original)
+++ click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java Fri Nov  4 11:01:51 2011
@@ -39,8 +39,6 @@ import java.util.TreeMap;
 
 import javax.servlet.ServletContext;
 
-import ognl.Ognl;
-
 import org.apache.click.Control;
 import org.apache.click.Page;
 import org.apache.click.PageInterceptor;
@@ -1543,7 +1541,7 @@ public class XmlConfigService implements
                 String name = i.next().toString();
                 String value = propertyMap.get(name).toString();
 
-                Ognl.setValue(name, fileUploadService, value);
+                PropertyUtils.setValue(fileUploadService, name, value);
             }
 
         } else {
@@ -1579,7 +1577,7 @@ public class XmlConfigService implements
                 String name = i.next().toString();
                 String value = propertyMap.get(name).toString();
 
-                Ognl.setValue(name, logService, value);
+                PropertyUtils.setValue(logService, name, value);
             }
         } else {
             logService = new ConsoleLogService();
@@ -1608,7 +1606,7 @@ public class XmlConfigService implements
                 String name = i.next().toString();
                 String value = propertyMap.get(name).toString();
 
-                Ognl.setValue(name, messagesMapService, value);
+                PropertyUtils.setValue(messagesMapService, name, value);
             }
         }
 
@@ -1671,7 +1669,7 @@ public class XmlConfigService implements
                 String name = i.next().toString();
                 String value = propertyMap.get(name).toString();
 
-                Ognl.setValue(name, resourceService, value);
+                PropertyUtils.setValue(resourceService, name, value);
             }
 
         } else {
@@ -1707,7 +1705,7 @@ public class XmlConfigService implements
                 String name = i.next().toString();
                 String value = propertyMap.get(name).toString();
 
-                Ognl.setValue(name, templateService, value);
+                PropertyUtils.setValue(templateService, name, value);
             }
 
         } else {
@@ -2176,13 +2174,10 @@ public class XmlConfigService implements
                 try {
                     listener = interceptorClass.newInstance();
 
-                    Map ognlContext = new HashMap();
-
                     for (Property property : properties) {
-                        PropertyUtils.setValueOgnl(listener,
-                                                   property.getName(),
-                                                   property.getValue(),
-                                                   ognlContext);
+                        PropertyUtils.setValue(listener,
+                                               property.getName(),
+                                               property.getValue());
                     }
 
                 } catch (Exception e) {

Modified: click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java (original)
+++ click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java Fri Nov  4 11:01:51 2011
@@ -171,12 +171,12 @@ public class ClickUtils {
         HTML_ENTITIES[166] = "&brvbar;"; // broken bar = broken vertical bar
         HTML_ENTITIES[167] = "&sect;"; // section sign
         HTML_ENTITIES[168] = "&uml;"; // diaeresis = spacing diaeresis
-        HTML_ENTITIES[169] = "&copy;"; // © - copyright sign
+        HTML_ENTITIES[169] = "&copy;"; // © - copyright sign
         HTML_ENTITIES[170] = "&ordf;"; // feminine ordinal indicator
         HTML_ENTITIES[171] = "&laquo;"; // left-pointing double angle quotation mark = left pointing guillemet
         HTML_ENTITIES[172] = "&not;";   //not sign
         HTML_ENTITIES[173] = "&shy;";   //soft hyphen = discretionary hyphen
-        HTML_ENTITIES[174] = "&reg;";   // ® - registered trademark sign
+        HTML_ENTITIES[174] = "&reg;";   // ® - registered trademark sign
         HTML_ENTITIES[175] = "&macr;";   //macron = spacing macron = overline = APL overbar
         HTML_ENTITIES[176] = "&deg;";   //degree sign
         HTML_ENTITIES[177] = "&plusmn;";   //plus-minus sign = plus-or-minus sign
@@ -194,70 +194,70 @@ public class ClickUtils {
         HTML_ENTITIES[189] = "&frac12;";   //vulgar fraction one half = fraction one half
         HTML_ENTITIES[190] = "&frac34;";   //vulgar fraction three quarters = fraction three quarters
         HTML_ENTITIES[191] = "&iquest;";   //inverted question mark = turned question mark
-        HTML_ENTITIES[192] = "&Agrave;";   // À - uppercase A, grave accent
-        HTML_ENTITIES[193] = "&Aacute;";   // Á - uppercase A, acute accent
-        HTML_ENTITIES[194] = "&Acirc;";   // Â - uppercase A, circumflex accent
-        HTML_ENTITIES[195] = "&Atilde;";   // Ã - uppercase A, tilde
-        HTML_ENTITIES[196] = "&Auml;";   // Ä - uppercase A, umlaut
-        HTML_ENTITIES[197] = "&Aring;";   // Å - uppercase A, ring
-        HTML_ENTITIES[198] = "&AElig;";   // Æ - uppercase AE
-        HTML_ENTITIES[199] = "&Ccedil;";   // Ç - uppercase C, cedilla
-        HTML_ENTITIES[200] = "&Egrave;";   // È - uppercase E, grave accent
-        HTML_ENTITIES[201] = "&Eacute;";   // É - uppercase E, acute accent
-        HTML_ENTITIES[202] = "&Ecirc;";   // Ê - uppercase E, circumflex accent
-        HTML_ENTITIES[203] = "&Euml;";   // Ë - uppercase E, umlaut
-        HTML_ENTITIES[204] = "&Igrave;";   // Ì - uppercase I, grave accent
-        HTML_ENTITIES[205] = "&Iacute;";   // Í - uppercase I, acute accent
-        HTML_ENTITIES[206] = "&Icirc;";   // Î - uppercase I, circumflex accent
-        HTML_ENTITIES[207] = "&Iuml;";   // Ï - uppercase I, umlaut
-        HTML_ENTITIES[208] = "&ETH;";   // Ð - uppercase Eth, Icelandic
-        HTML_ENTITIES[209] = "&Ntilde;";   // Ñ - uppercase N, tilde
-        HTML_ENTITIES[210] = "&Ograve;";   // Ò - uppercase O, grave accent
-        HTML_ENTITIES[211] = "&Oacute;";   // Ó - uppercase O, acute accent
-        HTML_ENTITIES[212] = "&Ocirc;";   // Ô - uppercase O, circumflex accent
-        HTML_ENTITIES[213] = "&Otilde;";   // Õ - uppercase O, tilde
-        HTML_ENTITIES[214] = "&Ouml;";   // Ö - uppercase O, umlaut
+        HTML_ENTITIES[192] = "&Agrave;";   // À - uppercase A, grave accent
+        HTML_ENTITIES[193] = "&Aacute;";   // � - uppercase A, acute accent
+        HTML_ENTITIES[194] = "&Acirc;";   // Â - uppercase A, circumflex accent
+        HTML_ENTITIES[195] = "&Atilde;";   // Ã - uppercase A, tilde
+        HTML_ENTITIES[196] = "&Auml;";   // Ä - uppercase A, umlaut
+        HTML_ENTITIES[197] = "&Aring;";   // Ã… - uppercase A, ring
+        HTML_ENTITIES[198] = "&AElig;";   // Æ - uppercase AE
+        HTML_ENTITIES[199] = "&Ccedil;";   // Ç - uppercase C, cedilla
+        HTML_ENTITIES[200] = "&Egrave;";   // È - uppercase E, grave accent
+        HTML_ENTITIES[201] = "&Eacute;";   // É - uppercase E, acute accent
+        HTML_ENTITIES[202] = "&Ecirc;";   // Ê - uppercase E, circumflex accent
+        HTML_ENTITIES[203] = "&Euml;";   // Ë - uppercase E, umlaut
+        HTML_ENTITIES[204] = "&Igrave;";   // Ì - uppercase I, grave accent
+        HTML_ENTITIES[205] = "&Iacute;";   // � - uppercase I, acute accent
+        HTML_ENTITIES[206] = "&Icirc;";   // ÃŽ - uppercase I, circumflex accent
+        HTML_ENTITIES[207] = "&Iuml;";   // � - uppercase I, umlaut
+        HTML_ENTITIES[208] = "&ETH;";   // � - uppercase Eth, Icelandic
+        HTML_ENTITIES[209] = "&Ntilde;";   // Ñ - uppercase N, tilde
+        HTML_ENTITIES[210] = "&Ograve;";   // Ã’ - uppercase O, grave accent
+        HTML_ENTITIES[211] = "&Oacute;";   // Ó - uppercase O, acute accent
+        HTML_ENTITIES[212] = "&Ocirc;";   // Ãâ€? - uppercase O, circumflex accent
+        HTML_ENTITIES[213] = "&Otilde;";   // Õ - uppercase O, tilde
+        HTML_ENTITIES[214] = "&Ouml;";   // Ö - uppercase O, umlaut
         HTML_ENTITIES[215] = "&times;";   //multiplication sign
-        HTML_ENTITIES[216] = "&Oslash;";   // Ø - uppercase O, slash
-        HTML_ENTITIES[217] = "&Ugrave;";   // Ù - uppercase U, grave accent
-        HTML_ENTITIES[218] = "&Uacute;";   // Ú - uppercase U, acute accent
-        HTML_ENTITIES[219] = "&Ucirc;";   // Û - uppercase U, circumflex accent
-        HTML_ENTITIES[220] = "&Uuml;";   // Ü - uppercase U, umlaut
-        HTML_ENTITIES[221] = "&Yacute;";   // Ý - uppercase Y, acute accent
-        HTML_ENTITIES[222] = "&THORN;";   // Þ - uppercase THORN, Icelandic
-        HTML_ENTITIES[223] = "&szlig;";   // ß - lowercase sharps, German
-        HTML_ENTITIES[224] = "&agrave;";   // à - lowercase a, grave accent
-        HTML_ENTITIES[225] = "&aacute;";   // á - lowercase a, acute accent
-        HTML_ENTITIES[226] = "&acirc;";   // â - lowercase a, circumflex accent
-        HTML_ENTITIES[227] = "&atilde;";   // ã - lowercase a, tilde
-        HTML_ENTITIES[228] = "&auml;";   // ä - lowercase a, umlaut
-        HTML_ENTITIES[229] = "&aring;";   // å - lowercase a, ring
-        HTML_ENTITIES[230] = "&aelig;";   // æ - lowercase ae
-        HTML_ENTITIES[231] = "&ccedil;";   // ç - lowercase c, cedilla
-        HTML_ENTITIES[232] = "&egrave;";   // è - lowercase e, grave accent
-        HTML_ENTITIES[233] = "&eacute;";   // é - lowercase e, acute accent
-        HTML_ENTITIES[234] = "&ecirc;";   // ê - lowercase e, circumflex accent
-        HTML_ENTITIES[235] = "&euml;";   // ë - lowercase e, umlaut
-        HTML_ENTITIES[236] = "&igrave;";   // ì - lowercase i, grave accent
-        HTML_ENTITIES[237] = "&iacute;";   // í - lowercase i, acute accent
-        HTML_ENTITIES[238] = "&icirc;";   // î - lowercase i, circumflex accent
-        HTML_ENTITIES[239] = "&iuml;";   // ï - lowercase i, umlaut
-        HTML_ENTITIES[240] = "&eth;";   // ð - lowercase eth, Icelandic
-        HTML_ENTITIES[241] = "&ntilde;";   // ñ - lowercase n, tilde
-        HTML_ENTITIES[242] = "&ograve;";   // ò - lowercase o, grave accent
-        HTML_ENTITIES[243] = "&oacute;";   // ó - lowercase o, acute accent
-        HTML_ENTITIES[244] = "&ocirc;";   // ô - lowercase o, circumflex accent
-        HTML_ENTITIES[245] = "&otilde;";   // õ - lowercase o, tilde
-        HTML_ENTITIES[246] = "&ouml;";   // ö - lowercase o, umlaut
+        HTML_ENTITIES[216] = "&Oslash;";   // Ø - uppercase O, slash
+        HTML_ENTITIES[217] = "&Ugrave;";   // Ù - uppercase U, grave accent
+        HTML_ENTITIES[218] = "&Uacute;";   // Ú - uppercase U, acute accent
+        HTML_ENTITIES[219] = "&Ucirc;";   // Û - uppercase U, circumflex accent
+        HTML_ENTITIES[220] = "&Uuml;";   // Ü - uppercase U, umlaut
+        HTML_ENTITIES[221] = "&Yacute;";   // � - uppercase Y, acute accent
+        HTML_ENTITIES[222] = "&THORN;";   // Þ - uppercase THORN, Icelandic
+        HTML_ENTITIES[223] = "&szlig;";   // ß - lowercase sharps, German
+        HTML_ENTITIES[224] = "&agrave;";   // à - lowercase a, grave accent
+        HTML_ENTITIES[225] = "&aacute;";   // á - lowercase a, acute accent
+        HTML_ENTITIES[226] = "&acirc;";   // â - lowercase a, circumflex accent
+        HTML_ENTITIES[227] = "&atilde;";   // ã - lowercase a, tilde
+        HTML_ENTITIES[228] = "&auml;";   // ä - lowercase a, umlaut
+        HTML_ENTITIES[229] = "&aring;";   // å - lowercase a, ring
+        HTML_ENTITIES[230] = "&aelig;";   // æ - lowercase ae
+        HTML_ENTITIES[231] = "&ccedil;";   // ç - lowercase c, cedilla
+        HTML_ENTITIES[232] = "&egrave;";   // è - lowercase e, grave accent
+        HTML_ENTITIES[233] = "&eacute;";   // é - lowercase e, acute accent
+        HTML_ENTITIES[234] = "&ecirc;";   // ê - lowercase e, circumflex accent
+        HTML_ENTITIES[235] = "&euml;";   // ë - lowercase e, umlaut
+        HTML_ENTITIES[236] = "&igrave;";   // ì - lowercase i, grave accent
+        HTML_ENTITIES[237] = "&iacute;";   // í - lowercase i, acute accent
+        HTML_ENTITIES[238] = "&icirc;";   // î - lowercase i, circumflex accent
+        HTML_ENTITIES[239] = "&iuml;";   // ï - lowercase i, umlaut
+        HTML_ENTITIES[240] = "&eth;";   // ð - lowercase eth, Icelandic
+        HTML_ENTITIES[241] = "&ntilde;";   // ñ - lowercase n, tilde
+        HTML_ENTITIES[242] = "&ograve;";   // ò - lowercase o, grave accent
+        HTML_ENTITIES[243] = "&oacute;";   // ó - lowercase o, acute accent
+        HTML_ENTITIES[244] = "&ocirc;";   // ô - lowercase o, circumflex accent
+        HTML_ENTITIES[245] = "&otilde;";   // õ - lowercase o, tilde
+        HTML_ENTITIES[246] = "&ouml;";   // ö - lowercase o, umlaut
         HTML_ENTITIES[247] = "&divide;";   // division sign
-        HTML_ENTITIES[248] = "&oslash;";   // ø - lowercase o, slash
-        HTML_ENTITIES[249] = "&ugrave;";   // ù - lowercase u, grave accent
-        HTML_ENTITIES[250] = "&uacute;";   // ú - lowercase u, acute accent
-        HTML_ENTITIES[251] = "&ucirc;";   // û - lowercase u, circumflex accent
-        HTML_ENTITIES[252] = "&uuml;";   // ü - lowercase u, umlaut
-        HTML_ENTITIES[253] = "&yacute;";   // ý - lowercase y, acute accent
-        HTML_ENTITIES[254] = "&thorn;";   // þ - lowercase thorn, Icelandic
-        HTML_ENTITIES[255] = "&yuml;";   // ÿ - lowercase y, umlaut
+        HTML_ENTITIES[248] = "&oslash;";   // ø - lowercase o, slash
+        HTML_ENTITIES[249] = "&ugrave;";   // ù - lowercase u, grave accent
+        HTML_ENTITIES[250] = "&uacute;";   // ú - lowercase u, acute accent
+        HTML_ENTITIES[251] = "&ucirc;";   // û - lowercase u, circumflex accent
+        HTML_ENTITIES[252] = "&uuml;";   // ü - lowercase u, umlaut
+        HTML_ENTITIES[253] = "&yacute;";   // ý - lowercase y, acute accent
+        HTML_ENTITIES[254] = "&thorn;";   // þ - lowercase thorn, Icelandic
+        HTML_ENTITIES[255] = "&yuml;";   // ÿ - lowercase y, umlaut
         // http://www.w3.org/TR/REC-html40/sgml/entities.html
         // <!-- Latin Extended-B -->
         HTML_ENTITIES[402] = "&fnof;";   //latin small f with hook = function= florin, U+0192 ISOtech -->
@@ -513,16 +513,30 @@ public class ClickUtils {
         }
 
         OutputStream os = null;
-        GZIPOutputStream gos = null;
         try {
             response.setContentType("text/html");
 
-            if (compress) {
+            // Only compress if flag set, and HTML value is greater than 2K
+            if (compress && buffer.length() > 2024) {
                 response.setHeader("Content-Encoding", "gzip");
 
+                ByteArrayOutputStream bos = null;
+                GZIPOutputStream gos = null;
+                try {
+                    bos = new ByteArrayOutputStream();
+                    gos = new GZIPOutputStream(bos);
+                    gos.write(buffer.toString().getBytes());
+
+                } finally {
+                    ClickUtils.close(gos);
+                    ClickUtils.close(bos);
+                }
+
+                byte[] byteArray = bos.toByteArray();
+                response.setContentLength(byteArray.length);
+
                 os = response.getOutputStream();
-                gos = new GZIPOutputStream(os);
-                gos.write(buffer.toString().getBytes());
+                IOUtils.write(byteArray, os);
 
             } else {
                 response.setContentLength(buffer.length());
@@ -535,7 +549,6 @@ public class ClickUtils {
             ClickUtils.getLogService().error(ex.getMessage(), ex);
 
         } finally {
-            ClickUtils.close(gos);
             ClickUtils.close(os);
         }
     }

Modified: click/trunk/click/framework/src/org/apache/click/util/ContainerUtils.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/util/ContainerUtils.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/ContainerUtils.java (original)
+++ click/trunk/click/framework/src/org/apache/click/util/ContainerUtils.java Fri Nov  4 11:01:51 2011
@@ -20,8 +20,6 @@ package org.apache.click.util;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -29,10 +27,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
-import ognl.DefaultTypeConverter;
-import ognl.Ognl;
-import ognl.OgnlOps;
-
 import org.apache.click.Control;
 import org.apache.click.Page;
 import org.apache.click.control.Button;
@@ -135,8 +129,6 @@ public class ContainerUtils {
         LogService logService = ClickUtils.getLogService();
 
         Set<String> properties = getObjectPropertyNames(object);
-        Map<?, ?> ognlContext = Ognl.createDefaultContext(
-                object, null, new FixBigDecimalTypeConverter(), null);
 
         for (Field field : fieldList) {
 
@@ -155,7 +147,7 @@ public class ContainerUtils {
             ensureObjectPathNotNull(object, fieldName);
 
             try {
-                PropertyUtils.setValueOgnl(object, fieldName, field.getValueObject(), ognlContext);
+                PropertyUtils.setValue(object, fieldName, field.getValueObject());
 
                 if (logService.isDebugEnabled()) {
                     String containerClassName =
@@ -1382,46 +1374,4 @@ public class ContainerUtils {
         ClickUtils.getLogService().warn(message);
     }
 
-    /**
-     * This class fix an error in ognl's conversion of double->BigDecimal. The
-     * default conversion uses BigDecimal(double), the fix is to use
-     * BigDecimal.valueOf(double)
-     *
-     */
-    private static class FixBigDecimalTypeConverter extends DefaultTypeConverter {
-        @SuppressWarnings("unchecked")
-        @Override
-        public Object convertValue(Map context, Object value, Class toType) {
-            if (value != null && toType == BigDecimal.class) {
-                return bigDecValue(value);
-            }
-            return OgnlOps.convertValue(value, toType);
-        }
-
-        /**
-     * Convert the given value into a BigDecimal.
-     *
-     * @param value the object to convert into a BigDecimal
-     * @return the converted BigDecimal value
-     */
-        private BigDecimal bigDecValue(Object value) {
-            if (value == null) {
-                return BigDecimal.valueOf(0L);
-            }
-            Class<?> c = value.getClass();
-            if (c == BigDecimal.class) {
-                return (BigDecimal) value;
-            }
-            if (c == BigInteger.class) {
-                return new BigDecimal((BigInteger) value);
-            }
-            if (c == Boolean.class) {
-                return BigDecimal.valueOf(((Boolean) value).booleanValue() ? 1 : 0);
-            }
-            if (c == Character.class) {
-                return BigDecimal.valueOf(((Character) value).charValue());
-            }
-            return new BigDecimal(value.toString().trim());
-        }
-    }
 }

Modified: click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java?rev=1197500&r1=1197499&r2=1197500&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java (original)
+++ click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java Fri Nov  4 11:01:51 2011
@@ -18,12 +18,13 @@
  */
 package org.apache.click.util;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import ognl.Ognl;
-import ognl.OgnlException;
+import org.mvel2.MVEL;
 
 /**
  * Provide property getter and setter utility methods.
@@ -31,11 +32,13 @@ import ognl.OgnlException;
 @SuppressWarnings("unchecked")
 public class PropertyUtils {
 
-    /** Provides a synchronized cache of OGNL expressions. */
-    private static final Map<String, Object> OGNL_EXPRESSION_CACHE = new ConcurrentHashMap<String, Object>();
-
     /** Provides a synchronized cache of get value reflection methods. */
-    private static final Map<String, Object> GET_METHOD_CACHE = new ConcurrentHashMap<String, Object>();
+    private static final Map<String, Object> GET_METHOD_CACHE
+        = new ConcurrentHashMap<String, Object>();
+
+    /** Provides a synchronized cache of MVEL expressions. */
+    private static final Map<String, Serializable> MVEL_EXPRESSION_CACHE
+        = new ConcurrentHashMap<String, Serializable>();
 
     // -------------------------------------------------------- Public Methods
 
@@ -121,56 +124,28 @@ public class PropertyUtils {
     }
 
     /**
-     * Return the property value for the given object and property name using
-     * the OGNL library.
-     * <p/>
-     * This method is thread-safe, and caches parsed OGNL expressions in an
-     * internal synchronized cache.
-     *
-     * @param source the source object
-     * @param name the name of the property
-     * @param context the OGNL context, do NOT modify this object
-     * @return the property value for the given source object and property name
-     * @throws OgnlException if an OGN error occurs
-     */
-    public static Object getValueOgnl(Object source, String name, Map context)
-        throws OgnlException {
-
-        Object expression = OGNL_EXPRESSION_CACHE.get(name);
-        if (expression == null) {
-            expression = Ognl.parseExpression(name);
-            OGNL_EXPRESSION_CACHE.put(name, expression);
-        }
-
-        return Ognl.getValue(expression, context, source);
-    }
-
-    /**
-     * Return the property value for the given object and property name using
-     * the OGNL library.
-     * <p/>
-     * This method is thread-safe, and caches parsed OGNL expressions in an
-     * internal synchronized cache.
+     * Return the property value for the given object and property name using the MVEL library.
      *
      * @param target the target object to set the property of
      * @param name the name of the property to set
      * @param value the property value to set
-     * @param context the OGNL context, do NOT modify this object
-     * @throws OgnlException if an OGN error occurs
      */
-    public static void setValueOgnl(Object target, String name, Object value, Map context)
-        throws OgnlException {
+    public static void setValue(Object target, String name, Object value) {
+
+        String expression = target.getClass().getSimpleName() + "." + name + " = value";
 
-        Object expression = OGNL_EXPRESSION_CACHE.get(name);
-        if (expression == null) {
-            expression = Ognl.parseExpression(name);
-            OGNL_EXPRESSION_CACHE.put(name, expression);
+        Serializable compiledExpression = MVEL_EXPRESSION_CACHE.get(expression);
+
+        if (compiledExpression == null) {
+            compiledExpression = MVEL.compileExpression(expression);
+            MVEL_EXPRESSION_CACHE.put(expression, compiledExpression);
         }
 
-        Ognl.setValue(expression,
-                      context,
-                      target,
-                      value);
+        Map vars = new HashMap();
+        vars.put(target.getClass().getSimpleName(), target);
+        vars.put("value", value);
+
+        MVEL.executeExpression(compiledExpression, vars);
     }
 
     // -------------------------------------------------------- Private Methods

Propchange: click/trunk/click/lib/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Nov  4 11:01:51 2011
@@ -17,3 +17,4 @@ servlet-api-2.3.jar
 hibernate-*.jar
 freemarker-*.jar
 velocity-*.jar
+mvel2-2.0.19.jar