November 15, 2012

A Better Maven POM for Wicket Archetypes

If you are new or just wants to try Apache Wicket there is a good Wicket Maven Archetype for that. You can find instruction for that at http://wicket.apache.org/start/quickstart.html.

But the generated pom.xml leafs room for improvement. A better pom would be

The differences I made are the following.

1. Downgrade the Jetty Maven Plugin to 7.5.0.v20110901


The new jetty plugin are much slower than the old one and you want miss anything important.

2. Add Wicket Datetime Dependency


Wicket provides a good datetime picker and I recommend that you use this.

3. Configure Jetty Maven Plugin for Autodeploy


The jetty plugin can automatically be configure to pick up any changes made within Eclipse and automatically redeploy your application. This is a great way to develop and I recommend it.

You also might want to mock any possible server facade class, which is located in your test directory. To enable that add your web test classes to jetty classpath.

November 13, 2012

Where is Additional Driver in Ubuntu 12.10?



Yesterday I had problems with my wireless network card and then looked after the Additional Driver that existed in previous version of Ubuntu and it has been moved. To get it open Software Updated from Unity.


Click Settings... and the Additional Drivers tab.


Broadcom Wireless Network Card not working after updating Ubuntu 12.10

Yesterday I updated my HP ProBook 6550 with Broadcom 4313 with my fresh installed Ubuntu 12.10 and suddenly my wireless network card stopped working. I google and found the following article http://www.howopensource.com/2012/10/install-broadcom-b43-legacy-wireless-driver-in-ubuntu-12-10-12-04/. But that did not helped, until I also installed

System Development Environment on Ubunut 12.10

With the latest Ubuntu release most of the tool a Java developer needs comes packaged in official release packages.

Open JDK 7


The open JDK 7 is mature and ready for production. This since the latter version of Open JDK 6. The reason for this is that now Oracle really develop the next version of Oracle JDK version is done in the Open JDK version. Previously when Sun owned the Java SDK they merely dumped source code in the Open JDK repository, but Open JDK is really a upstream project.

Maven 3


Subversion 1.7


Please note that there is a big difference between svn 1.6 and 1.7, where 1.6 was the official package version in Ubuntu 12.04.

Subversion Client


If you have previously used RabidSVN, you should consider switching to KDESVN

Best Practice Apache Wicket

There are some guidelines written about the best way how to use Apache Wicket, but I think I might have some more to contribute to all the things that has already been written.

1. And maybe the most important is always use Wicket Models.

First Wicket is a component based framework, which in itself implies you should always use Wicket Models.

Secondly wicket is also a framework that out of the box handles the back button dilemma, which is what should happen when the user press the back button in the web browser? Wicket handles this by versioning every page. Which means that if a user have in entered some data in a HTML form, then submitted and thereafter presses back button, Wicket will then out of the box present the values the way it was before pressing submit AND keeping you server Model in synch. You can get a good feeling of the above by playing around with the form example at http://www.wicket-library.com/wicket-examples/forminput/.

To achieve this Wicket uses the HTTP Session to store the previously pages states. To not now blow the RAM space on the server, you should almost always use the LoadableDetachableModel.

Be sure you have completely have understood the antipatterns at https://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-Antipatterns.

The second and maybe finally most important Model is the CompoundPropertyModel. And remember that you can wrap Model. Example of that is:

2. To keep wicket code more readable, avoid using anonymous inner classes.

Wicket as well as Swing code can blow up in your face when it comes to anonymous inner classes. Instead write separate classes in the same WebPage class, like the above example. Which result in in a much more cleaner code.

3. Try to only use the PageParameters constructor

Example of that you can see in the above PersonPage example. The reason for that is now you page can always be bookmarkable. Which the default constructor also can be, but it is more generic to directly use the PageParameters constructor, in case you later need to use a page parameters.

 

4. Do not try to reinvent the wheel when it comes to graphical components.

Wicket comes with a rich set of ready to use graphical components. Be sure to import them in your pom file.

If you need more have a look at http://wicket.visural.net/examples/, which have a nice WYSIWYG editor and a spinner.
Also since Wicket 6 is jQuery the backend library for Ajax. Look for example at the jQuery modal window at http://www.wicket-library.com/wicket-examples/ajax/modal-window.

 

5. Use Wicket XHTML namespace

See https://cwiki.apache.org/WICKET/wickets-xhtml-tags.html

 

6. Be sure you have configured Maven Jetty Plugin to restart whenever you have made code changes


7. And remember you can always debug your Wicket code with a JUnit.

Wicket has a great support for module testing support. But these test cases can also be used for debugging. When generating a Wicket project with the archetype you get a single JUnit test case with that you can start Jetty and then simply add breakpoints and you can debug your code.
References: