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/06/22 09:24:12 UTC

svn commit: r787157 - in /incubator/click/trunk/click/examples: src/org/apache/click/examples/page/general/PageImportsExample.java webapp/general/page-imports-example.htm

Author: sabob
Date: Mon Jun 22 07:24:12 2009
New Revision: 787157

URL: http://svn.apache.org/viewvc?rev=787157&view=rev
Log:
reuse BorderPage template

Modified:
    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

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=787157&r1=787156&r2=787157&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 Mon Jun 22 07:24:12 2009
@@ -18,17 +18,21 @@
  */
 package org.apache.click.examples.page.general;
 
+import java.util.List;
+import org.apache.click.element.CssImport;
+import org.apache.click.element.JsImport;
+import org.apache.click.element.JsScript;
 import org.apache.click.examples.page.BorderPage;
-import org.apache.click.util.ClickUtils;
 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.
+ */
 public class PageImportsExample extends BorderPage {
 
-    private static final String IMPORTS =
-        "<link type=\"text/css\" rel=\"stylesheet\" href=\"{0}/assets/css/imports.css\" title=\"Style\"/>\n"
-        + "<script type=\"text/javascript\" src=\"{0}/assets/js/imports.js\"></script>\n"
-        + "<script type=\"text/javascript\">addLoadEvent(function() '{' initMenu(); '}');</script>";
-
     /**
      * Provides an optimized home page imports.
      *
@@ -38,20 +42,26 @@
     public PageImports getPageImports() {
         PageImports pageImports = super.getPageImports();
 
-        String imports = ClickUtils.createHtmlImport(IMPORTS, getContext());
-
-        pageImports.addImport(imports);
+        pageImports.addAll(getHeadElements());
         pageImports.setInitialized(true);
 
         return pageImports;
     }
 
     /**
-     * @see org.apache.click.Page#getTemplate()
+     * Return the list of the Page HEAD elements.
+     *
+     * @return the list of Page HEAD elements
      */
     @Override
-    public String getTemplate() {
-        return getPath();
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+            
+            headElements.add(new CssImport("/assets/css/imports.css"));
+            headElements.add(new JsImport("/assets/js/imports.js"));
+            headElements.add(new JsScript("addLoadEvent(function() { initMenu(); });"));
+        }
+        return headElements;
     }
-
 }

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=787157&r1=787156&r2=787157&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 Mon Jun 22 07:24:12 2009
@@ -17,48 +17,7 @@
    under the License.*#
 -->
 
-<html>
-<head>
-<title>Click Examples</title>
-${headElements}
-<link rel="Click icon" href="$context/favicon.ico" type="image/ico"/>
-</head>
-<body>
-<center>
-<table height="100%" border="0" cellpadding="0" cellspacing="4" class="page">
-## Title Header
-<tr>
-	<td width="100%">			
-		<table cellpadding="0" cellspacing="0" width="100%" border="0" style="border-collapse:collapse;">
-			<tr>
-				<td class="title-icon">
-					<a target="blank" href="http://incubator.apache.org/click/"><img src="${context}/assets/images/click-icon-blue-32.png" border="0" alt="Click"/></a>
-				</td>
-				<td class="title-left" width="100%">
-					$title
-				</td>
-				<td class="title-hosted">
-					<p>Version ${messages.version}</p>
-					<a target="blank" href="http://www.avoka.com">Hosted by Avoka Technologies</a>
-				</td>
-			</tr>
-			<tr>
-				<td class="header-color" colspan="3">&nbsp;</td>
-			</tr>
-		</table>
-	</td>
-</tr>
-## Menu
-<tr>		
-	<td>
-#if (${rootMenu})
-#writeMenu(${rootMenu})
-#end
-	</td>
-</tr>
-## Page Content
-<tr>		
-	<td class="content">
+<p/>
 
 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
@@ -72,15 +31,3 @@
 and
 <a target="_blank" href="$context/source-viewer.htm?filename=$path" title="Page Content source"><img border="0" class="link" alt="" src="/click-examples/assets/images/lightbulb2.png"/> Page HTML</a>
 for more details.
-
-	</td>
-</tr>
-## Vertical Spacer
-<tr>		
-	<td height="100%">&nbsp;</td>
-</tr>
-</table>
-</center>
-${jsElements}
-</body>
-</html>