Component Based Web Development with Apache Wicket



Similar documents
Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

MASTERTAG DEVELOPER GUIDE

Client-side Web Engineering From HTML to AJAX

Wicket Hiroto Yamakawa

The Smart Forms Web Part allows you to quickly add new forms to SharePoint pages, here s how:

Rich-Internet Anwendungen auf Basis von ColdFusion und Ajax

Building A Very Simple Web Site

The Google Web Toolkit (GWT): Declarative Layout with UiBinder Basics

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Introduction to Ingeniux Forms Builder. 90 minute Course CMSFB-V6 P

Apache Wicket User Guide - Reference Documentation

A Comparison of Open Source Application Development Frameworks for the Enterprise

WHITEPAPER. Skinning Guide. Let s chat Velaro info@velaro.com by Velaro

Building and Using Web Services With JDeveloper 11g

MAGENTO THEME SHOE STORE

Mobile Web Applications. Gary Dubuque IT Research Architect Department of Revenue

ecommercesoftwareone Advance User s Guide -

Portals and Hosted Files

Web Applications and Struts 2

Rapid Application Development. and Application Generation Tools. Walter Knesel

Example. Represent this as XML

What s New in IBM Web Experience Factory IBM Corporation

AJAX and JSON Lessons Learned. Jim Riecken, Senior Software Engineer, Blackboard Inc.

CMSC434 TUTORIAL #3 HTML CSS JavaScript Jquery Ajax + Google AppEngine Mobile WebApp HTML5

Developing Web Views for VMware vcenter Orchestrator

Paging, sorting, and searching using EF Code first and MVC 3. Introduction. Installing AdventureWorksLT database. Creating the MVC 3 web application

Improved Navigation Magento Extension User Guide

Overview. In the beginning. Issues with Client Side Scripting What is JavaScript? Syntax and the Document Object Model Moving forward with JavaScript

Embedded BI made easy

WIRIS quizzes web services Getting started with PHP and Java

Fortis Theme. User Guide. v Magento theme by Infortis. Copyright 2012 Infortis

Google Web Toolkit. Progetto di Applicazioni Software a.a. 2011/12. Massimo Mecella

Terms and Definitions for CMS Administrators, Architects, and Developers

Reports and Documents Generator for SharePoint ver.: 2.2

Enterprise Application Development In Java with AJAX and ORM

Framework as a master tool in modern web development

Timeline for Microsoft Dynamics CRM

<Insert Picture Here> Betting Big on JavaServer Faces: Components, Tools, and Tricks

Ross University s Content Management System (CMS) Training Manual

SPHOL326: Designing a SharePoint 2013 Site. Hands-On Lab. Lab Manual

SellerDeck 2013 Reviewer's Guide

CaptainCasa. CaptainCasa Enterprise Client. CaptainCasa Enterprise Client. Feature Overview

Interspire Website Publisher Developer Documentation. Template Customization Guide

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

Drupal CMS for marketing sites

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

IMRG Peermap API Documentation V 5.0

Making Web Application using Tizen Web UI Framework. Koeun Choi

Installing and Sending with DocuSign for NetSuite v2.2

How To Use Query Console

Website Login Integration

CREATING A NEWSLETTER IN ADOBE DREAMWEAVER CS5 (step-by-step directions)

Model-View-Controller. and. Struts 2

jquery Tutorial for Beginners: Nothing But the Goods

IBM Digital Experience. Using Modern Web Development Tools and Technology with IBM Digital Experience

Design Approaches of Web Application with Efficient Performance in JAVA

Wicket Application Development

Visualizing a Neo4j Graph Database with KeyLines

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Specify the location of an HTML control stored in the application repository. See Using the XPath search method, page 2.

UH CMS Basics. Cascade CMS Basics Class. UH CMS Basics Updated: June,2011! Page 1

An Oracle White Paper May Creating Custom PDF Reports with Oracle Application Express and the APEX Listener

DocuSign for Salesforce Administrator Guide v6.1.1 Rev A Published: July 16, 2015

DreamFactory & Modus Create Case Study

JTouch Mobile Extension for Joomla! User Guide

Security features of ZK Framework

A send-a-friend application with ASP Smart Mailer

Building Ajax Applications with GT.M and EWD. Rob Tweed M/Gateway Developments Ltd

Flexible Virtuemart 2 Template CleanMart (for VM2.0.x only) TUTORIAL. INSTALLATION CleanMart VM 2 Template (in 3 steps):

Macromedia Dreamweaver 8 Developer Certification Examination Specification

Web Development 1 A4 Project Description Web Architecture

Debugging JavaScript and CSS Using Firebug. Harman Goei CSCI 571 1/27/13

Elgg 1.8 Social Networking

Modern Web Application Framework Python, SQL Alchemy, Jinja2 & Flask

Sitecore Dashboard User Guide

Agenda2. User Manual. Agenda2 User Manual Copyright Bobsoft 1 of 34

Web Dashboard User Guide

QualysGuard WAS. Getting Started Guide Version 3.3. March 21, 2014

Pay with Amazon Integration Guide

CloudTest WebUI Tes0ng Tutorial

How To Write A Cq5 Authoring Manual On An Ubuntu Cq (Windows) (Windows 5) (Mac) (Apple) (Amd) (Powerbook) (Html) (Web) (Font

Basic tutorial for Dreamweaver CS5

Web Applications. For live Java training, please see training courses at

An introduction to creating Web 2.0 applications in Rational Application Developer Version 8.0


Developing ASP.NET MVC 4 Web Applications MOC 20486

How to utilize Administration and Monitoring Console (AMC) in your TDI solution

Getting Started with Ubertor's Cascading Style Sheet (CSS) Support

Online Multimedia Winter semester 2015/16

Visualizing an OrientDB Graph Database with KeyLines

Building Rich Internet Applications with PHP and Zend Framework

Pro/INTRALINK Curriculum Guide

Eclipse Web Tools Platform. Naci Dai (Eteration), WTP JST Lead

Microsoft Expression Web

DESIGNING HTML HELPERS TO OPTIMIZE WEB APPLICATION DEVELOPMENT

tools that make every developer a quality expert

HP Cloud Service Automation

Web application Architecture

Ajax Performance Tuning and Best Practice

Transcription:

Component Based Web Development with Apache Wicket Web Application Development with just JAVA and HTML - Karthik Gurumurthy, Architect, Symcon Global Technologies Author Pro Wicket, Apress

Agenda What is Wicket Core concepts of Wicket Developing a custom component Q&A 2

The Java Ecosystem When depressed, Women consume chocolates & go shopping while men invade other countries - An old chinese proverb When depressed, Women (still) consume chocolates & go shopping while men create yet another open source java web framework - Karthik Gurumurthy ;-) Luckily, Apache Wicket, by no means, gives an impression of having been created when under depression unlike a few others ;-) 3

Quotes Wicket is not a framework, it s a candy bar and everybody loves candy bars.. - Romain Guy, Lead Software Engineer, Java Swing Team, Author, Filthy Rich Swing Clients 'Dude, where are my objects?! and then I saw Wicket! 4

Apache Wicket in a Nutshell Open Source (ASF) Component Based Clean separation of Markup and Code Plain Old Java and Plain old HTML No new templating / expression language to learn Minimum Configuration needs Zero XML Framework ( No Annotations either ) If you know Java and HTML, you already know quite a bit about Wicket! 5

Features Page Composition Panels, Borders and Markup Inheritance Excellent Localization & Style Support template and resource loading (_be.html,.xml) localized models (e.g. for labels) sophisticated resource bundle lookup (composition & inheritance hierarchy) 6

Features Integration Spring Guice Hibernate Jasper Reports Fancy Components sortable, filterable, pageable, data aware tables date picker, rich text editor, Google Maps tabbed panel, navigation, tree, wizard 7

Features State management type safe sessions clustering support back button support Double submit strategies render redirect/ redirect to buffered response/ none Testing support JUnit testing extensive logging and error reporting 8

Features Ajax support and components Ajax without writing JavaScript, Dojo, Scriptaculous,... Header contribution Javascript & CSS URL mounting pretty URLs Component level security 9

Apache Wicket in a Nutshell Event based as opposed to Action based Mission Statement A Java Software Framework to enable componentoriented, programmatic manipulation of markup 10

Model2 (Struts) request Action Client push push push response 2 1 3 4 Hello.jsp 11

Component Oriented (Wicket) Model pull Comp-1 Client request Comp-2 pull Model response Comp-3 pull Model HelloPage.java 12

Agenda What is Wicket Core concepts of Wicket Developing a custom component Q&A 13

Wicket Concepts Application Session RequestCycle Components Behaviors Models 14

Application Main entry point for your web application Configuration Output Wicket specific tags? Watch for markup changes every? Defines homepage Factories for Session RequestCycle Security 15

Application Configured in web.xml <filter> <filter-name>wicket</servlet-name> <filter-class> org.apache.wicket.protocol.http.wicketfilter </filter-class> <init-param> <param-name>applicationclassname</param-name> <param-value> com.mycompany.myapplication </param-value> </init-param> <load-on-startup>1</load-on-startup> </filter> 16

Wicket Concepts Application Session RequestCycle Components Behaviors Models 17

Session Abstraction of a user session Storage typically in HttpSession Stores session specific data Locale, Client info (browser vendor and version) Your own data? Logged in user Shopping cart contents Limited page history for back button support 18

Session class ApplicationSession extends WebSession { private User loggedinuser; public User getloggedinuser() { } public void setloggedinuser (User cart) { } } appsession.setloggedinuser(new User()); User loggedinuser = mysession. getloggedinuser(); Permission[] permissions = loggedinuser.getpermissions(); 19

Wicket Concepts Application Session RequestCycle Components Behaviors Models 20

RequestCycle Steps in a request cycle: Create request cycle object Decode the request Identify request target (page, component, ) Process event (onclick, onsubmit, ) Respond (page, component, image, pdf, ) Clean up 21

RequestCycle Two types of requests: Stateful Tied to specific user session Not bookmarkable Stateless Not necessarily tied to specific user session Bookmarkable 22

Wicket Concepts Application Session RequestCycle Components Behaviors Models 23

Component Ultimate super class org.apache.wicket.component Label MultiLineLabel TextField PasswordTextField Image Link Tree BookmarkablePageLink Panel ListView Loop PagingNavigator ImageMap Button Ajax Sorting, paging repeaters Wizard DatePicker 24

Components and Markup A component is identified in markup with wicket:id Html: <h1 wicket:id= msg >Gets replaced</h1> Java: new Label( msg, Hello, World! ); Final (wicket tags can be stripped): <h1>hello, World!</h1> 25

Convention over configuration Component can have its own markup file Page Panel Border Put java, markup and supporting files in same package on class path Can also place localization properties file in the same package 26

A Page: Hello, World! 27

Wicket Concepts Application Session RequestCycle Components Behaviors Models 28

Behaviors Behaviors are plug-ins for Components They can modify the components markup item.add(new AbstractBehavior() { public void oncomponenttag( Component component, ComponentTag tag) { String css = (((Item)component).getIndex() % 2 == 0)? "even" : "odd"; tag.put("class", css); } }); Output: <tr class= odd > </tr> <tr class= even > </tr> 29

Behaviors Change attributes of your component s markup Add javascript events Add Ajax behavior component.add( new AjaxSelfUpdatingBehavior( Duration.seconds(1))); 30

Wicket Concepts Application Session RequestCycle Components Behaviors Models 31

Models Models bind your POJO s to Wicket components Label( name, model) PropertyModel <<Person>> +name : String +city : String 32

Models Lazy binding in Java sucks Doesn t update: new TextField( txt, person.getname()) Gives null pointers: new Label( street, person.getaddress().getstreet()) Solution: OGNL/EL like expressions 33

Models PropertyModel: new PropertyModel(person, name ) new PropertyModel(person, address.street ) 34

Advanced Models StringResource Internationalization & localization LoadableDetachableModel Keeps session state minimal Store only entity ID in session CompoundPropertyModel Shared between components Uses component ID for OGNL traversals 35

Compound Property Model form.add(new Label( name, new PropertyModel(person, name )); form.add(new Label( birthdate, new PropertyModel(person, birthdate )); form.add(new TextField( street, new PropertyModel(person, address.street ))); form.setmodel(new CompoundPropertyModel(person)); form.add(new Label( name )); form.add(new Label( birthdate )); form.add(new TextField( address.street )); 36

Ajax Out-of-the-box Dynamic updating of components in page Update multiple components in one request No JavaScript skills necessary Several Ajax components and behaviors available Other Projects Dojo integration Scriptaculous integration Yahoo! UI library integration 37

Wicket Ajax Components Wicket core AjaxLink AjaxFallbackLink AjaxPagingNavigator AjaxSubmitButton AjaxSubmitLink AjaxCheckBox Wicket extensions IndicatingAjaxLink AjaxEditableLabel AutoCompleteTextField UploadProgressBar AjaxTabbedPanel 38

Agenda What is Wicket Core concepts of Wicket Developing a custom component Q&A 39

Wicket Lead on Custom Components Eelco Hillenius: «Imagine being told that you can use Java as your programming language, but at the same time being told not to create your own classes. [...] I fail to understand why that has to be different for UI development, and Wicket proves it doesn't have to be so.» 40

Wicket Lead on Custom Components Creating custom component is as easy as typing in extends Extends wicket.component down the line Available on application classpath 41

Custom Components Panels provide grouping Have own markup file Can be exchanged in pages for other components Can contribute to header Can contain any number of components, including panels 42

TogglePane HTML Markup (Designer) <div id="i_d" class="pane_border"> <div class="pane"> <div class="pane_header"> <span>countries</span> </div> <div class="pane_content"> <span>india, Pakistan, Australia</span> </div> </div> </div> 43

TogglePane JavaScript (toggle.js) function init_toggle(){ var panes = $$('div#i_d.pane'); panes = $A(panes); panes.each( function(pane){ var header = $A(pane.childNodes).find( function(child){ return child.classname == 'pane_header'; } ); var content = $A(pane.childNodes).find( function(child){ return child.classname == 'pane_content'; } ); header.onclick = function(){ Effect.toggle(content,'blind'); }; } } ); Fetch all elements under a div with id I_D having class pane Scriptaculous for toggle effect For each pane, look for header and content elements. Attach a onclick listener to the header to toggle the content when clicked 44

Add the required scripts to the <head> <head> <script src="toggle.js" type="text/javascript"></script> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script src="effects.js" type="text/javascript"></script> </head> 45

TogglePane Custom Component Designer ensures that the HTML+ JS prototype works 46

Enter Wicket : Identifying Components <div id="i_d" class="pane_border"> <div class="pane"> <div class="pane_header"> <span>countries</span> </div> <div class="pane_content"> <span>india, Pakistan, Australia</span> </div> </div> </div> Repeating Block Header Content 47

Identifying Components (attach wicket:id ) This is a group of components <wicket:panel> A Panel! <div id="i_d" class="pane_border"> <div class="pane wicket:id= panes > <div class="pane_header"> Repeating Block <span wicket:id= header >Countries</span> </div> <div class="pane_content"> Header <span wicket:id= content >India, Pakistan, Australia</span> </div> </div> Content </div> </wicket:panel> 48

Time to Code TogglePane Component Add Dynamic Behavior to the markup in Wicket 49

Identifying Components for Ajax Behavior <div id="i_d" class="pane_border"> <div class="pane wicket:id= pane > <div class="pane_header"> <span wicket:id= header >Countries</span> </div> <div class="pane_content"> <span wicket:id= content >India,</span> </div> </div> </div> onclick of header Repaint content 50

Add wicket:id in order to attach Ajax Behavior <div id="i_d" class="pane_border"> On click of <div class="pane wicket:id= panes > header <div class="pane_header wicket:id= h > <span wicket:id= header >Countries</span> </div> Repaint Content <div class="pane_content"> <span wicket:id= content >India, Pakistan, Australia</span> </div> </div> </div> 51

Avoid FUD and illogical reasoning.. Q) Why is JSF better than Wicket? A) Well, uhhm because JSF is a standard http://www.theserverside.com/news/thread.tss?thread_id=45345 I can stand brute force, but brute reason is quite unbearable - Oscar Wilde

Resources http://wicket.apache.org ##wicket irc.freenode.net Books: Pro Wicket, Karthik Gurumurthy Wicket in Action, Eelco Hillenius & Martijn Dashorst Enjoying Web Development with Wicket, Kent Tong