SlideShare una empresa de Scribd logo
1 de 157
Component Framework Primer for JSF Users Andy Schwartz | Oracle Corporation
What? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why Wicket and Tapestry? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Who? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
JSF History ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Vision ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is a Page? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
Grunge: web.xml <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class> javax.faces.webapp.FacesServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping>
My First JSF Page <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:h=&quot;http://java.sun.com/jsf/html&quot;> <head><title>My First JSF Page</title></head> <body> <!-- Our first JSF component usage --> Hello, <h:outputText value=&quot;World&quot;/>! </body> </html>
JSF Rendering ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Happens After Rendering? ,[object Object],[object Object],[object Object],[object Object]
Bindings ,[object Object],[object Object],[object Object],[object Object]
A Simple Binding <h:outputText  value=&quot;#{sessionScope.user.firstName}&quot;/>
Implicit Objects ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Managed Beans ,[object Object],[object Object],[object Object],[object Object]
Managed Bean Registration <faces-config> <managed-bean> <managed-bean-name>user</managed-bean-name> <managed-bean-class>demo.User</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>
Managed Bean Registration @ManagedBean @SessionScoped public class User { public String getFirstName() { … } }
Managed Bean Reference <!-- Instead of this: --> <h:outputText value=&quot;#{sessionScope.user.firstName}&quot;/> <!-- We can now do this: --> <h:outputText value=&quot;#{user.firstName}&quot;/>
[object Object]
Wicket Quick History ,[object Object],[object Object],[object Object],[object Object],[object Object]
Wicket Vision ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is a Page? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
Grunge: web.xml <filter> <filter-name>wicket</filter-name> <filter-class> org.apache.wicket.protocol.http.WicketFilter </filter-class> <filter-mapping> <filter-name>wicket</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </filter>
Grunge: web.xml <init-param> <param-name> applicationClassName </param-name> <param-value> org.demo.wicket.HelloApplication </param-value> </init-param>
My First Wicket Application public class HelloApplication extends WebApplication { @Override public Class<Hello> getHomePage() { return Hello.class; } }
My First Wicket Page (HTML) <html xmlns:wicket=&quot;…&quot;> <head><title>Hello, Wicket!</title></head> <body> <!-- My first Wicket component (html) --> Hello, <span  wicket:id=&quot;name&quot; >Foo</span>! </body> </html>
My First Wicket Page (Java) public class Hello extends WebPage { public Hello() { // My first Wicket component (Java) add(new Label( &quot;name&quot; , &quot;World&quot;)); } }
Wicket Rendering ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Happens After Rendering? ,[object Object],[object Object],[object Object],[object Object]
What is a Wicket Model? ,[object Object],[object Object]
IModel Contract T getObject() void setObject(T object)
Components and Models ,[object Object],[object Object],[object Object]
Simple Model ,[object Object],[object Object],[object Object]
Simple Model Sample // This: add(new Label(&quot;name&quot;, &quot;World&quot;); // Is shorthand for: add(new Label(&quot;name&quot;, new Model(&quot;World&quot;)));
Static Model ,[object Object],// This is static: add(new Label(&quot;random&quot;,  new Model<Double>(Math.random()) ));
Dynamic Model ,[object Object],// This is dynamic: add(new Label(&quot;reallyRandom&quot;,  new Model<Double>() { public Double getObject() { return Math.random(); } }));
Some More Models ,[object Object],[object Object],[object Object],[object Object]
[object Object]
Tapestry Quick History ,[object Object],[object Object],[object Object],[object Object]
Tapestry Vision ,[object Object],[object Object],[object Object],[object Object],[object Object]
What is a Page? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
Grunge: web.xml <filter> <filter-name>tapestry</filter-name> <filter-class> org.apache.tapestry5.TapestryFilter </filter-class> </filter> <filter-mapping> <filter-name>tapestry</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Grunge: web.xml <context-param> <param-name> tapestry.app-package </param-name> <param-value> org.example.tapestry </param-value> </context-param>
My First Tapestry Page (TML) <html xmlns:t=&quot;…&quot;> <head><title>Hello, Tapestry!</title></head> <body> <!-- My first Tapestry component. --> <!-- Note: We don't really need a component. --> Hello,  <t:textoutput t:value=&quot;name&quot;/>! </body> </html>
My First Tapestry Page (Java) public class Index { @Property private String name; }
Tapestry Rendering ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Happens After Rendering? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
Take 2: TML <html xmlns:t=&quot;…&quot;> <head><title>Hello, Tapestry!</title></head> <body> <!-- Does this seem familiar? --> Hello,  <span  t:id=&quot;nameOutput&quot; >Foo</span>! </body> </html>
Take 2: Java public class Index { @Property private String name; @Component( parameters={&quot;value=name&quot;}) private TextOutput nameOutput; }
[object Object]
Take 3: TML <html xmlns:t=&quot;…&quot;> <head><title>Hello, Tapestry!</title></head> <body> Hello,   <span  t:type=&quot;textoutput&quot; t:value=&quot;name&quot;>Foo</span>! </body> </html>
Facelets Flashback <!-- Remember this? --> <span jsfc=&quot;h:outputText&quot;  value=&quot;#{name}&quot;>Foo</span>!
Tapestry Property Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Property Expressions <!-- Component parameter --> <div><t:textoutput t:value=&quot;user.name&quot;/></div> <!-- Template expansion --> <div>${user.name}</div>
Binding Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Binding Expressions <!-- Property Binding--> Hello, <t:textoutput t:value=&quot;name&quot;/>! <!-- Literal Binding--> Hello, <t:textoutput t:value=&quot;literal:World&quot;/>!
Some Initial Thoughts ,[object Object],[object Object],[object Object],[object Object],[object Object]
Some More Thoughts ,[object Object],[object Object],[object Object]
[object Object]
JSF Event Handling ,[object Object],[object Object],[object Object],[object Object]
JSF Event Handling <h:form> <h:commandButton value=&quot;Increment&quot; actionListener=&quot;#{counter.increment}&quot;/> <h:outputText value=&quot;#{counter.count}&quot;/> </h:form>
JSF Event Handling @ManagedBean @SessionScoped public class Counter { public int getCount() { return count; } public void increment() { count++; } private int count; }
Wicket Event Handling ,[object Object],[object Object]
Wicket Event Handling <form wicket:id=&quot;form&quot;> <input type=&quot;submit&quot; value=&quot;Increment&quot; wicket:id=&quot;button&quot;/> <span wicket:id=&quot;count&quot;>count</span> </form>
Wicket Event Handling public class EventsPage extends WebPage { public EventsPage() { Button button = new Button(&quot;button&quot;) { @Override public void onSubmit() { count++; } }; } private int count; }
Wicket Event Handling ,[object Object],[object Object],[object Object],[object Object]
Tapestry Event Handling ,[object Object],[object Object]
Tapestry Event Handling <t:form t:id=&quot;form1&quot;> <input type=&quot;submit&quot; value=&quot;Increment&quot; t:type=&quot;submit&quot; t:id=&quot;button1&quot;/> ${count} </t:form>
Tapestry Event Handling public class Events { @Persist @Property private int count; // Called when any form is submitted void onSubmit() { count++; } }
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++; }
Tapestry Event Handling // And these too @OnEvent(value=&quot;selected&quot;, component=&quot;button1&quot;) void increment() { count++ } @OnEvent(value=&quot;submit&quot;, component=&quot;form&quot;) void foo() { count++ }
Tapestry Event Handling ,[object Object],[object Object],[object Object]
Event Handling Wrap Up ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
JSF Ajax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Ajax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Ajax <f:ajax render=&quot;count&quot;/> <h:commandButton value=&quot;Increment&quot; actionListener=&quot;#{counter.increment}&quot;> <h:commandButton value=&quot;Reset&quot; actionListener=&quot;#{counter.reset}&quot;> </f:ajax>
JSF Ajax ,[object Object],[object Object],[object Object],[object Object],[object Object]
Wicket Ajax ,[object Object],[object Object]
Wicket Ajax AjaxButton button = new AjaxButton(&quot;button&quot;) { @Override public void onSubmit( AjaxRequestTarget target , Form form) { count++; if (target != null) { target.addComponent(label); } }});
Wicket Ajax label = new Label(&quot;count&quot;, …); label. setOutputMarkupId(true);
Wicket Ajax ,[object Object],[object Object],[object Object],[object Object]
Tapestry Ajax ,[object Object],[object Object]
Tapestry Ajax <t:form t:id=&quot;form1&quot;  zone=&quot;countZone&quot; > <input type=&quot;submit&quot; value=&quot;Increment&quot; t:type=&quot;submit&quot; t:id=&quot;button1&quot;/> <t:zone t:id=&quot;countZone&quot;> Hello, ${count} </t:zone> </t:form>
Tapestry Ajax public class Ajax { @InjectComponent private Zone countZone; Object onSubmitFromForm1() { return countZone.getBody(); } }
Tapestry Ajax ,[object Object],[object Object],[object Object]
Ajax Wrap Up ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
JSF Navigation ,[object Object],[object Object],[object Object],[object Object]
JSF Navigation <h:commandButton action=&quot;#{nav.goToPageB}&quot;/> @ManagedBean(name=&quot;nav&quot;) @RequestScoped public class Navigation { public String goToPageB() { return &quot;success&quot;; } }
JSF Navigation <navigation-rule> <from-view-id>/pageA.xhtml</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/pageB.xhtml</to-view-id> <redirect/> </navigation-case> </navigation-rule>
JSF Implicit Navigation ,[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Implicit Navigation <h:commandButton action=&quot;#{nav.goToPageB}&quot;/> @ManagedBean(name=&quot;nav&quot;) @RequestScoped public class Navigation { public String goToPageB() { // No faces-config entry required return &quot;pageB&quot; ; } }
JSF Pre-Emptive Navigation ,[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Pre-Emptive Navigation <!-- Use navigation rules to determine  &quot;success&quot; outcome target --> <h:button outcome=&quot;success&quot;/> <!-- Both pre-emptive and implicit.  No  faces-config needed.  -->  <h:button outcome=&quot;pageB&quot;/>
Wicket Navigation ,[object Object],[object Object]
Wicket Navigation Button button1 = new Button(&quot;button1&quot;) { public void onSubmit() { setResponsePage(PageB.class); } };
Wicket Navigation Button button1 = new Button(&quot;button1&quot;) { public void onSubmit() { PageB pageB = new PageB(); // Configure PageB instance… setResponsePage(pageB); } }; Wicket Navigation
Wicket Navigation ,[object Object],[object Object],[object Object]
Wicket Navigation <!-- HTML --> <a wicket:id=&quot;bookmarkable&quot; href=&quot;PageB.html&quot;>Navigate To Page B</a> // Java form.add( new BookmarkablePageLink(&quot;bookmarkable&quot;, PageB.class));
Wicket Navigation <!-- No Java code required. --> <wicket:link> <ul> <li><a href=&quot;PageA.html&quot;>Page A</a></li> <li><a href=&quot;PageB.html&quot;>Page B</a></li> <li><a href=&quot;PageC.html&quot;>Page C</a></li> <li><a href=&quot;PageD.html&quot;>Page D</a></li> </ul> </wicket:link>
Tapestry Navigation ,[object Object],[object Object],[object Object]
Tapestry Navigation public class PageA { Object onSubmitFromForm1() { return PageB.class; } }
Tapestry Navigation public class PageA { @InjectPage private PageB pageB; Object onSubmitFromForm1() { // Configure pageB instance... return pageB; } }
Tapestry Navigation ,[object Object],[object Object]
Tapestry Navigation <t:pagelink t:page=&quot;PageB&quot;>Go</t:pagelink>
Navigation Wrap Up ,[object Object],[object Object],[object Object],[object Object]
[object Object]
JSF Input Processing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Input Processing <h:inputText value=&quot;#{user.name}&quot;/> @ManagedBean public class User { public String getName() { return name; } public void setName(String name) { this.name = name; } private String name; }
JSF Conversion ,[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Conversion <h:inputText value=&quot;#{user.age}&quot;> <f:convertNumber integerOnly=&quot;true&quot;/> </h:inputText>
JSF Validation ,[object Object],[object Object],[object Object],[object Object],[object Object]
JSF Validation <h:inputText value=&quot;#{user.age}&quot;> <f:validateLongRange minimum=&quot;18&quot;/> </h:inputText>
More JSF Validation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Wicket Input Processing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Wicket Input Processing <!-- HTML --> <input type=&quot;text&quot; wicket:id=&quot;firstName&quot;/> // Java User user = getUser(); form.add(new TextField(&quot;firstName&quot;,  new PropertyModel(user, &quot;name&quot;)));
Wicket Conversion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Wicket Validation ,[object Object],[object Object]
Wicket Validation <!-- HTML --> <input type=&quot;text&quot; wicket:id=&quot;age&quot;/> // Java add(new TextField(&quot;age&quot;,  new PropertyModel(getUser(), &quot;age&quot;)) .add(NumberValidator.minimum(18)));
More Wicket Validation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tapestry Input Processing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tapestry Input Processing <!-- TML --> <input type=&quot;text&quot; t:type=&quot;textfield&quot; t:value=&quot;user.name&quot;/> // Java public class Input { @Property private User user; }
Tapestry Conversion ,[object Object],[object Object],[object Object],[object Object]
Tapestry Conversion Events public class Input { String onToClientFromAge() { // Return String representation of age } Object onParseClientFromAge(String input) { // Return converted representation of age } }
Tapestry Validation ,[object Object],[object Object],[object Object]
Parameter-Based Validation <input type=&quot;text&quot; t:type=&quot;textfield&quot; t:value=&quot;user.age&quot; t:validate=&quot;required,min=18&quot;/>
Event-Based Validation void onValidateFromAge(Integer value) throws ValidationException { if (value < 18)  throw new ValidationException(&quot;Too young!&quot;); }
Anntation-Based Validation public class Input { @Property @Validate(&quot;required,min=18&quot;) private int age; }
More Tapestry Validation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Input Processing Wrap Up ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
JSF: Old School (Java) ,[object Object],[object Object],[object Object],[object Object],[object Object]
JSF: New School (Java) ,[object Object],[object Object],[object Object]
JSF: New School (Composite) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
resources/demo/titleBorder.xhtml <html ... ><body> <composite:implementation> <div class=&quot;tb-root&quot;> <div class=&quot;tb-title&quot;> #{cc.attrs.title} </div> <div class=&quot;tb-body&quot;> <composite:insertChildren/> </div> </div> </composite:implementation> </body></html>
Composite Interface <composite:interface> <composite:attribute name=&quot;title&quot; required=&quot;true&quot;/> </composite:interface>
Component Usage <html … xmlns:demo= &quot;http://java.sun.com/jsf/composite/demo&quot;> <body> <demo:titleBorder title=&quot;My Favorite Greeting&quot;> Hello, World! </demo:titleBorder> </body> </html>
Wicket Custom Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TitleBorder.html <html ... ><body> <wicket:border> <div class=&quot;tb-root&quot;> <div class=&quot;tb-title&quot;  wicket:id=&quot;titleLabel&quot;>Title</div> <div class=&quot;tb-body&quot;> <wicket:body/> </div> </div> </wicket:border> </body></html>
TitleBorder.java public class TitleBorder extends Border { public TitleBorder(String id) { super(id); add(new Label(&quot;titleLabel&quot;,  new PropertyModel(this, &quot;title&quot;))); } // Accessors private String title; }
Component Usage <!-- HTML --> <div wicket:id=&quot;titleBorder&quot;> Hello, World! </div> // Java add(new TitleBorder(&quot;titleBorder&quot;));
Tapestry Custom Components ,[object Object],[object Object],[object Object],[object Object]
TitleBorder.tml <div class=&quot;tb-root&quot; ... > <div class=&quot;tb-title&quot;> ${title} </div> <div class=&quot;tb-body&quot;> <t:body/> </div> </div>
TitleBorder.java public class TitleBorder { @Property @Parameter(required=true, defaultPrefix=BindingConstants.LITERAL) private String title;  }
Component Usage <t:titleborder t:title=&quot;My Favorite Greeting&quot;> Hello, World! </t:titleborder>
Custom Component Wrap Up ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
So Much To Do, So Little Time ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component BehaviorsAndy Schwartz
 
9. java server faces
9. java server faces9. java server faces
9. java server facesAnusAhmad
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVCJohn Lewis
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
Sprint Portlet MVC Seminar
Sprint Portlet MVC SeminarSprint Portlet MVC Seminar
Sprint Portlet MVC SeminarJohn Lewis
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Arun Gupta
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSFSoftServe
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkGuo Albert
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and DeploymentBG Java EE Course
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0Michael Fons
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Courseguest764934
 

La actualidad más candente (20)

Jsf intro
Jsf introJsf intro
Jsf intro
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Struts N E W
Struts N E WStruts N E W
Struts N E W
 
Jsf
JsfJsf
Jsf
 
Introduction to jsf 2
Introduction to jsf 2Introduction to jsf 2
Introduction to jsf 2
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Sprint Portlet MVC Seminar
Sprint Portlet MVC SeminarSprint Portlet MVC Seminar
Sprint Portlet MVC Seminar
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
Ibm
IbmIbm
Ibm
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
 

Similar a Component Framework Primer for JSF Users

Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket IntroductionEyal Golan
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet Sagar Nakul
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet Sagar Nakul
 
Developing a Struts & Tiles application using WebSphere Studio
Developing a Struts & Tiles application using WebSphere StudioDeveloping a Struts & Tiles application using WebSphere Studio
Developing a Struts & Tiles application using WebSphere Studioelliando dias
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial BasicsLuca Garulli
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2wiradikusuma
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011Paul Rogers
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011Paul Rogers
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran TochAdil Jafri
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksSunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworksSunil Patil
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleFelix Meschberger
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleFelix Meschberger
 

Similar a Component Framework Primer for JSF Users (20)

Jsfsunum
JsfsunumJsfsunum
Jsfsunum
 
Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket Introduction
 
JavaServer Pages
JavaServer PagesJavaServer Pages
JavaServer Pages
 
Facelets
FaceletsFacelets
Facelets
 
Facelets
FaceletsFacelets
Facelets
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Developing a Struts & Tiles application using WebSphere Studio
Developing a Struts & Tiles application using WebSphere StudioDeveloping a Struts & Tiles application using WebSphere Studio
Developing a Struts & Tiles application using WebSphere Studio
 
dJango
dJangodJango
dJango
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial Basics
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Jsp
JspJsp
Jsp
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi Style
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi Style
 

Último

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Component Framework Primer for JSF Users

  • 1. Component Framework Primer for JSF Users Andy Schwartz | Oracle Corporation
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. Grunge: web.xml <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class> javax.faces.webapp.FacesServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping>
  • 13. My First JSF Page <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:h=&quot;http://java.sun.com/jsf/html&quot;> <head><title>My First JSF Page</title></head> <body> <!-- Our first JSF component usage --> Hello, <h:outputText value=&quot;World&quot;/>! </body> </html>
  • 14.
  • 15.
  • 16.
  • 17. A Simple Binding <h:outputText value=&quot;#{sessionScope.user.firstName}&quot;/>
  • 18.
  • 19.
  • 20. Managed Bean Registration <faces-config> <managed-bean> <managed-bean-name>user</managed-bean-name> <managed-bean-class>demo.User</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>
  • 21. Managed Bean Registration @ManagedBean @SessionScoped public class User { public String getFirstName() { … } }
  • 22. Managed Bean Reference <!-- Instead of this: --> <h:outputText value=&quot;#{sessionScope.user.firstName}&quot;/> <!-- We can now do this: --> <h:outputText value=&quot;#{user.firstName}&quot;/>
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. Grunge: web.xml <filter> <filter-name>wicket</filter-name> <filter-class> org.apache.wicket.protocol.http.WicketFilter </filter-class> <filter-mapping> <filter-name>wicket</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </filter>
  • 29. Grunge: web.xml <init-param> <param-name> applicationClassName </param-name> <param-value> org.demo.wicket.HelloApplication </param-value> </init-param>
  • 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=&quot;…&quot;> <head><title>Hello, Wicket!</title></head> <body> <!-- My first Wicket component (html) --> Hello, <span wicket:id=&quot;name&quot; >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( &quot;name&quot; , &quot;World&quot;)); } }
  • 33.
  • 34.
  • 35.
  • 36. IModel Contract T getObject() void setObject(T object)
  • 37.
  • 38.
  • 39. Simple Model Sample // This: add(new Label(&quot;name&quot;, &quot;World&quot;); // Is shorthand for: add(new Label(&quot;name&quot;, new Model(&quot;World&quot;)));
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48. Grunge: web.xml <filter> <filter-name>tapestry</filter-name> <filter-class> org.apache.tapestry5.TapestryFilter </filter-class> </filter> <filter-mapping> <filter-name>tapestry</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
  • 49. Grunge: web.xml <context-param> <param-name> tapestry.app-package </param-name> <param-value> org.example.tapestry </param-value> </context-param>
  • 50. My First Tapestry Page (TML) <html xmlns:t=&quot;…&quot;> <head><title>Hello, Tapestry!</title></head> <body> <!-- My first Tapestry component. --> <!-- Note: We don't really need a component. --> Hello, <t:textoutput t:value=&quot;name&quot;/>! </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=&quot;…&quot;> <head><title>Hello, Tapestry!</title></head> <body> <!-- Does this seem familiar? --> Hello, <span t:id=&quot;nameOutput&quot; >Foo</span>! </body> </html>
  • 56. Take 2: Java public class Index { @Property private String name; @Component( parameters={&quot;value=name&quot;}) private TextOutput nameOutput; }
  • 57.
  • 58. Take 3: TML <html xmlns:t=&quot;…&quot;> <head><title>Hello, Tapestry!</title></head> <body> Hello, <span t:type=&quot;textoutput&quot; t:value=&quot;name&quot;>Foo</span>! </body> </html>
  • 59. Facelets Flashback <!-- Remember this? --> <span jsfc=&quot;h:outputText&quot; value=&quot;#{name}&quot;>Foo</span>!
  • 60.
  • 61. Property Expressions <!-- Component parameter --> <div><t:textoutput t:value=&quot;user.name&quot;/></div> <!-- Template expansion --> <div>${user.name}</div>
  • 62.
  • 63. Binding Expressions <!-- Property Binding--> Hello, <t:textoutput t:value=&quot;name&quot;/>! <!-- Literal Binding--> Hello, <t:textoutput t:value=&quot;literal:World&quot;/>!
  • 64.
  • 65.
  • 66.
  • 67.
  • 68. JSF Event Handling <h:form> <h:commandButton value=&quot;Increment&quot; actionListener=&quot;#{counter.increment}&quot;/> <h:outputText value=&quot;#{counter.count}&quot;/> </h:form>
  • 69. JSF Event Handling @ManagedBean @SessionScoped public class Counter { public int getCount() { return count; } public void increment() { count++; } private int count; }
  • 70.
  • 71. Wicket Event Handling <form wicket:id=&quot;form&quot;> <input type=&quot;submit&quot; value=&quot;Increment&quot; wicket:id=&quot;button&quot;/> <span wicket:id=&quot;count&quot;>count</span> </form>
  • 72. Wicket Event Handling public class EventsPage extends WebPage { public EventsPage() { Button button = new Button(&quot;button&quot;) { @Override public void onSubmit() { count++; } }; } private int count; }
  • 73.
  • 74.
  • 75. Tapestry Event Handling <t:form t:id=&quot;form1&quot;> <input type=&quot;submit&quot; value=&quot;Increment&quot; t:type=&quot;submit&quot; t:id=&quot;button1&quot;/> ${count} </t:form>
  • 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=&quot;selected&quot;, component=&quot;button1&quot;) void increment() { count++ } @OnEvent(value=&quot;submit&quot;, component=&quot;form&quot;) void foo() { count++ }
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84. JSF Ajax <f:ajax render=&quot;count&quot;/> <h:commandButton value=&quot;Increment&quot; actionListener=&quot;#{counter.increment}&quot;> <h:commandButton value=&quot;Reset&quot; actionListener=&quot;#{counter.reset}&quot;> </f:ajax>
  • 85.
  • 86.
  • 87. Wicket Ajax AjaxButton button = new AjaxButton(&quot;button&quot;) { @Override public void onSubmit( AjaxRequestTarget target , Form form) { count++; if (target != null) { target.addComponent(label); } }});
  • 88. Wicket Ajax label = new Label(&quot;count&quot;, …); label. setOutputMarkupId(true);
  • 89.
  • 90.
  • 91. Tapestry Ajax <t:form t:id=&quot;form1&quot; zone=&quot;countZone&quot; > <input type=&quot;submit&quot; value=&quot;Increment&quot; t:type=&quot;submit&quot; t:id=&quot;button1&quot;/> <t:zone t:id=&quot;countZone&quot;> Hello, ${count} </t:zone> </t:form>
  • 92. Tapestry Ajax public class Ajax { @InjectComponent private Zone countZone; Object onSubmitFromForm1() { return countZone.getBody(); } }
  • 93.
  • 94.
  • 95.
  • 96.
  • 97. JSF Navigation <h:commandButton action=&quot;#{nav.goToPageB}&quot;/> @ManagedBean(name=&quot;nav&quot;) @RequestScoped public class Navigation { public String goToPageB() { return &quot;success&quot;; } }
  • 98. JSF Navigation <navigation-rule> <from-view-id>/pageA.xhtml</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/pageB.xhtml</to-view-id> <redirect/> </navigation-case> </navigation-rule>
  • 99.
  • 100. JSF Implicit Navigation <h:commandButton action=&quot;#{nav.goToPageB}&quot;/> @ManagedBean(name=&quot;nav&quot;) @RequestScoped public class Navigation { public String goToPageB() { // No faces-config entry required return &quot;pageB&quot; ; } }
  • 101.
  • 102. JSF Pre-Emptive Navigation <!-- Use navigation rules to determine &quot;success&quot; outcome target --> <h:button outcome=&quot;success&quot;/> <!-- Both pre-emptive and implicit. No faces-config needed. --> <h:button outcome=&quot;pageB&quot;/>
  • 103.
  • 104. Wicket Navigation Button button1 = new Button(&quot;button1&quot;) { public void onSubmit() { setResponsePage(PageB.class); } };
  • 105. Wicket Navigation Button button1 = new Button(&quot;button1&quot;) { public void onSubmit() { PageB pageB = new PageB(); // Configure PageB instance… setResponsePage(pageB); } }; Wicket Navigation
  • 106.
  • 107. Wicket Navigation <!-- HTML --> <a wicket:id=&quot;bookmarkable&quot; href=&quot;PageB.html&quot;>Navigate To Page B</a> // Java form.add( new BookmarkablePageLink(&quot;bookmarkable&quot;, PageB.class));
  • 108. Wicket Navigation <!-- No Java code required. --> <wicket:link> <ul> <li><a href=&quot;PageA.html&quot;>Page A</a></li> <li><a href=&quot;PageB.html&quot;>Page B</a></li> <li><a href=&quot;PageC.html&quot;>Page C</a></li> <li><a href=&quot;PageD.html&quot;>Page D</a></li> </ul> </wicket:link>
  • 109.
  • 110. Tapestry Navigation public class PageA { Object onSubmitFromForm1() { return PageB.class; } }
  • 111. Tapestry Navigation public class PageA { @InjectPage private PageB pageB; Object onSubmitFromForm1() { // Configure pageB instance... return pageB; } }
  • 112.
  • 113. Tapestry Navigation <t:pagelink t:page=&quot;PageB&quot;>Go</t:pagelink>
  • 114.
  • 115.
  • 116.
  • 117. JSF Input Processing <h:inputText value=&quot;#{user.name}&quot;/> @ManagedBean public class User { public String getName() { return name; } public void setName(String name) { this.name = name; } private String name; }
  • 118.
  • 119. JSF Conversion <h:inputText value=&quot;#{user.age}&quot;> <f:convertNumber integerOnly=&quot;true&quot;/> </h:inputText>
  • 120.
  • 121. JSF Validation <h:inputText value=&quot;#{user.age}&quot;> <f:validateLongRange minimum=&quot;18&quot;/> </h:inputText>
  • 122.
  • 123.
  • 124. Wicket Input Processing <!-- HTML --> <input type=&quot;text&quot; wicket:id=&quot;firstName&quot;/> // Java User user = getUser(); form.add(new TextField(&quot;firstName&quot;, new PropertyModel(user, &quot;name&quot;)));
  • 125.
  • 126.
  • 127. Wicket Validation <!-- HTML --> <input type=&quot;text&quot; wicket:id=&quot;age&quot;/> // Java add(new TextField(&quot;age&quot;, new PropertyModel(getUser(), &quot;age&quot;)) .add(NumberValidator.minimum(18)));
  • 128.
  • 129.
  • 130. Tapestry Input Processing <!-- TML --> <input type=&quot;text&quot; t:type=&quot;textfield&quot; t:value=&quot;user.name&quot;/> // 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 } }
  • 133.
  • 134. Parameter-Based Validation <input type=&quot;text&quot; t:type=&quot;textfield&quot; t:value=&quot;user.age&quot; t:validate=&quot;required,min=18&quot;/>
  • 135. Event-Based Validation void onValidateFromAge(Integer value) throws ValidationException { if (value < 18) throw new ValidationException(&quot;Too young!&quot;); }
  • 136. Anntation-Based Validation public class Input { @Property @Validate(&quot;required,min=18&quot;) private int age; }
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143. resources/demo/titleBorder.xhtml <html ... ><body> <composite:implementation> <div class=&quot;tb-root&quot;> <div class=&quot;tb-title&quot;> #{cc.attrs.title} </div> <div class=&quot;tb-body&quot;> <composite:insertChildren/> </div> </div> </composite:implementation> </body></html>
  • 144. Composite Interface <composite:interface> <composite:attribute name=&quot;title&quot; required=&quot;true&quot;/> </composite:interface>
  • 145. Component Usage <html … xmlns:demo= &quot;http://java.sun.com/jsf/composite/demo&quot;> <body> <demo:titleBorder title=&quot;My Favorite Greeting&quot;> Hello, World! </demo:titleBorder> </body> </html>
  • 146.
  • 147. TitleBorder.html <html ... ><body> <wicket:border> <div class=&quot;tb-root&quot;> <div class=&quot;tb-title&quot; wicket:id=&quot;titleLabel&quot;>Title</div> <div class=&quot;tb-body&quot;> <wicket:body/> </div> </div> </wicket:border> </body></html>
  • 148. TitleBorder.java public class TitleBorder extends Border { public TitleBorder(String id) { super(id); add(new Label(&quot;titleLabel&quot;, new PropertyModel(this, &quot;title&quot;))); } // Accessors private String title; }
  • 149. Component Usage <!-- HTML --> <div wicket:id=&quot;titleBorder&quot;> Hello, World! </div> // Java add(new TitleBorder(&quot;titleBorder&quot;));
  • 150.
  • 151. TitleBorder.tml <div class=&quot;tb-root&quot; ... > <div class=&quot;tb-title&quot;> ${title} </div> <div class=&quot;tb-body&quot;> <t:body/> </div> </div>
  • 152. TitleBorder.java public class TitleBorder { @Property @Parameter(required=true, defaultPrefix=BindingConstants.LITERAL) private String title; }
  • 153. Component Usage <t:titleborder t:title=&quot;My Favorite Greeting&quot;> Hello, World! </t:titleborder>
  • 154.
  • 155.
  • 156.
  • 157.