1 / 16

Apache Wicket

Apache Wicket. Component Based Web Development Framework. Wicket Agenda:. 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...). .

gaerwn
Download Presentation

Apache Wicket

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Apache Wicket Component Based Web Development Framework

  2. Wicket Agenda: 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...).

  3. What is Wicket? • Open Source • Component Based • 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 • 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: 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.

  7. Pages & Panels • Page: • 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 • Consists of HTML & Java • Reusable displayable component • May contain 1 … N panels

  8. Wicket and Sessions 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 ShoppingCartgetCart() { … } 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! TextFieldphoneNumberInput = 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. Wicket Models • Models bind your POJO’s to Wicket components Label(“name”, model) <<Person>> +name : String +city : String PropertyModel

  15. Example Models: • PropertyModel: • 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

More Related