Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Igor Drobiazko on Tapestry5

Igor Drobiazko on Tapestry5

More Decks by Enterprise Java User Group Austria

Other Decks in Technology

Transcript

  1. About Me • Apache Tapestry Committer • Project Management Committee

    • Tapestry Evangelist • Book author & Speaker • http://tapestry5.de • [email protected]
  2. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 1.0 1.0
  3. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0
  4. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 1.0
  5. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 1.0 1.0
  6. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 1.0 1.0 1.0
  7. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 4.0 1.0 1.0 1.0
  8. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 4.0 1.0 2.0 1.0 1.0
  9. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 4.0 5.0 1.0 2.0 1.0 1.0
  10. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 4.0 5.0 1.0 2.0 2.0 1.0 1.0
  11. History of Web Frameworks 2000 2001 2002 2003 2004 2005

    2006 2007 2008 2009 2010 2011 3.0 1.0 1.0 4.0 5.0 1.0 2.0 2.0 1.0 5.1 5.2 1.0
  12. Tapestry Templates public class Index { ! ! public String

    getHello() { ! ! return "Hello, World!"; ! } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> </body> </html> ${hello} Index.tml Index.java
  13. Tapestry Templates public class Index { ! ! public String

    getHello() { ! ! return "Hello, World!"; ! } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> </body> </html> ${hello} Index.tml Index.java
  14. Tapestry Templates public class Index { ! ! public String

    getHello() { ! ! return "Hello, World!"; ! } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> </body> </html> Index.tml Index.java
  15. Tapestry Templates public class Index { ! ! public String

    getHello() { ! ! return "Hello, World!"; ! } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> </body> </html> ${prop:hello} Index.tml Index.java
  16. Invisible Instrumentation <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:pagelink page="MyPage">Go to MyPage</t:pagelink> </body>

    </html> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="pagelink" page="MyPage">Go to MyPage</a> </body> </html>
  17. Meta Programming public class Login { ! @Property @Persist private

    String username; @Property @Persist private String password; @Inject private Session session; @CommitAfter @DiscardAfter public Object onSuccess() { User user = (User) session.createCriteria(User.class) .add(Restrictions.eq("username", username)); ... user.setLastLogin(new Date()); ! return UserProfile.class; } }
  18. State Management public class MyPage { @Persist private String value;

    ! @SessionState private User user; ... } Persistent field Session State Object
  19. Tapestry Components public class HelloComponent { @Parameter private String name;

    public String getHello(){ return "Hello, " + name; } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:helloComponent name="literal:Igor"/> </body> </html> MyPage.tml HelloComponent.java
  20. Tapestry Components public class HelloComponent { @Parameter private String name;

    public String getHello(){ return "Hello, " + name; } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:helloComponent name="literal:Igor"/> </body> </html> MyPage.tml HelloComponent.java
  21. Tapestry Components public class HelloComponent { @Parameter private String name;

    public String getHello(){ return "Hello, " + name; } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:helloComponent name="literal:Igor"/> </body> </html> <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> ${hello} </div> MyPage.tml HelloComponent.java HelloComponent.tml
  22. Tapestry Components public class HelloComponent { @Parameter private String name;

    public String getHello(){ return "Hello, " + name; } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:helloComponent name="literal:Igor"/> </body> </html> <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> ${hello} </div> MyPage.tml HelloComponent.java HelloComponent.tml
  23. public class HelloComponent { @Parameter private String name; void beginRender(MarkupWriter

    writer){ writer.element("div"); writer.write("Hello, " + name); writer.end(); } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:helloComponent name="literal:Igor"/> </body> </html> HelloComponent.java MyPage.tml Tapestry Components
  24. public class HelloComponent { @Parameter private String name; void beginRender(MarkupWriter

    writer){ writer.element("div"); writer.write("Hello, " + name); writer.end(); } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:helloComponent name="literal:Igor"/> </body> </html> HelloComponent.java MyPage.tml Tapestry Components
  25. Component Rendering public class HelloComponent { @Parameter private String name;

    boolean beginRender(MarkupWriter writer){ writer.element("div"); writer.write("Hello, " + name); writer.end(); return false; } }
  26. Component Rendering public class HelloComponent { @Parameter private String name;

    void beginRender(MarkupWriter writer){ writer.element("div"); } void beforeRenderBody(MarkupWriter writer){ writer.write("Hello, " + name); } void afterRender(MarkupWriter writer){ writer.end(); } }
  27. public class Index { ! ! void onAction() { !

    ! ... ! } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="actionlink">Click me</a> </body> </html> Index.tml Index.java Component Events 1/3
  28. public class Index { ! ! void onAction() { !

    ! ... ! } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="actionlink">Click me</a> </body> </html> Index.tml Index.java Component Events 1/3
  29. Component Events 2/3 public class Index { ! ! void

    onActionFromFirst(){...} void onActionFromSecond(){...} } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="actionlink" t:id="first">Click me</a> <a t:type="actionlink" t:id="second">Click me too</a> </body> </html> Index.tml Index.java
  30. Component Events 2/3 public class Index { ! ! void

    onActionFromFirst(){...} void onActionFromSecond(){...} } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="actionlink" t:id="first">Click me</a> <a t:type="actionlink" t:id="second">Click me too</a> </body> </html> Index.tml Index.java
  31. Component Events 2/3 public class Index { ! ! void

    onActionFromFirst(){...} void onActionFromSecond(){...} } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="actionlink" t:id="first">Click me</a> <a t:type="actionlink" t:id="second">Click me too</a> </body> </html> Index.tml Index.java
  32. Component Events 2/3 public class Index { ! ! void

    onActionFromFirst(){...} void onActionFromSecond(){...} } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <a t:type="actionlink" t:id="first">Click me</a> <a t:type="actionlink" t:id="second">Click me too</a> </body> </html> public class Index { ! @OnEvent(component="first", event="action") ! void foo() {...} @OnEvent(component="second", event="action") void bar() {...} } Index.tml Index.java Index.java
  33. public class Login { ! void onValidateForm() { ... }

    void onSuccess() { ... } void onFailure() { ... } } <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <t:form> <t:texfield value="username"/> <t:passwordfield value="password"/> <input type="submit"> </t:form> </body> </html> Login.tml Login.java Component Events 3/3
  34. Events & Page Navigation public class Index { @InjectPage private

    MyPage myPage; ! ! Object onAction(){ return myPage; } }
  35. Events & Page Navigation public class Index { ! Object

    onAction(){ return „MyPage“; } }
  36. Events & Page Navigation public class Index { ! Object

    onAction(){ return MyPage.class; } }
  37. Events & Page Navigation public class Index { ! Object

    onAction() throws MalformedURLException { return new URL(“http://www.google.com“); } }