click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r775450 - in /incubator/click/trunk/click: documentation/docs/roadmap-changes.html framework/src/org/apache/click/ClickServlet.java
Date Sat, 16 May 2009 11:45:10 GMT
Author: medgar
Date: Sat May 16 11:45:10 2009
New Revision: 775450

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

Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java

Modified: incubator/click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/roadmap-changes.html?rev=775450&r1=775449&r2=775450&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Sat May 16 11:45:10
2009
@@ -193,6 +193,12 @@
           [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-528">528</a>].
       </li>
       <li class="change">
+          Added TypeConverter configuration option to ClickServlet. 
+          See <a href="click-api/org/apache/click/ClickServlet.html#getTypeConverter()">getTypeConverter()</a>
+          method for details. This issue was raised Joseph Schmidt and fixed by Adrian A.
+          [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-539">539</a>].
+      </li>
+      <li class="change">
           Improved Table to support very large datasets by promoting the methods
           <a href="click-api/org/apache/click/control/Table.html#getFirstRow()">getFirstRow()</a>
           and <a href="click-api/org/apache/click/control/Table.html#getLastRow()">getLastRow()</a>

Modified: incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=775450&r1=775449&r2=775450&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java Sat May 16
11:45:10 2009
@@ -137,6 +137,12 @@
     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";
@@ -146,7 +152,7 @@
      */
     protected final static String FORWARD_PAGE = "forward-page";
 
-    // ------------------------------------------------------ Instance Varables
+    // ----------------------------------------------------- Instance Variables
 
     /** The click application configuration service. */
     protected ConfigService configService;
@@ -174,7 +180,6 @@
             // Create and initialize the application config service
             configService = createConfigService(getServletContext());
             initConfigService(getServletContext());
-
             logger = configService.getLogService();
 
             if (logger.isInfoEnabled()) {
@@ -1380,14 +1385,30 @@
     }
 
     /**
-     * Return the request parameters OGNL <tt>TypeConverter</tt>. By default
-     * this method returns a {@link RequestTypeConverter} instance.
+     * 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
      */
-    protected TypeConverter getTypeConverter() {
+    protected TypeConverter getTypeConverter() throws RuntimeException {
         if (typeConverter == null) {
-            typeConverter = new RequestTypeConverter();
+            Class converter = RequestTypeConverter.class;
+
+            try {
+                String classname = getInitParameter(TYPE_CONVERTER_CLASS);
+                if (StringUtils.isNotBlank(classname)) {
+                    converter = ClickUtils.classForName(classname);
+                }
+
+                typeConverter = (TypeConverter) converter.newInstance();
+
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
         }
 
         return typeConverter;



Mime
View raw message