KEMBAR78
Wicket Introduction | PPT
Cost Benefit  Open Source Solutions By Eyal Golan – Senior Java Consultant @ Tikal Knowledge Introduction to
“ Apache Wicket  is a  component oriented  Java web application framework. With proper  mark-up/logic separation , a  POJO data model , and a refreshing  lack of XML , Apache Wicket makes developing web-apps simple and enjoyable again. Swap the boilerplate, complex debugging and brittle code for powerful, reusable components written with plain Java and HTML.*” *The Wicket Team
Introduction to Wicket - Agenda What is Wicket? Wicket in a Nutshell Stateful, Just Java, Just HTML Wicket Architecture The component concept Getting Wicket Wicket’s Features Wicket on the web Q&A
Wicket in a Nutshell “ A Java software framework to enable component oriented, programmatic manipulation of markup.” (WIA) Manipulation of markup  – Use Wicket to manipulate the markup tags and their contents. (<span>[content]</span>) Programmatic manipulation  – Wicket forces a strict separation of presentation and logic. Java is used to derive the dynamic parts of the markup templates. Component Oriented  – The application is constructed of reusable components. The components have their own states and behaviors. It is very similar to programming with Swing / SWT.
Wicket is stateful Wicket is a stateful framework. Wicket was developed to solve the problems that REST introduced to web applications development Security, modularization, state maintenance and everything as Strings  No need to decide how to pass state Wicket manages state transparently Wicket hides the fact that you work on a stateless protocol Feels like regular Java programming The state of components is managed for you. public class EditBarLink extends Link { private final Person person; public EditBarLink(String id, Person person) { super(id); this.person = person; } public void onClick() { setResponsePage(new EditPersonPage( person )); } }
Just Java You decide how components are created, assembled and combined and - to some extend – what their life cycle looks like The developer is in charge of how the components are created Constructor, inheritance etc. Component classes can be designed in any way Class members, hierarchy etc.
Just HTML Just HTML Presentation is defined in HTML markups HTML templates you use with Wicket only contain static presentation code (markup) and placeholders where Java components are hooked in There is never logic in the templates You pretty much have  to know  the structure of your  page * upfront * Or any other component that has a corresponding markup (Page, Panel, Border and Fragment).  This will be explained later * The pieces can be put together dynamically <tr> <td wicket:id=”list”> <span wicket:id=”name” /> </td> </tr> Dynamic Table
Introduction to Wicket - Agenda What is Wicket? Wicket Architecture / behind the scene A brief explanation The component concept Getting Wicket Wicket’s Features Wicket on the web Q&A
Wicket Architecture In this section we will go over the  main role players  of a Wicket application This is only a brief introduction The section is intended only to be familiarized with the primary classes that create a Wicket application Application One object instance for an application Bundles all components, markups, properties, settings files etc. Acts as the central hub of processing The Application object is used for customize the application’s behavior Session Holds the state of one user Wicket allows to have custom session With a custom session we know exactly what can be store in a session
Wicket Architecture (cont.) RequestCycle Responsible of processing requests Uses  Request  and  Response  objects Some examples of Application Customization A SecuredSession that allows only logged in user to open a certain page How to render a disabled link How to mount pages with a nice readable URL Component Page, Form, Label, TextField, DropDown, WebMarkupContainer and much more Model The Model is an indirection for how to get the data that drives the Java components. Models hide ‘what’ data to get and ‘from where’ to get it, and Java components hide ‘when’ and ‘how’ that data is  displayed
Introduction to Wicket - Agenda What is Wicket? Wicket Architecture The component concept Hello World… The shortest example ever! Component – The building block A few examples Getting Wicket Wicket’s Features Wicket on the web Q&A
Hello World – The Short Example add(new Label(&quot; message &quot;, &quot;Hello World!&quot;)); Put it in your Java
Hello World – The Short Example <h1 wicket:id=“ message ”>[text goes here]</h1> add(new Label(&quot; message &quot;, &quot;Hello World!&quot;)); + Add it to your HTML Put it in your Java
Hello World – The Short Example <h1 wicket:id=“ message ”>[text goes here]</h1> add(new Label(&quot; message &quot;, &quot;Hello World!&quot;)); <h1>Hello World!</h1> + = Add it to your HTML Put it in your Java Et Voila
What about picking a date? DateTextField dateTxt =  new  DateTextField(&quot;dateTxt&quot;); dateTxt.add( new  DatePicker()); add(dateTxt); <input wicket:id=“dateTxt”></input> You can manipulate the header by adding calls to CSS and JS files.
Introduction to Wicket - Agenda What is Wicket? Wicket Architecture The component concept Hello World… The shortest example ever! Component – The building block Getting Wicket Wicket’s Features Wicket on the web Q&A
About Components “ Apache Wicket  is a component oriented …” Components are the building blocks of Wicket They are self contained and do not leak scope Other components don’t have to know about it They are reusable You build them using plain Java You  use  them using plain Java Components can be nested to “components tree” Each component that is added in the Java file must be added in the same hierarchy in the corresponding HTML file Pages  are special components that function as the root for such trees The components are the objects that encapsulate the manipulation the markup Their data is separated using the IModel interface
Components Tree Hierarchy
Component + Markup Component has wicket id Markup has the same wicket:id Hierarchy must much HTML Code Java Code Link link = new Link(“ link ”) {…} add(link); link .add(new Label(&quot; message &quot;, “My Message&quot;)); <a href=”#” wicket:id=“ link ”> <span wicket:id=“ message ”>[text replaced]</span> </a>
Component + Markup Some components have a markup file associated with them and others don’t Components with an associated markup Page, Panel, Border, Fragment Both files should reside in the same package folder*, and should have the same name src/com/tikal/presentation/HelloWorldPage.java src/com/tikal/presentation/HelloWorldPage.html *And naturally Wicket allows to configure this behavior Some components without an associated markup The markup for this components are located in their parent XXX.html Label, Button, DropDown, Link, Form and more
Component – Link Example Link link = new Link(&quot; link &quot;) { … @Override public void onClick() { setResponsePage(OrdersReportsPage.class); } }); <a href=”#” wicket:id=“ link ”>Click</a> HTML Code Java Code
Component – AjaxLink Example someComponent.setOutputMarkupId(true); AjaxLink link = new AjaxLink(&quot; link &quot;) {  private static final long  serialVersionUID  = 1L; @Override public void onClick(AjaxRequestTarget target) {  //  Do Something target.addComponent(someComponent); target.appendJavaScript(“Effects.fade(‘foo’)”); } }); <a href=”#” wicket:id=“ link ”>Click</a> The same as regular Link Some Ajax stuff in Java
Just Java + Just HTML (returned) The designer creates the page  with his favorite designing tool The Wicket programmer adds wicket:id as a hook in the file Minor issue – If the HTML hierarchy changes, it should be changed in the Java code as well
Introduction to Wicket - Agenda What is Wicket? Wicket Architecture The component concept Getting Wicket (So easy…) Starting point for Wicket Wicket’s Features Wicket on the web Q&A
A great quick start in Wicket’s site http://wicket.apache.org/quickstart.html Create a maven archetype to work with Run mvn jetty:run Use the Start.java class that is created automatically Create a war file and put in a web server (or an application server) A quick start project that builds your own Wicket project http://www.antwerkz.com/qwicket/app/home A bit tricky to start with it Wiki getting started http:// cwiki.apache.org/WICKET/newuserguide.html Getting Wicket
Introduction to Wicket - Agenda What is Wicket? Wicket Architecture The component concept Getting Wicket Wicket’s Features A list of (most) features Wicket on the web Q&A
Wicket’s Features – The Short List Automatic State (no HttpSession) POJO for logic Reusability No XML, no configuration files Like Swing Simplicity Active community
Wicket’s Features – The Long List Clean / clear separation of presentation and logic POJO for logic No XML, no configuration files Security i18n Built-in Ajax without the need to write JavaScript Transparent state and session management Stateful Navigation history, support of multiple tabs/windows in the browser Markup inheritance (OOD) Has validation Integrating with other frameworks (Spring, Hibernate) Has Lazy Loading facilities Active community
Introduction to Wicket - Agenda What is Wicket? Wicket Architecture The component concept Getting Wicket Wicket’s Features Wicket on the web Some useful links Q&A
Wicket on the Web Home of Wicket http://wicket.apache.org/index.html Wicket-extension (expansion of Wicket) http://wicket.apache.org/docs/wicket-1.3.2/wicket-extensions/index.html Wicket Forums http://www.nabble.com/Apache-Wicket-f13974.html Wicketstuff (cool libraries for Wicket) http://wicketstuff.org/confluence/display/STUFFWEB/Home http://wicketstuff.org/wicket13/  (examples) InMethod (Wicket table component) http://inmethod.com/ Wicket Blogs http://www.google.com/ig/add?feedurl=http%3A%2F%2Fpipes.yahoo.com%2Fpipes%2Fpipe.run%3F_id%3Dff2c46188493fc387b9b29d93ff77078%26_render%3Drss Wicket W. Warrick http:// en.wikipedia.org/wiki/Wicket_W._Warrick
Wicket on the Books Wicket In Action Martijn Dashorst, Eelco Hillenius http://wicketinaction.com/ http://manning.com/dashorst/ Pro Wicket Karthik Gurumurthy http://www.apress.com/book/view/1590597222 Enjoying Web Development with Wicket Kent Tong http://www.agileskills2.org/EWDW/
 
Summary Wicket is cool and fun Wicket gives an easy and fast Web Application development Has a very clear OOD approach Lets the user concentrate on the business logic The community is very dynamic and helpful Wicket is a dynamic framework that is built upon users’ request and suggestion Last Stable version 1.3.4 Wicket 1.4-M3 is the next version to go out
Q&A
Thank You [email_address] [email_address]

Wicket Introduction

  • 1.
    Cost Benefit Open Source Solutions By Eyal Golan – Senior Java Consultant @ Tikal Knowledge Introduction to
  • 2.
    “ Apache Wicket is a component oriented Java web application framework. With proper mark-up/logic separation , a POJO data model , and a refreshing lack of XML , Apache Wicket makes developing web-apps simple and enjoyable again. Swap the boilerplate, complex debugging and brittle code for powerful, reusable components written with plain Java and HTML.*” *The Wicket Team
  • 3.
    Introduction to Wicket- Agenda What is Wicket? Wicket in a Nutshell Stateful, Just Java, Just HTML Wicket Architecture The component concept Getting Wicket Wicket’s Features Wicket on the web Q&A
  • 4.
    Wicket in aNutshell “ A Java software framework to enable component oriented, programmatic manipulation of markup.” (WIA) Manipulation of markup – Use Wicket to manipulate the markup tags and their contents. (<span>[content]</span>) Programmatic manipulation – Wicket forces a strict separation of presentation and logic. Java is used to derive the dynamic parts of the markup templates. Component Oriented – The application is constructed of reusable components. The components have their own states and behaviors. It is very similar to programming with Swing / SWT.
  • 5.
    Wicket is statefulWicket is a stateful framework. Wicket was developed to solve the problems that REST introduced to web applications development Security, modularization, state maintenance and everything as Strings No need to decide how to pass state Wicket manages state transparently Wicket hides the fact that you work on a stateless protocol Feels like regular Java programming The state of components is managed for you. public class EditBarLink extends Link { private final Person person; public EditBarLink(String id, Person person) { super(id); this.person = person; } public void onClick() { setResponsePage(new EditPersonPage( person )); } }
  • 6.
    Just Java Youdecide how components are created, assembled and combined and - to some extend – what their life cycle looks like The developer is in charge of how the components are created Constructor, inheritance etc. Component classes can be designed in any way Class members, hierarchy etc.
  • 7.
    Just HTML JustHTML Presentation is defined in HTML markups HTML templates you use with Wicket only contain static presentation code (markup) and placeholders where Java components are hooked in There is never logic in the templates You pretty much have to know the structure of your page * upfront * Or any other component that has a corresponding markup (Page, Panel, Border and Fragment). This will be explained later * The pieces can be put together dynamically <tr> <td wicket:id=”list”> <span wicket:id=”name” /> </td> </tr> Dynamic Table
  • 8.
    Introduction to Wicket- Agenda What is Wicket? Wicket Architecture / behind the scene A brief explanation The component concept Getting Wicket Wicket’s Features Wicket on the web Q&A
  • 9.
    Wicket Architecture Inthis section we will go over the main role players of a Wicket application This is only a brief introduction The section is intended only to be familiarized with the primary classes that create a Wicket application Application One object instance for an application Bundles all components, markups, properties, settings files etc. Acts as the central hub of processing The Application object is used for customize the application’s behavior Session Holds the state of one user Wicket allows to have custom session With a custom session we know exactly what can be store in a session
  • 10.
    Wicket Architecture (cont.)RequestCycle Responsible of processing requests Uses Request and Response objects Some examples of Application Customization A SecuredSession that allows only logged in user to open a certain page How to render a disabled link How to mount pages with a nice readable URL Component Page, Form, Label, TextField, DropDown, WebMarkupContainer and much more Model The Model is an indirection for how to get the data that drives the Java components. Models hide ‘what’ data to get and ‘from where’ to get it, and Java components hide ‘when’ and ‘how’ that data is displayed
  • 11.
    Introduction to Wicket- Agenda What is Wicket? Wicket Architecture The component concept Hello World… The shortest example ever! Component – The building block A few examples Getting Wicket Wicket’s Features Wicket on the web Q&A
  • 12.
    Hello World –The Short Example add(new Label(&quot; message &quot;, &quot;Hello World!&quot;)); Put it in your Java
  • 13.
    Hello World –The Short Example <h1 wicket:id=“ message ”>[text goes here]</h1> add(new Label(&quot; message &quot;, &quot;Hello World!&quot;)); + Add it to your HTML Put it in your Java
  • 14.
    Hello World –The Short Example <h1 wicket:id=“ message ”>[text goes here]</h1> add(new Label(&quot; message &quot;, &quot;Hello World!&quot;)); <h1>Hello World!</h1> + = Add it to your HTML Put it in your Java Et Voila
  • 15.
    What about pickinga date? DateTextField dateTxt = new DateTextField(&quot;dateTxt&quot;); dateTxt.add( new DatePicker()); add(dateTxt); <input wicket:id=“dateTxt”></input> You can manipulate the header by adding calls to CSS and JS files.
  • 16.
    Introduction to Wicket- Agenda What is Wicket? Wicket Architecture The component concept Hello World… The shortest example ever! Component – The building block Getting Wicket Wicket’s Features Wicket on the web Q&A
  • 17.
    About Components “Apache Wicket is a component oriented …” Components are the building blocks of Wicket They are self contained and do not leak scope Other components don’t have to know about it They are reusable You build them using plain Java You use them using plain Java Components can be nested to “components tree” Each component that is added in the Java file must be added in the same hierarchy in the corresponding HTML file Pages are special components that function as the root for such trees The components are the objects that encapsulate the manipulation the markup Their data is separated using the IModel interface
  • 18.
  • 19.
    Component + MarkupComponent has wicket id Markup has the same wicket:id Hierarchy must much HTML Code Java Code Link link = new Link(“ link ”) {…} add(link); link .add(new Label(&quot; message &quot;, “My Message&quot;)); <a href=”#” wicket:id=“ link ”> <span wicket:id=“ message ”>[text replaced]</span> </a>
  • 20.
    Component + MarkupSome components have a markup file associated with them and others don’t Components with an associated markup Page, Panel, Border, Fragment Both files should reside in the same package folder*, and should have the same name src/com/tikal/presentation/HelloWorldPage.java src/com/tikal/presentation/HelloWorldPage.html *And naturally Wicket allows to configure this behavior Some components without an associated markup The markup for this components are located in their parent XXX.html Label, Button, DropDown, Link, Form and more
  • 21.
    Component – LinkExample Link link = new Link(&quot; link &quot;) { … @Override public void onClick() { setResponsePage(OrdersReportsPage.class); } }); <a href=”#” wicket:id=“ link ”>Click</a> HTML Code Java Code
  • 22.
    Component – AjaxLinkExample someComponent.setOutputMarkupId(true); AjaxLink link = new AjaxLink(&quot; link &quot;) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { // Do Something target.addComponent(someComponent); target.appendJavaScript(“Effects.fade(‘foo’)”); } }); <a href=”#” wicket:id=“ link ”>Click</a> The same as regular Link Some Ajax stuff in Java
  • 23.
    Just Java +Just HTML (returned) The designer creates the page with his favorite designing tool The Wicket programmer adds wicket:id as a hook in the file Minor issue – If the HTML hierarchy changes, it should be changed in the Java code as well
  • 24.
    Introduction to Wicket- Agenda What is Wicket? Wicket Architecture The component concept Getting Wicket (So easy…) Starting point for Wicket Wicket’s Features Wicket on the web Q&A
  • 25.
    A great quickstart in Wicket’s site http://wicket.apache.org/quickstart.html Create a maven archetype to work with Run mvn jetty:run Use the Start.java class that is created automatically Create a war file and put in a web server (or an application server) A quick start project that builds your own Wicket project http://www.antwerkz.com/qwicket/app/home A bit tricky to start with it Wiki getting started http:// cwiki.apache.org/WICKET/newuserguide.html Getting Wicket
  • 26.
    Introduction to Wicket- Agenda What is Wicket? Wicket Architecture The component concept Getting Wicket Wicket’s Features A list of (most) features Wicket on the web Q&A
  • 27.
    Wicket’s Features –The Short List Automatic State (no HttpSession) POJO for logic Reusability No XML, no configuration files Like Swing Simplicity Active community
  • 28.
    Wicket’s Features –The Long List Clean / clear separation of presentation and logic POJO for logic No XML, no configuration files Security i18n Built-in Ajax without the need to write JavaScript Transparent state and session management Stateful Navigation history, support of multiple tabs/windows in the browser Markup inheritance (OOD) Has validation Integrating with other frameworks (Spring, Hibernate) Has Lazy Loading facilities Active community
  • 29.
    Introduction to Wicket- Agenda What is Wicket? Wicket Architecture The component concept Getting Wicket Wicket’s Features Wicket on the web Some useful links Q&A
  • 30.
    Wicket on theWeb Home of Wicket http://wicket.apache.org/index.html Wicket-extension (expansion of Wicket) http://wicket.apache.org/docs/wicket-1.3.2/wicket-extensions/index.html Wicket Forums http://www.nabble.com/Apache-Wicket-f13974.html Wicketstuff (cool libraries for Wicket) http://wicketstuff.org/confluence/display/STUFFWEB/Home http://wicketstuff.org/wicket13/ (examples) InMethod (Wicket table component) http://inmethod.com/ Wicket Blogs http://www.google.com/ig/add?feedurl=http%3A%2F%2Fpipes.yahoo.com%2Fpipes%2Fpipe.run%3F_id%3Dff2c46188493fc387b9b29d93ff77078%26_render%3Drss Wicket W. Warrick http:// en.wikipedia.org/wiki/Wicket_W._Warrick
  • 31.
    Wicket on theBooks Wicket In Action Martijn Dashorst, Eelco Hillenius http://wicketinaction.com/ http://manning.com/dashorst/ Pro Wicket Karthik Gurumurthy http://www.apress.com/book/view/1590597222 Enjoying Web Development with Wicket Kent Tong http://www.agileskills2.org/EWDW/
  • 32.
  • 33.
    Summary Wicket iscool and fun Wicket gives an easy and fast Web Application development Has a very clear OOD approach Lets the user concentrate on the business logic The community is very dynamic and helpful Wicket is a dynamic framework that is built upon users’ request and suggestion Last Stable version 1.3.4 Wicket 1.4-M3 is the next version to go out
  • 34.
  • 35.