Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wicket vs. main-method (how Wicket works?)

I am new to Wicket and would like to understand, how this framework works.

In normal Java application, the program counter starts in the main method. To understand the application from the beginning , I usually put eclipse break point at the beginning of this method and go step for step.

My Question is, when Wicket application is started, what happens first? How to follow the sequences in some Wicket application?

like image 861
Ronald Avatar asked Dec 21 '22 12:12

Ronald


2 Answers

Wicket is a Java Web Application framework, so first you have to understand that a bit. For a start on that, have a look at the Java EE tutorial.

Somewhere way up in the web application server, there is in fact a main method which is run when the server starts. But the connection to your web application written with Wicket is quite loose.

When you write and build a wicket application, one of the things you do is to create a web.xml file that describes to the web application container how to load your application. This normally includes a reference to WicketFilter and a reference to your application's subclass of WebApplication.

The WicketFilter class intercepts requests and sends them to your application.

A more detailed description of this process is on the wiki page LifeCycle of a Wicket Application.

like image 64
Don Roby Avatar answered Jan 03 '23 04:01

Don Roby


As the original creator of Apache Wicket, I'd suggest you stay as far away from Java EE as possible. The driving idea behind Wicket is to bring object-oriented programming to the web. There are other frameworks that do this, but Wicket is pretty good at it. As such, all these gory details of how Wicket uses the Servlet API to create this abstraction are truly something you don't need to worry about. If you're just curious and really want to see what happens, set a breakpoint in WicketServlet and/or WicketFilter and step through it.

There are a number of books on Wicket now:

https://wicket.apache.org/learn/books/index.html

Also, the reference guide on the web site is pretty complete:

https://ci.apache.org/projects/wicket/guide/9.x/single.html

Take a look in particular at the "under the hood of request processing" section as well as the "component lifecycle" section:

https://ci.apache.org/projects/wicket/guide/9.x/single.html#_under_the_hood_of_the_request_processing https://ci.apache.org/projects/wicket/guide/9.x/single.html#_components_lifecycle

This should give you a pretty good flavor for what happens. But again, you really don't need to know any of this stuff to make good use of the framework.

-- Jon

like image 36
Jonathan Locke Avatar answered Jan 03 '23 04:01

Jonathan Locke