Download presentation
Presentation is loading. Please wait.
Published byLaura Douglas Modified over 6 years ago
1
Apache Wicket Component Based Web Development Framework
2
Wicket Agenda: What is Wicket? Why use Wicket? Core Wicket Concepts
There is an overwhelming number of Java web frameworks available today, primarily distinguished by two main groups, Traditional – or – request based (Struts, Spring MVC…) and Component Based (Wicket, Tapestry...). What is Wicket? Why use Wicket? Core Wicket Concepts A few Wicket examples
3
What is Wicket? Open Source Component Based Pure Java & HTML
Enables component oriented, programmatic manipulation of markup Pure Java & HTML Clean separation of Java and HTML The mission: bringing object oriented programming to the web application view layer
4
Why use Wicket? Integration State management Clustering support
Spring Guice Hibernate and more… State management Clustering support Back button support
5
Why use Wicket cont.. Ajax support without writing JavaScript!
Integration with some JavaScript libraries such as jQuery URL Mounting Pretty URLs Component Level Security
6
Core Wicket Concepts: Pages & Panels
The four most important wicket concepts that require understanding by any user, are Session, Components, Models, and Behaviors. Without these four main concepts you cannot manage dataflow throughout your wicket application. Pages & Panels Session Components Models Behaviors
7
Pages & Panels Page: Panel
A representation of what is to be displayed to the user when the page is loaded. Consists of HTML & Java May contain 1 … N panels Panel Reusable displayable component
8
Wicket and Sessions Stores Session specific data Locale, client info
Wicket’s Session is an implementation of java’s HttpSession. Stores Session specific data Locale, client info Logged in user Shopping cart contents Page history and back button support And whatever else you need to maintain..
9
Sessions are EASY with Wicket
class MySession extends WebSession { private ShoppingCart cart; public ShoppingCart getCart() { … } public void setCart(ShoppingCart cart) { … } } mysession.setCart(new ShoppingCart()); The sessions is accessible from ALL pages / panels
10
Components! The ultimate superclass!
Encapsulate the programmatic manipulation of markup. May receive events onClick, onSubmit, etc.. Know how and when to render themselves
11
How components work. HTML Markup Java Code
<h1 wicket:id=“title”/> <input wicket:id=“firstName”/> Behaviors: <button wicket:id=“addUser" type="submit" class="positive“> <b>Add User</b></button> new Label(“title”, “It’s a Title!”); new TextField(“firstName", new PropertyModel(user, " firstName ")); Behaviors new Button(" addUser ", new Model<String>("Add User")) { @Override public void onSubmit() { // do something here!!! }
12
Component Validation Input validation is key in all web applications, fortunately Wicket makes this easy! TextField phoneNumberInput = new TextField("phoneNumberInput", new PropertyModel(currentUser, "phoneNumber")); phoneNumberInput.setRequired(true) .add(new StringValidator.ExactLengthValidator(10)) .add(new PatternValidator("[0-9]*"));
13
Creating your own Components
Wicket is designed and intended for extension, if the provided components don’t do EXACTLY what you want, you can easily extend any of them!
14
<<Person>>
Wicket Models Models bind your POJO’s to Wicket components Label(“name”, model) <<Person>> +name : String +city : String PropertyModel
15
Example Models: PropertyModel: In Code:
new PropertyModel(person, “name”) new PropertyModel(person, “address.street”) In Code: Person person = new Person(); new TextField(“firstName", new PropertyModel(person, "firstName"));
16
Examples and Q & A
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.