click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r797778 - in /incubator/click/trunk/click: documentation/docs/roadmap-changes.html framework/src/org/apache/click/service/ConfigService.java framework/src/org/apache/click/service/XmlConfigService.java
Date Sat, 25 Jul 2009 14:46:48 GMT
Author: sabob
Date: Sat Jul 25 14:46:48 2009
New Revision: 797778

URL: http://svn.apache.org/viewvc?rev=797778&view=rev
Log:
added support for custom template extensions. CLK-568

Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/framework/src/org/apache/click/service/ConfigService.java
    incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.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=797778&r1=797777&r2=797778&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Sat Jul 25 14:46:48
2009
@@ -161,6 +161,20 @@
           [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-560">560</a>].
       </li>
       <li class="change">
+          Added support for an in-memory <a href="extras-api/org/apache/click/extras/gae/MemoryFileUploadService.html">File
Upload Service</a>
+          that can be used for uploading files in a <a class="external" target="_blank"
href="http://code.google.com/appengine/docs/java/overview.html">Google App Engine</a>
+          environment.
+      </li>
+       <li class="change">
+          Added support for templates with custom extensions through the new
+          ConfigService.<a href="click-api/org/apache/click/service/ConfigService.html#isTemplate(java.lang.String)">isTemplate</a>
+          method. The default ConfigService implementation, XmlConfigService, provides
+          support for the extensions <tt>.htm</tt> and <tt>.jsp</tt>,
but new extensions
+          can be provided in a subclass. See the <a href="click-api/org/apache/click/service/XmlConfigService.html#isTemplate(java.lang.String)">JavaDoc</a>
+          for details
+          [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-568">568</a>].
+      </li>
+      <li class="change">
           Added new Calendar popup to DateField. This Calendar popup uses
           <a target="_blank" class="external" href="http://code.google.com/p/calendardateselect/">Calendar
Date Select</a>
           which is based on the Prototype JavaScript library.

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/ConfigService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/ConfigService.java?rev=797778&r1=797777&r2=797778&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/ConfigService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/ConfigService.java
Sat Jul 25 14:46:48 2009
@@ -34,6 +34,7 @@
  * startup. Once the ConfigService has been initialized it is stored in the
  * ServletContext using the key "<tt>org.apache.click.service.ConfigService</tt>".
  *
+ * <a href="#" name="config"></a>
  * <h3>Configuration</h3>
  * The default ConfigService is {@link XmlConfigService}.
  * <p/>
@@ -209,6 +210,33 @@
     public boolean isJspPage(String path);
 
     /**
+     * Return true if the given resource is a Page class template, false
+     * otherwise.
+     * <p/>
+     * Below is an example showing how to map <tt>.htm</tt> and <tt>.jsp</tt>
+     * files as Page class templates.
+     *
+     * <pre class="prettyprint">
+     * public class XmlConfigService implements ConfigService {
+     *
+     *     ...
+     *
+     *     public boolean isTemplate(String path) {
+     *         if (path.endsWith(".htm") || path.endsWith(".jsp")) {
+     *             return true;
+     *         }
+     *         return false;
+     *     }
+     *
+     *     ...
+     * } </pre>
+     *
+     * @param path the path to check if it is a Page class template or not
+     * @return true if the resource is a Page class template, false otherwise
+     */
+    public boolean isTemplate(String path);
+
+    /**
      * Return the page auto binding mode. If the mode is "PUBLIC" any public
      * Page fields will be auto bound, if the mode is "ANNOTATION" any Page field
      * with the "Bindable" annotation will be auto bound and if the mode is

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java?rev=797778&r1=797777&r2=797778&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
Sat Jul 25 14:46:48 2009
@@ -405,6 +405,94 @@
     }
 
     /**
+     * Return true if the given path is a Page class template, false
+     * otherwise. By default this method returns true if the path has a
+     * <tt>.htm</tt> or <tt>.jsp</tt> extension.
+     * <p/>
+     * If you want to map alternative templates besides <tt>.htm</tt> and
+     * <tt>.jsp</tt> files you can override this method and provide extra
+     * checks against the given path whether it should be added as a
+     * template or not.
+     * <p/>
+     * Below is an example showing how to allow <tt>.xml</tt> paths to
+     * be recognized as Page class templates.
+     *
+     * <pre class="prettyprint">
+     * public class MyConfigService extends XmlConfigService {
+     *
+     *     protected boolean isTemplate(String path) {
+     *         // invoke default implementation
+     *         boolean isTemplate = super.isTemplate(path);
+     *
+     *         if (!isTemplate) {
+     *             // If path has an .xml extension, mark it as a template
+     *             isTemplate = path.endsWith(".xml");
+     *         }
+     *         return isTemplate;
+     *     }
+     * } </pre>
+     *
+     * Here is an example <tt>web.xml</tt> showing how to configure a custom
+     * ConfigService through the context parameter <tt>config-service-class</tt>.
+     * We also map <tt>*.xml</tt> requests to be routed through ClickServlet:
+     *
+     * <pre class="prettyprint">
+     * &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+     *   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     *   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+     *   version="2.4"&gt;
+     *
+     *   &lt;!-- Specify a custom ConfigService through the context param 'config-service-class'
--&gt;
+     *   &lt;context-param&gt;
+     *     &lt;param-name&gt;config-service-class&lt;/param-name&gt;
+     *     &lt;param-value&gt;com.mycorp.service.MyConfigSerivce&lt;/param-value&gt;
+     *   &lt;/context-param&gt;
+     *
+     *   &lt;servlet&gt;
+     *     &lt;servlet-name&gt;ClickServlet&lt;/servlet-name&gt;
+     *     &lt;servlet-class&gt;org.apache.click.ClickServlet&lt;/servlet-class&gt;
+     *     &lt;load-on-startup&gt;0&lt;/load-on-startup&gt;
+     *   &lt;/servlet&gt;
+     *
+     *   &lt;!-- NOTE: we still map the .htm extension --&gt;
+     *   &lt;servlet-mapping&gt;
+     *     &lt;servlet-name&gt;ClickServlet&lt;/servlet-name&gt;
+     *     &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
+     *   &lt;/servlet-mapping&gt;
+     *
+     *   &lt;!-- NOTE: we also map .xml extension in order to route xml requests to the
ClickServlet --&gt;
+     *   &lt;servlet-mapping&gt;
+     *     &lt;servlet-name&gt;ClickServlet&lt;/servlet-name&gt;
+     *     &lt;url-pattern&gt;*.xml&lt;/url-pattern&gt;
+     *   &lt;/servlet-mapping&gt;
+     *
+     *   ...
+     *
+     * &lt;/web-app&gt; </pre>
+     *
+     * <b>Please note</b>: even though you can add extra template mappings by
+     * overriding this method, it is still recommended to keep the default
+     * <tt>.htm</tt> mapping by invoking <tt>super.isTemplate(String)</tt>.
+     * The reason being that Click ships with some default templates such as
+     * {@link ConfigService#ERROR_PATH} and {@link ConfigService#NOT_FOUND_PATH}
+     * that must be mapped as <tt>.htm</tt>.
+     * <p/>
+     * Please see the ConfigService <a href="#config">javadoc</a> for details
+     * on how to configure a custom ConfigService implementation.
+     *
+     * @see ConfigService#isTemplate(String)
+     *
+     * @param path the path to check if it is a Page class template or not
+     * @return true if the path is a Page class template, false otherwise
+     */
+    public boolean isTemplate(String path) {
+        if (path.endsWith(".htm") || path.endsWith(".jsp")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
      * @see ConfigService#getPageClass(String)
      *
      * @param path the page path
@@ -1637,7 +1725,7 @@
         for (Iterator i = resources.iterator(); i.hasNext();) {
             String resource = (String) i.next();
 
-            if (resource.endsWith(".htm") || resource.endsWith(".jsp")) {
+            if (isTemplate(resource)) {
                 fileList.add(resource);
 
             } else if (resource.endsWith("/")) {
@@ -1659,7 +1747,7 @@
             for (Iterator i = resources.iterator(); i.hasNext();) {
                 String resource = (String) i.next();
 
-                if (resource.endsWith(".htm") || resource.endsWith(".jsp")) {
+                if (isTemplate(resource)) {
                     fileList.add(resource);
 
                 } else if (resource.endsWith("/")) {



Mime
View raw message