click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r797912 - in /incubator/click/trunk/click: documentation/docs/ documentation/xdocs/src/docbook/click/ examples/src/org/apache/click/examples/page/general/ examples/webapp/general/ framework/src/org/apache/click/ framework/src/org/apache/cli...
Date Sun, 26 Jul 2009 11:40:19 GMT
Author: sabob
Date: Sun Jul 26 11:40:19 2009
New Revision: 797912

URL: http://svn.apache.org/viewvc?rev=797912&view=rev
Log:
Deprecated Page.getPageImports. Added includeControlHeadElements. CLK-571

Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-best-practices.xml
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageImportsExample.java
    incubator/click/trunk/click/examples/webapp/general/page-imports-example.htm
    incubator/click/trunk/click/framework/src/org/apache/click/Page.java
    incubator/click/trunk/click/framework/src/org/apache/click/util/PageImports.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=797912&r1=797911&r2=797912&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Sun Jul 26 11:40:19
2009
@@ -86,11 +86,11 @@
       when upgrading from previous releases.
     </div>
     <div style="margin-left:-2em;margin-bottom:1em;">
-      <span style="font-weight: bold; color: navy;">Please Note:</span>
+      <b>Please Note:</b>
       This release requires Java 1.5 or later.
     </div>
     <div style="margin-left: -2em; margin-top: 1.5em; margin-bottom: 1em;">
-      New examples:
+      <b>New examples:</b>
     </div>
     <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
       <li>
@@ -131,7 +131,7 @@
     </ul>
 
     <div style="margin-left: -2em; margin-top: 1.5em; margin-bottom: 1em;">
-      New documentation:
+      <b>New documentation:</b>
     </div>
     <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
       <li>
@@ -149,7 +149,26 @@
     </ul>
 
     <div style="margin-left: -2em; margin-top: 1.5em; margin-bottom: 1em;">
-      New features and issues resolved:
+      <b>Deprecated:</b>
+    </div>
+    <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
+       <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">
+          Deprecated methods: <a href="click-api/org/apache/click/Page.html#getPageImports()">Page.getPageImports()</a>
+          and <a href="click-api/org/apache/click/Page.html#setPageImports(org.apache.click.util.PageImports)">Page.setPageImports()</a>.
+          These methods have been deprecated in favor of
+          <a href="click-api/org/apache/click/Page.html#getHeadElements()">Page.getHeadElements()</a>.
+      </li>
+    </ul>
+
+    <div style="margin-left: -2em; margin-top: 1.5em; margin-bottom: 1em;">
+      <b>New features and issues resolved:</b>
     </div>
     <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
       <li class="change">
@@ -175,6 +194,12 @@
           [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-568">568</a>].
       </li>
       <li class="change">
+          Added support to the Page class for conditionally including Control
+          <a href="click-api/org/apache/click/Page.html#getHeadElements()">head elements</a>
+          through the new method <a href="click-api/org/apache/click/Page.html#setIncludeControlHeadElements(boolean)">includeControlHeadElements</a>
+          [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-571">571</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.
@@ -359,13 +384,6 @@
           [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-557">557</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">
           Update Velocity library to version 1.6.2.
       </li>
       <li class="change">

Modified: incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-best-practices.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-best-practices.xml?rev=797912&r1=797911&r2=797912&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-best-practices.xml
(original)
+++ incubator/click/trunk/click/documentation/xdocs/src/docbook/click/chapter-best-practices.xml
Sun Jul 26 11:40:19 2009
@@ -872,19 +872,18 @@
     compressed files, home-page.css and home-page.js.
     </para>
 
-    <para>Click makes use of the utility class
-    <ulink url="../../click-api/org/apache/click/util/PageImports.html">PageImports</ulink>
-    to include the CSS and JavaScript. PageImports exposes the method
-    <ulink url="../../click-api/org/apache/click/util/PageImports.html#setInitialized(boolean)">setInitialized(boolean)</ulink>,
-    which controls when PageImports are fully initialized. Once PageImports have
-    been initialized, no other CSS and JavaScript will be included.
+    <para>The Click Page class exposes the property
+    <ulink url="../../click-api/org/apache/click/Page.html#setIncludeControlHeadElements(boolean)">includeControlHeadElements</ulink>
+    that indicates whether Controls have their CSS and JavaScript resources
+    included or not.
     </para>
 
-    <para>Knowing this one can override
-    <ulink url="../../click-api/org/apache/click/Page.html#getPageImports()">Page.getPageImports()</ulink>,
-    and import the necessary JavaScript and CSS files and then set PageImports to
-    <literal>initialized</literal>, forcing PageImports to skip other CSS and
-    JavaScript files.
+    <para>To optimize Page loading one can override
+    <ulink url="../../click-api/org/apache/click/Page.html#getHeadElements()">Page.getHeadElements()</ulink>,
+    and import the JavaScript and CSS files and then set the property
+    <ulink url="../../click-api/org/apache/click/Page.html#setIncludeControlHeadElements(boolean)">includeControlHeadElements</ulink>
+    to <literal>false</literal>, indicating that Controls won't contribute
+    their own JavaScript and CSS resources.
     </para>
 
     <para>Here is an example:</para>
@@ -894,24 +893,21 @@
     private Form form = new Form("form");
 
     public void onInit() {
+        // Indicate that Controls should not import their head elements
+        setIncludeControlHeadElements(false);
+
         form.add(new EmailField("email");
         addControl(form);
     }
 
-    public PageImports getPageImports () {
-        PageImports pageImports = super.getPageImports();
-
-        // Add the Page Css to the PageImports
-        pageImports.add(new CssImport("/assets/css/home-page.css"));
-
-        // Add the Page JS to the PageImports
-        pageImports.add(new JsImport("/assets/js/home-page.js"));
-
-        // Set pageImports to initialized so that no other Css and JavaScript
-        // files will be included.
-        pageImports.setInitialized(true);
-        
-        return pageImports;
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            headElements.add(new CssImport("/assets/css/home-page.css"));
+            headElements.add(new JsImport("/assets/js/home-page.js"));
+        }
+        return headElements;
     }
 }</programlisting>
 

Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageImportsExample.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageImportsExample.java?rev=797912&r1=797911&r2=797912&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageImportsExample.java
(original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageImportsExample.java
Sun Jul 26 11:40:19 2009
@@ -23,29 +23,21 @@
 import org.apache.click.element.JsImport;
 import org.apache.click.element.JsScript;
 import org.apache.click.examples.page.BorderPage;
-import org.apache.click.util.PageImports;
 
 /**
  * This page provides an example of how to programatically optimize your
  * PageImports for high traffic pages. You optimize your Page by combinding
  * multiple CSS and JavaScript import files into a single file, which reduces
  * the number of HTTP requests required to serve the page.
+ * <p/>
+ * Then you set the Page property "includeControlHeadElements" to false so that
+ * Controls won't have their head elements imported.
  */
 public class PageImportsExample extends BorderPage {
 
-    /**
-     * Provides an optimized home page imports.
-     *
-     * @see org.apache.click.Page#getPageImports()
-     */
-    @Override
-    public PageImports getPageImports() {
-        PageImports pageImports = super.getPageImports();
-
-        pageImports.addAll(getHeadElements());
-        pageImports.setInitialized(true);
-
-        return pageImports;
+    public PageImportsExample() {
+        // Indicate that Controls should not import their head elements
+        setIncludeControlHeadElements(false);
     }
 
     /**

Modified: incubator/click/trunk/click/examples/webapp/general/page-imports-example.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/general/page-imports-example.htm?rev=797912&r1=797911&r2=797912&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/general/page-imports-example.htm (original)
+++ incubator/click/trunk/click/examples/webapp/general/page-imports-example.htm Sun Jul 26
11:40:19 2009
@@ -17,9 +17,10 @@
    under the License.*#
 -->
 
-This page provides an example of how to programatically optimize your PageImports for
-high traffic pages. By optimizing your PageImports you can combine CSS and JavaScript
-import files and reduce the number of HTTP requests required to serve the page.
+This page provides an example of how to programatically optimize your Page
+imports for high traffic pages. You optimize your Page imports by combining
+CSS and JavaScript import files which reduces the number of HTTP requests required
+to serve the page.
 <p/>
 This is one of the Yahoo performance best practice rules :
 <a target="_blank" class="external" href="http://developer.yahoo.com/performance/rules.html#num_http">Minimize
HTTP Requests</a>.

Modified: incubator/click/trunk/click/framework/src/org/apache/click/Page.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/Page.java?rev=797912&r1=797911&r2=797912&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/Page.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/Page.java Sun Jul 26 11:40:19
2009
@@ -193,13 +193,19 @@
 
     /**
      * The page is stateful and should be saved to the users HttpSession
-     * between requests.
+     * between requests, default value is false.
      */
     protected boolean stateful;
 
     /** The path of the page border template to render.*/
     protected String template;
 
+    /**
+     * Indicates whether Control head elements should be included in the
+     * page template, default value is true.
+     */
+    protected boolean includeControlHeadElements = true;
+
     // --------------------------------------------------------- Event Handlers
 
     /**
@@ -645,9 +651,6 @@
      * <p/>
      * The order in which JS and CSS files are included will be preserved in the
      * page.
-     * <p/>
-     * If you need to customize the HTML imports included in your page override
-     * the method {@link #getPageImports()}.
      *
      * @return the HTML includes statements for the control stylesheet and
      * JavaScript files, by default this method returns null
@@ -927,6 +930,8 @@
      * If you need to create a custom PageImports, override the method
      * {@link ClickServlet#createPageImports(org.apache.click.Page)}
      *
+     * @deprecated use the new {@link #getHeadElements()} instead
+     *
      * @return the Page header imports
      */
     public PageImports getPageImports() {
@@ -953,6 +958,8 @@
      * If you need to create a custom PageImports, override the method
      * {@link ClickServlet#createPageImports(org.apache.click.Page)}
      *
+     * @deprecated use the new {@link #getHeadElements()} instead
+     *
      * @param pageImports the new pageImports instance to set
      */
     public void setPageImports(PageImports pageImports) {
@@ -1023,7 +1030,7 @@
 
     /**
      * Return true if the page is stateful and should be saved in the users
-     * HttpSession between requests.
+     * HttpSession between requests, default value is false.
      *
      * @return true if the page is stateful and should be saved in the users
      * session
@@ -1059,6 +1066,70 @@
     }
 
     /**
+     * Return true if the Control head elements should be included in the page
+     * template, false otherwise. Default value is true.
+     *
+     * @see #setIncludeControlHeadElements(boolean)
+     *
+     * @return true if the Control head elements should be included in the page
+     * template, false otherwise
+     */
+    public boolean isIncludeControlHeadElements() {
+        return includeControlHeadElements;
+    }
+
+    /**
+     * Set whether the Control head elements should be included in the page
+     * template.
+     * <p/>
+     * By setting this value to <tt>false</tt>, Click won't include Control's
+     * {@link #getHeadElements() head elements}, however the Page head elements
+     * will still be included.
+     * <p/>
+     * This allows one to create a single JavaScript and CSS resource file for
+     * the entire Page which increases performance, since the browser only has
+     * to load one resource, instead of multiple resources.
+     * <p/>
+     * Below is an example:
+     *
+     * <pre class="prettyprint">
+     * public class HomePage extends Page {
+     *
+     *     private Form form = new Form("form");
+     *
+     *     public HomePage() {
+     *         // Indicate that Controls should not import their head elements
+     *         setIncludeControlHeadElements(false);
+     *
+     *         form.add(new EmailField("email");
+     *         addControl(form);
+     *     }
+     *
+     *     // Include the Page JavaScript and CSS resources
+     *     public List getHeadElements() {
+     *         if (headElements == null) {
+     *             headElements = super.getHeadElements();
+     *
+     *             // Include the Page CSS resource. This resource should combine
+     *             // all the CSS necessary for the page
+     *             headElements.add(new CssImport("/assets/css/home-page.css"));
+     *
+     *             // Include the Page JavaScript resource. This resource should
+     *             // combine all the JavaScript necessary for the page
+     *             headElements.add(new JsImport("/assets/js/home-page.js"));
+     *         }
+     *         return headElements;
+     *     }
+     * } </pre>
+     *
+     * @param includeControlHeadElements flag indicating whether Control
+     * head elements should be included in the page
+     */
+    public void setIncludeControlHeadElements(boolean includeControlHeadElements) {
+        this.includeControlHeadElements = includeControlHeadElements;
+    }
+
+    /**
      * Set the location to redirect the request to.
      * <p/>
      * If the {@link #redirect} property is not null it will be used to redirect

Modified: incubator/click/trunk/click/framework/src/org/apache/click/util/PageImports.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/util/PageImports.java?rev=797912&r1=797911&r2=797912&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/util/PageImports.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/util/PageImports.java Sun Jul
26 11:40:19 2009
@@ -550,8 +550,10 @@
 
         setInitialized(true);
 
-        if (page.hasControls()) {
-            processControls(page.getControls());
+        if (page.isIncludeControlHeadElements()) {
+            if (page.hasControls()) {
+                processControls(page.getControls());
+            }
         }
 
         addImport(page.getHtmlImports());



Mime
View raw message