Web Development with just Java and HTML

47 slides
0.62 MB
905 views

Similar Presentations

Presentation Transcript

1

Apache Wicket: web applications with just Java Xavier Hanin JavaZone ‘07

2

Who is Xavier HaninIndependent Java Consultant Customers Open Source Renault

3

AgendaWhat is Wicket Core concepts of Wicket Developing a custom component Q&A

4

Wicket in a NutshellOpen Source (Apache Software Foundation) Component based Pure Java + Pure HTML Simple Enthusiastic community

5

What is Wicket?The technology: enabling component-oriented, programmatic manipulation of markup The mission: bringing object oriented programming to the web application view layer The reward: have a fun job and be good friends with your manager again

6

Achieving these goals throughKeeping simple things simple Utilizing an object-oriented component model where components are truly self contained Re-applying the Model View Controller pattern on components instead of requests, with models as first class citizens Having a clean separation of concerns between HTML and Java

7

Achieving these goals throughProviding transparent, fully automated state management Keeping configuration needs to the minimum No more XML! Making using & creating custom components easier than any framework out there

8

Component versus ‘traditional’Traditional Struts, WebWork, Spring MVC, etc. Proven for web A lot of web developers available Components JSF, Wicket, Tapestry, etc. Traditional model for UI development on thick clients A lot of developers available

9

FeaturesPage composition panels, borders and markup inheritance Excellent localization and style support template and resource loading (_be.html, .xml) localized models (e.g. for labels) sophisticated resource bundle lookup (composition & inheritance hierarchy) automatic client capabilities detection

10

FeaturesIntegration Spring Guice Hibernate JasperReports OSGi Fancy components sortable, filterable, pageable, data aware tables date picker, rich text editor, Google Maps tabbed panel, navigation, tree, wizard

11

FeaturesState 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

12

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

13

AgendaWhat is Wicket Core concepts of Wicket Developing a custom component Q&A

14

Wicket’s conceptsApplication Session RequestCycle Components Behaviors Models

15

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

16

ApplicationConfigured in web.xml: wicket org.apache.wicket.protocol.http.WicketFilter applicationClassName example.MyApplication 1

17

Wicket’s conceptsApplication Session RequestCycle Components Behaviors Models

18

SessionAbstraction 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

19

Sessionclass MySession extends WebSession { private ShoppingCart cart; public ShoppingCart getCart() { … } public void setCart(ShoppingCart cart) { … } } mysession.setCart(new ShoppingCart()); … ShoppingCart cart = mysession.getCart(); cart.add(quantity, selectedProduct);

20

Wicket’s conceptsApplication Session RequestCycle Components Behaviors Models

21

RequestCycleSteps 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

22

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

23

Wicket’s conceptsApplication Session RequestCycle Components Behaviors Models

24

Componentsencapsulate the programmatic manipulation of markup can receive an event onClick, onSubmit know how and where to render itself

25

ComponentUltimate super class wicket.ComponentLabel MultiLineLabel TextField PasswordTextField Image Link Tree BookmarkablePageLink JasperReportsListView Loop PagingNavigator ImageMap Button Ajax… Sorting, paging repeaters Wizard DatePicker

26

Components and markupA component is identified in markup with wicket:id Html:

Gets replaced

Java: new Label(“msg”, “Hello, World!”); Final (wicket tags can be stripped):

Hello, World!

Browse More Presentations

Last Updated: 8th March 2018

Recommended PPTs