Friday, August 10, 2007

Configuring Eclipse 3.3 for wicket web development

Install software updates and plugins

Go to: Help->Software Updates->Find and Install
Select: Search for updates of currently installed features
Automatically select mirrors (or manually do it if you prefer)
I can't remember what I updated, but there is a minor Eclipse update available
Install this update -- I think it is needed for WicketBench to work.
When asked to restart Eclipse, say NO (not yet).
Next, go again to: Help->Software Updates->Find and Install
Select: Search for new features to install
Check Web Tools Platform (WTP) Updates
Click Finish
Select Web Tools Platform (WTP) -> Web Standard Tools (WST)
(only select the one checkbox, not the others such as SDK)
Go through install process
When asked to restart Eclipse, say NO (not yet).
Next, go again to: Help->Software Updates->Find and Install
Select: Search for new features to install
Click New Remote Site button
Name: Wicket Bench
The new Wicket Bench site should be checked.
Click Finish
Go through install process
Now, when asked to restart Eclipse, say YES.

Configure workspace preferences
Go to: Window->Preferences
Select: Java->Compiler
Make sure compiler compliance level is 5.0
Select: Java->Compiler->Errors/Warnings
Under Potential programming problems
Set Serializable class withous serialVersionUID to Ignore
Select: General->Editors->Text Editors
Set the displayed tab width to 4 (or whatever you prefer)
Uncheck insert spaces for tabs (unless you want spaces, but they bug me)
Check show line numbers
Select: General->Workspace->Local History
Set Days to keep files to 14 (or whatever you want...)
Click OK to save everything

Now, to open a Java class, right click onto the class and select Open with -> Wicket Editor. You only need to do this one time. After that, it will automatically use the wicketbench editor when you open that class. In the editor, there will be tabs at the bottom of the editor window for java, properties, css, and html. You can quickly switch between these files within one editor (for instance,,, HomePage.html, and HomePage.css). It makes it easy for working with Wicket.

WST needs to be installed or you won't be able to edit HTML files with HTML tag highlighting. Whenever you open an HTML file, it will render it in a web browser, but it won't be editable unless you install WST. With WST, you can edit it using the "HTML editor" instead of doing a right click->open with->Text Editor. Another alternative is Aptana. I'm experimenting with it -- it does a lot more than WST, but it seems a bit too heavy and overkill for my needs. If I end up using it, I'll post here with more about it.

Also, WicketBench provides an HTML tab that automatically use WST HTML editor (I think it uses that editor). I don' t know if there is a way to get it to use the Aptana HTML editor. WicketBench also provides a Preview tab that renders the page, but it isn't the same as opening with the Web Browser.

Note that I originally I also did this, but I recommend against doing it:
Go to: Window->Preferences
Select: General->Editors->File Associations
Highlight *.java in list of File Types
Select associated editor: Wicket Editor
Click onto the Default button

When you do that, it causes a wicketbench/eclipse debugger bug to happen. I've found that the debugger in eclipse doesn't show the current line of execution in the code if wicket bench is installed and configured as the default Java editor. The debugger works, and the thread view shows the current line number, but the line isn't highlighted in the code.

At this time, Wicket Bench hasn't been officially tested with Eclipse 3.3 yet, but I understand that this same issue existed prior to Eclipse 3.3. See this FAQ:

To avoid the problem, just do not set WicketBench as the default editor for java files. Instead, use right-click, "Open With" Wicket Editor as I described above to open java classes. The next time you open them, you can just double click and it will remember to use WicketBench. And, by doing this, the debugger will open a regular Java Editor and will show the current line highlighted. Even if you have a WicketBench editor open for the same file, the debugger will open a new window with a regular Java Editor during debugging. You will have to close the extra files manually, however.

Once this is done, eclipse provides a decent environment for developing wicket apps. You might also want to add the subversive plugin to eclipse, as described in my previous post.

Next, I may look into adding a maven plugin, but no time for that right now.

1 comment:

Unknown said...

I am very happy to be able to find this excellent article! After reading your article, I feel learned a lot of things, and we hope to see your next article, look forward to your masterpiece.
Infrastructure Systems Egypt