Title of your PowerPoint presentation

Download Report

Transcript Title of your PowerPoint presentation

Wicket in 60 Minutes
Wicket 4 Newbs
Even Voorstellen ...
Agenda
Waarom Wicket?
Basis Ingredienten Wicket Applicatie
Demo: Hello World! met Maven en Wicket
Enkele Wicket Componenten
Demo: Wicked Bookstore
Waarom Wicket?
(Hadden nog niet genoeg web frameworks?)
Jawel ...
Echo
Cocoon
Maverick
Struts
GWT
Smile
SOFIA
JFormular
Expresso
Turbine
Tapestry
Japple
Jato
Stripes
JPublish
WebWork
Click
Spring MVC
TeaServlet
Melati
...
Maar Wicket ...
Is Component Oriented
Houd HTML en Java Strikt Gescheiden
Heeft Geen XML configuratie nodig!
Wicket is Component Oriented
Composite Pattern
Wicket is Component Oriented
Voorbeeld: Form Components
Java en HTML Gescheiden
HTML mark-up:
<p wicket:id="quoteOfDay">famous quote here</p>
Java code:
String quoteNeilArmstrong=
”This is one small step for a man, “ +
“one giant leap for mankind.";
add(new Label("quoteOfDay", quoteNeilArmstrong));
Geen XML Configuraties 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>
Wat gaat er in de soep?
Wicket Basis Ingredienten
Wicket Basis Ingredienten
 Wicket dependency in
pom.xml
 Wicket Servlet Filter in web.xml
 WebApplication class
 WebPage class
 HTML template ( + CSS )
Dependencies in pom.xml
Wicket ‘core’ library:
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket</artifactId>
<version>${wicket.version}</version>
</dependency>
Wicket Spring integratie
library:
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-spring</artifactId>
<version>${wicket.version}</version>
</dependency>
Servlet 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>
WebApplication Class
package nl.iprofs;
import org.apache.wicket.protocol.http.WebApplication;
public class WicketApplication extends WebApplication {
public MyWicketApplication() {}
public Class getHomePage() {
return HomePage.class;
}
}
WebPage 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));
}
}
HTML 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>
Demo
Hello Wicked World
Wicket Componenten
Wicket Component Structuur
Link Component
HTML mark-up:
<a href="#" wicket:id="homeLink">Home</a><br />
Java code:
Link homeLink =
new BookmarkablePageLink("homeLink", HomePage.class);
ListView Component
HTML mark-up:
<div wicket:id="categoryRow">
<a href="#" wicket:id="catLink">
<span wicket:id="catLabel">Boek A</span></a>
</div>
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);
}
});
Demo
WickedBookstore
Vragen
... en antwoorden