21. Managed Bean Registration @ManagedBean @SessionScoped public class User { public String getFirstName() { … } }
22. Managed Bean Reference <!-- Instead of this: --> <h:outputText value="#{sessionScope.user.firstName}"/> <!-- We can now do this: --> <h:outputText value="#{user.firstName}"/>
30. My First Wicket Application public class HelloApplication extends WebApplication { @Override public Class<Hello> getHomePage() { return Hello.class; } }
31. My First Wicket Page (HTML) <html xmlns:wicket="…"> <head><title>Hello, Wicket!</title></head> <body> <!-- My first Wicket component (html) --> Hello, <span wicket:id="name" >Foo</span>! </body> </html>
32. My First Wicket Page (Java) public class Hello extends WebPage { public Hello() { // My first Wicket component (Java) add(new Label( "name" , "World")); } }
50. My First Tapestry Page (TML) <html xmlns:t="…"> <head><title>Hello, Tapestry!</title></head> <body> <!-- My first Tapestry component. --> <!-- Note: We don't really need a component. --> Hello, <t:textoutput t:value="name"/>! </body> </html>
51. My First Tapestry Page (Java) public class Index { @Property private String name; }
52.
53.
54.
55. Take 2: TML <html xmlns:t="…"> <head><title>Hello, Tapestry!</title></head> <body> <!-- Does this seem familiar? --> Hello, <span t:id="nameOutput" >Foo</span>! </body> </html>
56. Take 2: Java public class Index { @Property private String name; @Component( parameters={"value=name"}) private TextOutput nameOutput; }
69. JSF Event Handling @ManagedBean @SessionScoped public class Counter { public int getCount() { return count; } public void increment() { count++; } private int count; }
76. Tapestry Event Handling public class Events { @Persist @Property private int count; // Called when any form is submitted void onSubmit() { count++; } }
77. Tapestry Event Handling // All of these work too! // Called when form 1 is submitted void onSubmitFromForm1() { count++ } // Called when any button is selected void onSelected() { count++; } // Called when button1 is selected void onSelectedFromButton1() { count++; }
78. Tapestry Event Handling // And these too @OnEvent(value="selected", component="button1") void increment() { count++ } @OnEvent(value="submit", component="form") void foo() { count++ }
124. Wicket Input Processing <!-- HTML --> <input type="text" wicket:id="firstName"/> // Java User user = getUser(); form.add(new TextField("firstName", new PropertyModel(user, "name")));
125.
126.
127. Wicket Validation <!-- HTML --> <input type="text" wicket:id="age"/> // Java add(new TextField("age", new PropertyModel(getUser(), "age")) .add(NumberValidator.minimum(18)));
128.
129.
130. Tapestry Input Processing <!-- TML --> <input type="text" t:type="textfield" t:value="user.name"/> // Java public class Input { @Property private User user; }
131.
132. Tapestry Conversion Events public class Input { String onToClientFromAge() { // Return String representation of age } Object onParseClientFromAge(String input) { // Return converted representation of age } }