You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/07/06 08:25:25 UTC

svn commit: r791391 - in /incubator/click/trunk/click/examples: src/org/apache/click/examples/page/general/PageHeadDemo.java webapp/general/page-head-demo.htm

Author: sabob
Date: Mon Jul  6 06:25:25 2009
New Revision: 791391

URL: http://svn.apache.org/viewvc?rev=791391&view=rev
Log:
updated docs for page-head-demo

Modified:
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java
    incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm

Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java?rev=791391&r1=791390&r2=791391&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/PageHeadDemo.java Mon Jul  6 06:25:25 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.click.examples.page.general;
 
+import java.util.List;
 import java.util.Map;
 import org.apache.click.Context;
 import org.apache.click.control.ActionLink;
@@ -48,33 +49,41 @@
          // Create a new TextField and add it the Page controls
         field = new TextField("field");
 
-        // Add JavaScript and Css imports
-        setHeadElements();
-
         addControl(link);
         addControl(field);
     }
 
-    private void setHeadElements() {
-        // Add a Css import to the Page
-        getHeadElements().add(new CssImport("/general/page-head-demo.css"));
-
-        // Add inline Css content to the Page that increases the field font-size
-        getHeadElements().add(new CssStyle("#" + field.getId() + " { font-size: 18px; }"));
-
-        // Add the JQuery library to the Page
-        getHeadElements().add(new JsImport("/assets/js/jquery-1.3.2.js"));
-
-        // Add a JQuery template which adds a 'click' listener to the link
-        // that will show/hide the field
-        Context context = getContext();
-
-        // Create a template model and pass in the linkId
-        Map jsModel = ClickUtils.createTemplateModel(this, context);
-        jsModel.put("linkId", '#' + link.getId());
-
-        String content = context.renderTemplate("/general/page-head-demo.js", jsModel);
-
-        getHeadElements().add(new JsScript(content));
+    /**
+     * Return the Page list of HEAD elements.
+     *
+     * @return the Page list of HEAD elements
+     */
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            // Add a Css import to the Page
+            headElements.add(new CssImport("/general/page-head-demo.css"));
+
+            // Add inline Css content to the Page that increases the field font-size
+            headElements.add(new CssStyle("#" + field.getId() + " { font-size: 18px; }"));
+
+            // Add the JQuery library to the Page
+            headElements.add(new JsImport("/assets/js/jquery-1.3.2.js"));
+
+            // Add a JQuery template which adds a 'click' listener to the link
+            // that will show/hide the field
+            Context context = getContext();
+
+            // Create a template model and pass in the linkId
+            Map jsModel = ClickUtils.createTemplateModel(this, context);
+            jsModel.put("linkId", '#' + link.getId());
+
+            String content =
+                context.renderTemplate("/general/page-head-demo.js", jsModel);
+
+            headElements.add(new JsScript(content));
+        }
+        return headElements;
     }
 }

Modified: incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm?rev=791391&r1=791390&r2=791391&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm (original)
+++ incubator/click/trunk/click/examples/webapp/general/page-head-demo.htm Mon Jul  6 06:25:25 2009
@@ -17,14 +17,15 @@
    under the License.*#
 -->
 
-This demo shows how to manipulate the HEAD elements of a Page by adding
-the JQuery library and render the JavaScript
-<a href="$context/source-viewer.htm?filename=/general/page-head-demo.js">page-head-demo.js</a>
-to the Field's HEAD elements.
+This demo shows how to add
+<a href="http://incubator.apache.org/click/docs/click-api/org/apache/click/Page.html#getHeadElements()">HEAD elements</a>
+to a Page. In this example the <a class="external" target="_blank" href="http://jquery.com/">jQuery</a>
+library and the JavaScript snippet, <a href="$context/source-viewer.htm?filename=/general/page-head-demo.js">page-head-demo.js</a>,
+are added to the Page's HEAD elements.
 <p/>
 
-The <tt>page-head-demo.js</tt> uses JQuery to register a 'click' listener on the
-link that toggles the 'field-div' visibility.
+The <a href="$context/source-viewer.htm?filename=/general/page-head-demo.js">page-head-demo.js</a> script,
+uses jQuery to register a 'click' listener on the link to toggle the Field visibility.
 
 <hr/>