240 likes | 394 Views
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 .
E N D
Wicket in 60 Minutes Wicket 4 Newbs
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?)
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
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)); Java en HTML Gescheiden
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 )
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> Dependencies in pom.xml
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; publicclass 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; publicclass 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
HTML mark-up: <a href="#" wicket:id="homeLink">Home</a><br /> Java code: Link homeLink = new BookmarkablePageLink("homeLink", HomePage.class); Link 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 protectedvoid 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); } }); ListView Component
Demo WickedBookstore
Vragen ... en antwoorden