Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

24
Wicket in 60 Minutes Wicket in 60 Minutes Wicket 4 Newbs Wicket 4 Newbs

Transcript of Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Page 1: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wicket in 60 MinutesWicket in 60 MinutesWicket in 60 MinutesWicket in 60 Minutes

Wicket 4 NewbsWicket 4 Newbs

Page 2: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Even Voorstellen ...Even Voorstellen ...Even Voorstellen ...Even Voorstellen ...

Page 3: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

AgendaAgendaAgendaAgenda

Waarom Wicket?Waarom Wicket?

Basis Ingredienten Wicket ApplicatieBasis Ingredienten Wicket Applicatie

Demo: Hello World! met Maven en WicketDemo: Hello World! met Maven en Wicket

Demo: Wicked BookstoreDemo: Wicked Bookstore

Enkele Wicket ComponentenEnkele Wicket Componenten

Page 4: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Waarom Wicket?Waarom Wicket?

(Hadden nog niet genoeg web frameworks?)

Page 5: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Jawel ...Jawel ...Jawel ...Jawel ...

Echo Cocoon Maverick

Struts Turbine WebWork

GWT Tapestry Click

Smile Japple Spring MVC

SOFIA Jato TeaServlet

JFormular Stripes Melati

Expresso JPublish ...

Page 6: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Maar Wicket ...Maar Wicket ...Maar Wicket ...Maar Wicket ...

Is Component OrientedIs Component Oriented

Houd HTML en Java Strikt GescheidenHoud HTML en Java Strikt Gescheiden

Heeft Geen XML configuratie nodig!Heeft Geen XML configuratie nodig!

Page 7: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wicket is Component Wicket is Component OrientedOrientedWicket is Component Wicket is Component OrientedOriented

Composite PatternComposite Pattern

Page 8: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wicket is Component Wicket is Component OrientedOrientedWicket is Component Wicket is Component OrientedOriented

Voorbeeld: Form ComponentsVoorbeeld: Form Components

Page 9: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Java en HTML GescheidenJava en HTML GescheidenJava en HTML GescheidenJava en HTML Gescheiden

HTML mark-up:HTML mark-up:

<p wicket:id="quoteOfDay">famous quote here</p>

Java code:Java code:

String quoteNeilArmstrong=

”This is one small step for a man, “ + “one giant leap for mankind.";

add(new Label("quoteOfDay", quoteNeilArmstrong));

Page 10: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Geen XML Configuraties Geen XML Configuraties Meer!Meer!Geen XML Configuraties Geen XML Configuraties Meer!Meer!

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>

<!-- ========== Form Bean Definitions ============ --> <form-beans> <form-bean name="loginFormBean" type="test.struts.LoginForm" /> (...) </form-beans>

<!-- ========== Action Mapping Definitions ======== --> <action-mappings> <action path="/login" type="test.struts.LoginAction" >

<forward name="valid" path="/jsp/MainMenu.jsp" /> <forward name="invalid" path="/jsp/LoginView.jsp" /></action>

(...)

</action-mappings>

</struts-config>

Page 11: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wat gaat er in de soep?Wat gaat er in de soep?

Wicket Basis IngredientenWicket Basis Ingredienten

Page 12: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wicket Basis Wicket Basis IngredientenIngredientenWicket Basis Wicket Basis IngredientenIngredienten

Wicket dependency in pom.xml Wicket dependency in pom.xml

Wicket Servlet Filter in web.xml Wicket Servlet Filter in web.xml

WebApplication class WebApplication class

WebPage class WebPage class

HTML template ( + CSS ) HTML template ( + CSS )

Page 13: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Dependencies in pom.xmlDependencies in pom.xml

<dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket</artifactId> <version>${wicket.version}</version></dependency>

Wicket ‘core’ library:Wicket ‘core’ library:

<dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket-spring</artifactId> <version>${wicket.version}</version></dependency>

Wicket Spring integratie library:Wicket Spring integratie library:

Page 14: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Servlet Filter in web.xmlServlet Filter in web.xml

<filter> <filter-name>wicket.helloworld</filter-name> <filter-class> org.apache.wicket.protocol.http.WicketFilter </filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value> nl.iprofs.MyWicketApplication </param-value> </init-param></filter>

<filter-mapping> <filter-name>wicket.helloworld</filter-name> <url-pattern>/*</url-pattern></filter-mapping>

Page 15: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

WebApplication ClassWebApplication Class

package nl.iprofs;

import org.apache.wicket.protocol.http.WebApplication;

public class WicketApplication extends WebApplication {

public MyWicketApplication() {}

public Class getHomePage() { return HomePage.class; }

}

Page 16: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

WebPage ClassWebPage Class

package nl.iprofs;

import org.apache.wicket.PageParameters;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.WebPage;

public class HomePage extends WebPage {

public HomePage(final PageParameters parameters) {

String neilArmstrongQuote =

"This is one small step for a man, " + "one giant leap for mankind";

add( new Label("quoteOfDay", neilArmstrongQuote)); }

}

Page 17: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

HTML TemplateHTML Template

<html> <head> <title>Quote of the Day</title> </head> <body> <h1>Quote of the Day</h1>

<p wicket:id="quoteOfDay">famous quote here</p>

</body></html>

Page 18: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

DemoDemo

Hello Wicked WorldHello Wicked World

Page 19: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wicket ComponentenWicket Componenten

Page 20: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Wicket Component Wicket Component StructuurStructuurWicket Component Wicket Component StructuurStructuur

Form

FormComponent

1..*

Button

WebMarkupContainer

+ add ( :Component ):void

CheckBox TextArea TextField

Page 21: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Link ComponentLink Component

HTML mark-up:HTML mark-up:

<a href="#" wicket:id="homeLink">Home</a><br />

Java code:Java code:

Link homeLink = new BookmarkablePageLink("homeLink", HomePage.class);

Page 22: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

ListView ComponentListView Component

HTML mark-up:HTML mark-up:

<div wicket:id="categoryRow"> <a href="#" wicket:id="catLink"> <span wicket:id="catLabel">Boek A</span></a></div>

Java code:Java code:

add(new ListView("categoryRow", categorieen) {

@Override protected void populateItem(ListItem item) { Category category = (Category) item.getModelObject(); Link catLink = new BookmarkablePageLink( "catLink", HomePage.class); catLink.add(new Label("catLabel", category.getName()));

item.add(catLink); }});

Page 23: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

DemoDemo

WickedBookstoreWickedBookstore

Page 24: Wicket in 60 Minutes Wicket 4 Newbs. Even Voorstellen...

Vragen

... en antwoorden