Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Wicket Introduction

7.934 Aufrufe

Veröffentlicht am

An introduction about Wicket. Taken on June 30th 2008

Veröffentlicht in: Business, Technologie
  • Als Erste(r) kommentieren

Wicket Introduction

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