You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by ml...@apache.org on 2013/08/01 16:52:16 UTC
[06/13] git commit: TAP5-2153 Adapt quickstart archetype generated
sources to be bootstrap and 5.4 compatibile adapt pages to use bootstrap
example template
TAP5-2153 Adapt quickstart archetype generated sources to be bootstrap and 5.4 compatibile
adapt pages to use bootstrap example template
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/e9469dc0
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/e9469dc0
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/e9469dc0
Branch: refs/heads/master
Commit: e9469dc04f486a8ca2a855e898734b79fdc63c13
Parents: 2d4e009
Author: Massimo Lusetti <ml...@apache.org>
Authored: Thu Aug 1 16:28:08 2013 +0200
Committer: Massimo Lusetti <ml...@apache.org>
Committed: Thu Aug 1 16:28:08 2013 +0200
----------------------------------------------------------------------
.../src/main/java/components/Layout.java | 80 +++++-----
.../src/main/java/pages/About.java | 14 +-
.../src/main/java/pages/Index.java | 90 +++++++----
.../src/main/resources/components/Layout.tml | 155 +++++++++----------
.../src/main/resources/pages/About.tml | 20 ++-
.../src/main/resources/pages/Index.tml | 73 +++++----
6 files changed, 241 insertions(+), 191 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e9469dc0/quickstart/filtered/archetype-resources/src/main/java/components/Layout.java
----------------------------------------------------------------------
diff --git a/quickstart/filtered/archetype-resources/src/main/java/components/Layout.java b/quickstart/filtered/archetype-resources/src/main/java/components/Layout.java
index 0de75d6..d2d3732 100644
--- a/quickstart/filtered/archetype-resources/src/main/java/components/Layout.java
+++ b/quickstart/filtered/archetype-resources/src/main/java/components/Layout.java
@@ -1,53 +1,51 @@
package ${package}.components;
import org.apache.tapestry5.*;
+import org.apache.tapestry5.alerts.AlertManager;
import org.apache.tapestry5.annotations.*;
+import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.corelib.components.PasswordField;
+import org.apache.tapestry5.corelib.components.TextField;
+import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.*;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.SymbolConstants;
/**
- * Layout component for pages of application ${artifactId}.
+ * Layout component for pages of application test-project.
*/
-@Import(stylesheet = "context:layout/layout.css")
public class Layout
{
- /**
- * The page title, for the <title> element and the <h1> element.
- */
- @Property
- @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
- private String title;
-
- @Property
- private String pageName;
-
- @Property
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private String sidebarTitle;
-
- @Property
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private Block sidebar;
-
- @Inject
- private ComponentResources resources;
-
- @Property
- @Inject
- @Symbol(SymbolConstants.APPLICATION_VERSION)
- private String appVersion;
-
-
- public String getClassForPageName()
- {
- return resources.getPageName().equalsIgnoreCase(pageName)
- ? "current_page_item"
- : null;
- }
-
- public String[] getPageNames()
- {
- return new String[]{"Index", "About", "Contact"};
- }
-}
+ @Inject
+ private ComponentResources resources;
+
+ /**
+ * The page title, for the <title> element and the <h1> element.
+ */
+ @Property
+ @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
+ private String title;
+
+ @Property
+ private String pageName;
+
+ @Property
+ @Inject
+ @Symbol(SymbolConstants.APPLICATION_VERSION)
+ private String appVersion;
+
+
+
+ public String getClassForPageName()
+ {
+ return resources.getPageName().equalsIgnoreCase(pageName)
+ ? "active"
+ : null;
+ }
+
+ public String[] getPageNames()
+ {
+ return new String[]{"Index", "About", "Contact"};
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e9469dc0/quickstart/filtered/archetype-resources/src/main/java/pages/About.java
----------------------------------------------------------------------
diff --git a/quickstart/filtered/archetype-resources/src/main/java/pages/About.java b/quickstart/filtered/archetype-resources/src/main/java/pages/About.java
index 3dce2c0..2cdd9c4 100644
--- a/quickstart/filtered/archetype-resources/src/main/java/pages/About.java
+++ b/quickstart/filtered/archetype-resources/src/main/java/pages/About.java
@@ -1,6 +1,18 @@
package ${package}.pages;
+import org.apache.tapestry5.annotations.PageActivationContext;
+
public class About
{
+ @PageActivationContext
+ private String learn;
+
+
+ public String getLearn() {
+ return learn;
+ }
-}
+ public void setLearn(String learn) {
+ this.learn = learn;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e9469dc0/quickstart/filtered/archetype-resources/src/main/java/pages/Index.java
----------------------------------------------------------------------
diff --git a/quickstart/filtered/archetype-resources/src/main/java/pages/Index.java b/quickstart/filtered/archetype-resources/src/main/java/pages/Index.java
index 74d03db..daf40ab 100644
--- a/quickstart/filtered/archetype-resources/src/main/java/pages/Index.java
+++ b/quickstart/filtered/archetype-resources/src/main/java/pages/Index.java
@@ -1,50 +1,76 @@
package ${package}.pages;
-import java.util.Date;
-import org.apache.tapestry5.annotations.*;
-import org.apache.tapestry5.ioc.annotations.*;
-import org.apache.tapestry5.corelib.components.*;
+
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.SymbolConstants;
-import org.apache.tapestry5.alerts.AlertManager;
+import org.apache.tapestry5.annotations.InjectPage;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.services.HttpError;
+import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
+import org.slf4j.Logger;
+
+import java.util.Date;
/**
* Start page of application ${artifactId}.
*/
public class Index
{
- @Property
- @Inject
- @Symbol(SymbolConstants.TAPESTRY_VERSION)
- private String tapestryVersion;
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private AjaxResponseRenderer ajaxResponseRenderer;
+
+ @Property
+ @Inject
+ @Symbol(SymbolConstants.TAPESTRY_VERSION)
+ private String tapestryVersion;
+
+ @InjectPage
+ private About about;
+
+ @Inject
+ private Block block;
+
- @InjectComponent
- private Zone zone;
+ // Handle call with an unwanted context
+ Object onActivate(EventContext eventContext)
+ {
+ return eventContext.getCount() > 0 ?
+ new HttpError(404, "Resource not found") :
+ null;
+ }
- @Persist
- @Property
- private int clickCount;
- @Inject
- private AlertManager alertManager;
+ Object onActionFromLearnMore()
+ {
+ about.setLearn("LearnMore");
- public Date getCurrentTime()
- {
- return new Date();
- }
+ return about;
+ }
- void onActionFromIncrement()
- {
- alertManager.info("Increment clicked");
+ @Log
+ void onComplete()
+ {
+ logger.info("Complete call on Index page");
+ }
- clickCount++;
- }
+ @Log
+ void onAjax()
+ {
+ logger.info("Ajax call on Index page");
- Object onActionFromIncrementAjax()
- {
- clickCount++;
+ ajaxResponseRenderer.addRender("middlezone", block);
+ }
- alertManager.info("Increment (via Ajax) clicked");
- return zone;
- }
-}
+ public Date getCurrentTime()
+ {
+ return new Date();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e9469dc0/quickstart/filtered/archetype-resources/src/main/resources/components/Layout.tml
----------------------------------------------------------------------
diff --git a/quickstart/filtered/archetype-resources/src/main/resources/components/Layout.tml b/quickstart/filtered/archetype-resources/src/main/resources/components/Layout.tml
index 115d4bf..f5ab93f 100644
--- a/quickstart/filtered/archetype-resources/src/main/resources/components/Layout.tml
+++ b/quickstart/filtered/archetype-resources/src/main/resources/components/Layout.tml
@@ -1,89 +1,80 @@
<!DOCTYPE html>
-<!--
-
-Design by Free CSS Templates
-http://www.freecsstemplates.org
-Released for free under a Creative Commons Attribution 2.5 License
-
-Title : Concrete (modified for Tapestry)
-Version : 1.0
-Released : 20080825
-Description: A Web 2.0 design with fluid width suitable for blogs and small websites.
--->
- #set( $D = '$' )
-<html xmlns="http://www.w3.org/1999/xhtml"
+<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
- <title>${D}{title}</title>
- </head>
- <body>
- <!-- start header -->
- <div class="header">
- <div class="logo">
- <h1>
- <t:pagelink page="index">${groupId}:${artifactId}</t:pagelink>
-
- version ${D}{appVersion}
- </h1>
- </div>
- <div class="menu">
- <ul>
- <li t:type="loop" source="pageNames" value="pageName" class="prop:classForPageName">
- <t:pagelink page="prop:pageName">${D}{pageName}</t:pagelink>
- </li>
- </ul>
- </div>
- </div>
- <!-- end header -->
- <!-- start page -->
- <div class="page">
- <!-- start sidebar -->
- <div class="sidebar">
- <ul>
- <li class="search" style="background: none;">
- </li>
- <li>
- <t:alerts/>
- </li>
- <li t:type="if" test="sidebar">
- <h2>${D}{sidebarTitle}</h2>
+<head>
+ <meta charset="utf-8" />
+ <title>${D}{title}</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="" />
+ <meta name="author" content="" />
+
+ <!-- Le styles -->
+ <style type="text/css">
+ body {
+ padding-top: 60px;
+ padding-bottom: 40px;
+ }
+ </style>
+
+ <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script src="../assets/js/html5shiv.js"></script>
+ <![endif]-->
+
+ <!-- Fav and touch icons -->
+ <link rel="shortcut icon" href="${D}{asset:context:/favicon.ico}" />
+</head>
+
+<body>
- <div class="sidebar-content">
- <t:delegate to="sidebar"/>
- </div>
- </li>
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <t:pagelink page="index" class="brand">${artifactId}</t:pagelink>
+ <div class="nav-collapse collapse">
+ <ul class="nav">
+ <t:loop source="pageNames" value="pageName">
+ <li class="prop:classForPageName">
+ <t:pagelink page="prop:pageName">${D}{pageName}</t:pagelink>
+ </li>
+ </t:loop>
</ul>
- </div>
- <!-- end sidebar -->
- <!-- start content -->
- <div class="content">
- <div class="post">
- <div class="title">
- <h2>${D}{title}</h2>
- </div>
- <div class="entry">
- <t:body/>
- </div>
- </div>
- </div>
- <!-- end content -->
- <br style="clear: both;"/>
+ <span class="pull-right">
+ <t:pagelink page="login">
+ <button type="submit" class="btn">Sign in</button>
+ </t:pagelink>
+ </span>
+
+ </div><!--/.nav-collapse -->
</div>
- <!-- end page -->
- <!-- start footer -->
- <div class="footer">
- <p class="legal">
- ©@year@ ${groupId}. All Rights Reserved.
- •
- Design by
- <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>
- •
- Icons by
- <a href="http://famfamfam.com/">FAMFAMFAM</a>.
- </p>
+ </div>
+</div>
+
+<div class="container">
+ <div class="row">
+ <div class="span12">
+ <t:alerts/>
</div>
- <!-- end footer -->
- </body>
-</html>
+ </div>
+</div>
+
+<div class="container">
+
+ <t:body />
+
+ <hr />
+
+ <footer>
+ <p>© Your Company 2013</p>
+ </footer>
+
+</div> <!-- /container -->
+
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e9469dc0/quickstart/filtered/archetype-resources/src/main/resources/pages/About.tml
----------------------------------------------------------------------
diff --git a/quickstart/filtered/archetype-resources/src/main/resources/pages/About.tml b/quickstart/filtered/archetype-resources/src/main/resources/pages/About.tml
index b63a401..5add626 100644
--- a/quickstart/filtered/archetype-resources/src/main/resources/pages/About.tml
+++ b/quickstart/filtered/archetype-resources/src/main/resources/pages/About.tml
@@ -2,6 +2,22 @@
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
- <p>About ${artifactId} application ...</p>
+ <div class="row">
+ <div class="span12">
+ <p>About ${artifactId} application ...</p>
+ </div>
+ </div>
-</html>
+ <t:if test="learn">
+ <div class="row">
+ <div class="span12">
+ <p>
+ To learn more go to
+ <a href="http://tapestry.apache.org">Tapestry home</a>
+ and start typing...
+ </p>
+ </div>
+ </div>
+ </t:if>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e9469dc0/quickstart/filtered/archetype-resources/src/main/resources/pages/Index.tml
----------------------------------------------------------------------
diff --git a/quickstart/filtered/archetype-resources/src/main/resources/pages/Index.tml b/quickstart/filtered/archetype-resources/src/main/resources/pages/Index.tml
index edeb3d5..6bc607b 100644
--- a/quickstart/filtered/archetype-resources/src/main/resources/pages/Index.tml
+++ b/quickstart/filtered/archetype-resources/src/main/resources/pages/Index.tml
@@ -2,42 +2,49 @@
t:sidebarTitle="Framework Version"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
- #set( $D = '$' )
- <!-- Most of the page content, including <head>, <body>, etc. tags, comes from Layout.tml -->
-
- <p>${D}{message:greeting}</p>
- <p>The current time is: <strong>${D}{currentTime}</strong></p>
-
- <!-- A Zone is a component that can be updated in place, triggered by other components. -->
- <t:zone t:id="zone">
- <p>
- You have clicked the link <strong>${D}{clickCount}</strong> times.
- </p>
-
- <p>
- [
- <t:actionlink t:id="increment">increment</t:actionlink>
- ]
-
- [
- <t:actionlink t:id="incrementAjax" zone="^">increment (via Ajax)</t:actionlink>
- ]
- </p>
-
- </t:zone>
+ <!-- Most of the page content, including <head>, <body>, etc. tags, comes from Layout.tml -->
- <p:sidebar>
+ <!-- Main hero unit for a primary marketing message or call to action -->
+ <div class="hero-unit">
<p>
- You are running Tapestry version <strong>${D}{tapestryVersion}</strong>.
+ <img src="${D}{asset:context:images/tapestry.png}"
+ alt="${D}{message:greeting}" title="${D}{message:greeting}" />
</p>
-
-
+ <h3>${D}{message:greeting}</h3>
+ <p>The current time is: <strong>${D}{currentTime}</strong></p>
<p>
- [
- <t:pagelink page="Index">refresh page</t:pagelink>
- ]
+ This is a template for a simple marketing or informational website. It includes a large callout called
+ the hero unit and three supporting pieces of content. Use it as a starting point to create something
+ more unique.
</p>
- </p:sidebar>
-
-</html>
+ <p><t:actionlink t:id="learnmore" class="btn btn-primary btn-large">Learn more »</t:actionlink></p>
+ </div>
+
+ <t:alerts />
+
+ <!-- Example row of columns -->
+ <div class="row">
+ <div class="span4">
+ <h2>Normal link</h2>
+ <p>Clink the bottom link and the page refresh with event <code>complete</code></p>
+ <p><t:eventlink event="complete" class="btn" >Complete»</t:eventlink></p>
+ </div>
+ <t:zone t:id="middlezone" class="span4">
+
+ </t:zone>
+ <div class="span4">
+ <h2>Ajax link</h2>
+ <p>Click the bottom link to update just the middle column with Ajax call with event <code>ajax</code></p>
+ <p><t:eventlink event="ajax" zone="middlezone" class="btn" >Ajax»</t:eventlink></p>
+ </div>
+ </div>
+
+ <t:block t:id="block">
+ <h2>Ajax updated</h2>
+ <p>I'v been updated through AJAX call</p>
+ <p>The current time is: <strong>${D}{currentTime}</strong></p>
+ <t:alerts />
+ </t:block>
+
+</html>
\ No newline at end of file