<< Android with IntelliJ IDEA 9 | Home | Wicket - AjaxLazyLoadPanel loading indicator >>

Learning Apache Wicket

Wicket in Action, code

Following entry will be outside of mobile development realm as I will rant about few things that I faced recently while learning about Wicket.

Why I'm learning + using Wicket?
Because of our current project at work and also because neither me or my colleague have any knowledge of other web frameworks. Therefore it was suggested to us have look at Wickets and try to learn something new.

What did we use?
For start I used Pro Wicket book by Apress, but soon found out that this book is more trouble then use (authors decided to teach people the way of giving first broken example and then try to fix it.)
So after that I picked up Wicket in Action by Manning Publishing. It has few question marks, but nothing serious that hasn't been fixed by so far.

What did they missed or is different?

  • When they been writing book Wicket been at version 1.3 where the latest one at the moment is 1.4.9 (check here for latest version).
  • Missing explanation how to create project from scratch and what would you need.
    Obviously you need installation of Java, you need some IDE, installation of Maven 2 is handy as the you can execute maven archetype that will help to build basic project structure and get you all necessary libraries including Jetty server. You can configure archetype here
    Provide group ID, give a artefact ID and select version of wicket you wish to use and final maven building string can look something like
    mvn archetype:create  
    -DarchetypeGroupId=org.apache.wicket  
    -DarchetypeArtifactId=wicket-archetype-quickstart  
    -DarchetypeVersion=1.4.9  
    -DgroupId=com.peterscorner  
    -DartifactId=DvdCollection
  • Chapter 3 - Building a cheesy Wicket application
    pg.50 - CheesrSession, at runtime you will find out this class is causing trouble because it is missing following method
      public Session newSession(Request request, Response response) {
        return new CheesrSession(request); 
      }

    pg.54 - authors place like CSS styles from Index.html. However as you will find later on this doesn't work. It is not till pg.248 of chapter 10 when authors provide a way for calling CSS, but this is out of date. So if you wish to have use of CSS and background image used by it you may wish to add following line at the beginning of Index class declaration
      public Index() {
    
        add(CSSPackageResource.getHeaderContribution("style/style.css"));
        //rest of the code

    pg.60 - overwriting getObject method of Label with return type of Object is now deprecated so you need to provided specific type you wish to return(String, int, double etc.). This is what I used at the end
        add(new Label("total", new Model(){
          public String getObject(){
            return "$"+getCart().getTotal();
          }
        }));
  • Additional stuff. In our project beside using images referenced from CSS we need to dynamically load images that are store on same level like CSS, under resources/images. The way to add then image to your page is as follows
    add(new ContextImage("smallLogoImage", "images/volareweekend/logo_small.png"));

 

Categories : Tips, Wicket

Export this post as PDF document  Export this post to PDF document

Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!
Technorati Tags : , , ,



Add a comment Send a TrackBack