click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r758016 - in /incubator/click/trunk/click: documentation/docs/roadmap-changes.html framework/src/org/apache/click/ClickServlet.java framework/src/org/apache/click/util/ClickUtils.java
Date Tue, 24 Mar 2009 20:58:34 GMT
Author: sabob
Date: Tue Mar 24 20:58:33 2009
New Revision: 758016

URL: http://svn.apache.org/viewvc?rev=758016&view=rev
Log:
added convenience method ClickUtils.createTemplateModel, to allow easy creationg of Velocity
templating models

Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java
    incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.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=758016&r1=758015&r2=758016&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Tue Mar 24 20:58:33
2009
@@ -85,6 +85,22 @@
     </div>
     <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
       <li>
+        <a target="_blank" class="external" href="http://www.avoka.com/click-examples/general/page-head-demo.htm">
+        Page HEAD elements example</a> demonstrates how to add
+        <a href="click-api/org/apache/click/control/element/JsImport.html">JsImport</a>,
+        <a href="click-api/org/apache/click/control/element/JsScript.html">JsScript</a>,
+        <a href="click-api/org/apache/click/control/element/CssImport.html">CssImport</a>
+        and <a href="click-api/org/apache/click/control/element/CssStyle.html">CssStyle</a>
+        HEAD elements to a Page.
+      </li>
+      <li>
+        <a target="_blank" class="external" href="http://www.avoka.com/click-examples/general/control-head-demo.htm">
+        Control HEAD elements example</a> demonstrates how to add
+        <a href="click-api/org/apache/click/control/element/JsImport.html">JsImport</a>
and
+        <a href="click-api/org/apache/click/control/element/CssImport.html">CssImport</a>
+        HEAD elements to a custom Control.
+      </li>
+      <li>
         <a target="_blank" class="external" href="http://www.avoka.com/click-examples/table/large-dataset-demo.htm">
         Large Dataset Demo</a> demonstrates a Table with a large number of rows
         and how to lazily page through the rows using a custom Table model.
@@ -97,10 +113,48 @@
     </ul>
 
     <div style="margin-left: -2em; margin-top: 1.5em; margin-bottom: 1em;">
+      New documentation:
+    </div>
+    <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
+      <li>
+        Added documentation describing the new HEAD element support.
+        Please see the new section on Page HEAD elements
+        <a target="blank" class="external" href="user-guide/html/ch02s12.html">here</a>
+        the section on Control HEAD elements <a target="blank" class="external" href="user-guide/html/ch03s05.html">here</a>.
+      </li>
+    </ul>
+
+    <div style="margin-left: -2em; margin-top: 1.5em; margin-bottom: 1em;">
       New features and issues resolved:
     </div>
     <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
       <li class="change">
+          Added first class support for HEAD elements such as JavaScript and Css.
+          The following classes were added:
+          <a href="click-api/org/apache/click/control/element/Element.html">Element</a>,
+          <a href="click-api/org/apache/click/control/element/ResourceElement.html">ResourceElement</a>,
+          <a href="click-api/org/apache/click/control/element/JsImport.html">JsImport</a>,
+          <a href="click-api/org/apache/click/control/element/JsScript.html">JsScript</a>,
+          <a href="click-api/org/apache/click/control/element/CssImport.html">CssImport</a>
+          and <a href="click-api/org/apache/click/control/element/CssStyle.html">CssStyle</a>.
+          A new method was added to Page and Control: <a href="click-api/org/apache/click/Control.html#getHeadElements()">Control.getHeadElements()</a>
+          and <a href="click-api/org/apache/click/Page.html#getHeadElements()">Page.getHeadElements()</a>.
+          [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-501">501</a>].
+      </li>
+      <li class="change">
+          Deprecated methods: <a href="click-api/org/apache/click/Control.html#getHtmlImports()">Control.getHtmlImports()</a>
and
+          <a href="click-api/org/apache/click/Page.html#getHtmlImports()">Page.getHtmlImports()</a>.
+          These methods have been deprecated in favor of
+          <a href="click-api/org/apache/click/Control.html#getHeadElements()">Control.getHeadElements()</a>
+          and <a href="click-api/org/apache/click/Page.html#getHeadElements()">Page.getHeadElements()</a>.
+      </li>
+      <li class="change">
+          Added method,
+          <a href="click-api/org/apache/click/util/ClickUtils.html#createTemplateModel(org.apache.click.Page,
org.apache.click.Context)">ClickUtils.createTemplateModel</a>,
+          which returns a template model containing objects such as the Context
+          path, Page path, HTTP request, HTTP response, HTTP session etc.
+      </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=758016&r1=758015&r2=758016&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 Tue Mar 24
20:58:33 2009
@@ -1011,84 +1011,8 @@
             });
         }
 
-        final Map model = new HashMap(page.getModel());
-
-        final HttpServletRequest request = page.getContext().getRequest();
-
-        Object pop = model.put("request", request);
-        if (pop != null && !page.isStateful()) {
-            String msg = page.getClass().getName() + " on " + page.getPath()
-                         + " model contains an object keyed with reserved "
-                         + "name \"request\". The page model object "
-                         + pop + " has been replaced with the request object";
-            logger.warn(msg);
-        }
-
-        pop = model.put("response", page.getContext().getResponse());
-        if (pop != null && !page.isStateful()) {
-            String msg = page.getClass().getName() + " on " + page.getPath()
-                         + " model contains an object keyed with reserved "
-                         + "name \"response\". The page model object "
-                         + pop + " has been replaced with the response object";
-            logger.warn(msg);
-        }
-
-        SessionMap sessionMap = new SessionMap(request.getSession(false));
-        pop = model.put("session", sessionMap);
-        if (pop != null && !page.isStateful()) {
-            String msg = page.getClass().getName() + " on " + page.getPath()
-                         + " model contains an object keyed with reserved "
-                         + "name \"session\". The page model object "
-                         + pop + " has been replaced with the request "
-                         + " session";
-            logger.warn(msg);
-        }
-
-        pop = model.put("context", request.getContextPath());
-        if (pop != null && !page.isStateful()) {
-            String msg = page.getClass().getName() + " on " + page.getPath()
-                         + " model contains an object keyed with reserved "
-                         + "name \"context\". The page model object "
-                         + pop + " has been replaced with the request "
-                         + " context path";
-            logger.warn(msg);
-        }
-
-        Format format = page.getFormat();
-        if (format != null) {
-            pop = model.put("format", format);
-            if (pop != null && !page.isStateful()) {
-                String msg = page.getClass().getName() + " on "
-                        + page.getPath()
-                        + " model contains an object keyed with reserved "
-                        + "name \"format\". The page model object " + pop
-                        + " has been replaced with the format object";
-                logger.warn(msg);
-            }
-        }
-
-        String path = page.getPath();
-        if (path != null) {
-           pop = model.put("path", path);
-            if (pop != null && !page.isStateful()) {
-                String msg = page.getClass().getName() + " on "
-                        + page.getPath()
-                        + " model contains an object keyed with reserved "
-                        + "name \"path\". The page model object " + pop
-                        + " has been replaced with the page path";
-                logger.warn(msg);
-            }
-        }
-
-        pop = model.put("messages", page.getMessages());
-        if (pop != null && !page.isStateful()) {
-            String msg = page.getClass().getName() + " on " + page.getPath()
-                         + " model contains an object keyed with reserved "
-                         + "name \"messages\". The page model object "
-                         + pop + " has been replaced with the request "
-                         + " messages";
-            logger.warn(msg);
-        }
+        final Context context = page.getContext();
+        final Map model = ClickUtils.createTemplateModel(page, context);
 
         PageImports pageImports = page.getPageImports();
         pageImports.popuplateTemplateModel(model);

Modified: incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java?rev=758016&r1=758015&r2=758016&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java Tue Mar
24 20:58:33 2009
@@ -41,6 +41,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -642,6 +643,129 @@
     }
 
     /**
+     * Creates a template model of key/value pairs which can be used by template
+     * engines such as Velocity and Freemarker.
+     * <p/>
+     * The following objects will be added to the model:
+     * <ul>
+     * <li>the Page {@link org.apache.click.Page#model model} Map key/value
+     * pairs
+     * </li>
+     * <li>context - the Servlet context path, e.g. <span class="">/mycorp</span>
+     * </li>
+     * <li>format - the Page {@link Format} object for formatting the display
+     * of objects.
+     * </li>
+     * <li>messages - the {@link MessagesMap} adaptor for the
+     * {@link org.apache.click.Page#getMessages()} method.
+     * </li>
+     * <li>path - the {@link org.apache.click.Page#path path} of the <tt>page</tt>
+     * template.
+     * </li>
+     * <li>request - the page {@link javax.servlet.http.HttpServletRequest}
+     * object.
+     * </li>
+     * <li>response - the page {@link javax.servlet.http.HttpServletResponse}
+     * object.
+     * </li>
+     * <li>session - the {@link SessionMap} adaptor for the users
+     * {@link javax.servlet.http.HttpSession}.
+     * </li>
+     * </ul>
+     *
+     * @param page the page to populate the template model from
+     * @param context the request context
+     * @return a template model as a map
+     */
+    //public static Map createTemplateModel(final Page page, Context context) {
+    public static Map createTemplateModel(final Page page, Context context) {
+
+        ConfigService configService = ClickUtils.getConfigService(context.getServletContext());
+        LogService logger = configService.getLogService();
+
+        final Map model = new HashMap(page.getModel());
+
+        final HttpServletRequest request = context.getRequest();
+
+        Object pop = model.put("request", request);
+        if (pop != null && !page.isStateful()) {
+            String msg = page.getClass().getName() + " on " + page.getPath()
+                         + " model contains an object keyed with reserved "
+                         + "name \"request\". The page model object "
+                         + pop + " has been replaced with the request object";
+            logger.warn(msg);
+        }
+
+        pop = model.put("response", context.getResponse());
+        if (pop != null && !page.isStateful()) {
+            String msg = page.getClass().getName() + " on " + page.getPath()
+                         + " model contains an object keyed with reserved "
+                         + "name \"response\". The page model object "
+                         + pop + " has been replaced with the response object";
+            logger.warn(msg);
+        }
+
+        SessionMap sessionMap = new SessionMap(request.getSession(false));
+        pop = model.put("session", sessionMap);
+        if (pop != null && !page.isStateful()) {
+            String msg = page.getClass().getName() + " on " + page.getPath()
+                         + " model contains an object keyed with reserved "
+                         + "name \"session\". The page model object "
+                         + pop + " has been replaced with the request "
+                         + " session";
+            logger.warn(msg);
+        }
+
+        pop = model.put("context", request.getContextPath());
+        if (pop != null && !page.isStateful()) {
+            String msg = page.getClass().getName() + " on " + page.getPath()
+                         + " model contains an object keyed with reserved "
+                         + "name \"context\". The page model object "
+                         + pop + " has been replaced with the request "
+                         + " context path";
+            logger.warn(msg);
+        }
+
+        Format format = page.getFormat();
+        if (format != null) {
+            pop = model.put("format", format);
+            if (pop != null && !page.isStateful()) {
+                String msg = page.getClass().getName() + " on "
+                        + page.getPath()
+                        + " model contains an object keyed with reserved "
+                        + "name \"format\". The page model object " + pop
+                        + " has been replaced with the format object";
+                logger.warn(msg);
+            }
+        }
+
+        String path = page.getPath();
+        if (path != null) {
+           pop = model.put("path", path);
+            if (pop != null && !page.isStateful()) {
+                String msg = page.getClass().getName() + " on "
+                        + page.getPath()
+                        + " model contains an object keyed with reserved "
+                        + "name \"path\". The page model object " + pop
+                        + " has been replaced with the page path";
+                logger.warn(msg);
+            }
+        }
+
+        pop = model.put("messages", page.getMessages());
+        if (pop != null && !page.isStateful()) {
+            String msg = page.getClass().getName() + " on " + page.getPath()
+                         + " model contains an object keyed with reserved "
+                         + "name \"messages\". The page model object "
+                         + pop + " has been replaced with the request "
+                         + " messages";
+            logger.warn(msg);
+        }
+
+        return model;
+    }
+
+    /**
      * Invalidate the specified cookie and delete it from the response object.
      * <p/>
      * This method was derived from Atlassian <tt>CookieUtils</tt> method of



Mime
View raw message