Wicket Exception when using wrong order in addComponent

2011-02-19 17:19:01 +0100

Today I working on a application that uses the Wicket framework. I was plagued with the following Exception:

WicketMessage: org.apache.wicket.WicketRuntimeException: component myForm:myTable:editor not found on page nl.gerbrand-ict.gui.HomePage[id = 4], listener interface = [RequestListenerInterface name=IActivePageBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]

Root cause:


In place of the ... there was a full stacktrace, which information that's not not relevant for this posting.

Turned out the solution was pretty simple, but the cause isn't that easy to find and is quite a good example how some design decisions in Wicket aren't considered as clean.

I'm using Ajax-features of Wicket extensively.
I was creating a table, which contained editable fields (AjaxEdiableLabel). This would allow the user to click on a field in the table, to edit the content.
Somewhere I had the following code:

if .. needed .. {
... make item invisible

The super.onSubmit belonged, in this case, to AjaxEditableLabel. I found out the super.onSubmit() would call target.addComponent(this); to update the editable label itself. As you could see, in my code I'm telling wicket to update the component that's the parent of the editable label also.

In this case, the code caused wicket to first update the parent-panel, which in this case makes the child-component invisible. Then the wicket tries to redraw the child-component, which is then invisible. That will trigger the above error.
Unfortunately, solving this error isn't quite easy in all cases. Especially when you'd use a AjaxSelfUpdatingBehaviour you can have little control on the redrawing order.

Fortunately I found a good tip on the wicket mailing list to get rid of the exception. Add the following code your Wicketapplication class (the class that extends org.apache.wicket.protocol.http.WebApplication):

    protected IRequestCycleProcessor newRequestCycleProcessor() {
    	//Tip from http://apache-wicket.1842946.n4.nabble.com/WicketRuntimeException-component-not-found-on-page-td3055902.html
    	return new WebRequestCycleProcessor(){
    		public IRequestTarget resolve(final RequestCycle requestCycle,
    				final RequestParameters requestParameters) {
    	        try {
    	            return super.resolve(requestCycle, requestParameters);
    	        } catch (InvalidUrlException e) {
    	            if (requestCycle.getRequest().getURL().contains("LinkListener") || requestCycle.getRequest().getURL().contains("BehaviorListener")) {
    	            	log.warn("Couldn't process event, is ignored because of: "+e.getMessage());
                        //ignore exception
    	                return new PageRequestTarget(requestCycle.getRequest().getPage());
    	            } else {
                        //normal operation
    	            	throw e;


The above code will ignore all of the exception that occur when wicket tries to do something with an component that's no longer available because of an ajax-update. Of course this fix isn't very nice, hopefully later versions of Wicket fix the error all-together when Ajax-support is improved. For now, this seems the best solution.

Read more

JavaFX 2.0

2011-02-18 23:01:27 +0100

Yesterday I attended a NLJug meeting at Oracle at De Meern on JavaFX, called 'JavaFX 2.0 EA'. The meeting was presented by Roger Brinkley, who's a called 'Community leader', of Mobile and Embedded. That he was formally part of Sun wasn't hard to see based on his clothing and style.

Roger gave an overview of the new JavaFX 2.0, the road-map and the planned features. The software seems to be developed in an agile manner: the dead line is fixed, as is policy at Oracle (not meeting a dead line means exit for the responsible executive), but the final set of features is not.
The preview is available now for a limited audience, in May the first public beta will be released and in November the final will be available.

The most important news I heard:

  • JavaFX 2.0 will be a library (jfx.jar), rather than a separate scripting language JavaFX. The language works in the language Java of course, but you can use the language Scala, JRuby, Jython or other languages available on the JVM. JavaFX script is end-of-life. Fortunately, the syntax of the library calls is quite similar, and there's a program to translate JavaFX script into equivalent Javacode. Curiously, the translator, FX Translator, is written in Scala.
    Update 2011-06-15: I only heard about the fx translator at the here mentioned presentation. I could find little references to the translator: a back-reference to this posting (sigh) and the fxtranslator mentioned shortly in this posting on DrDobbs.
    If you want to use the FXtranslator, you'll have to contact Oracle for now. I guess Oracle will release the automatic translation tool in some time too.
  • The Swing-controls can be used from JavaFX 2.0. The 'traditional Swing' is now in maintenance mode, Oracle won't create an new features for the original Swing library. Meaning, if you want to develop Swing applications, or more generally, desktop applications in Java now, you can best get the beta or coming GA of JavaFX.
  • JavaFX 2.0 will be available on neither the Mobiles nor Televisions! Oracle has accepted (Sun's) loss, and will only focus on the desktop for the time being.
    JavaFX seems practical on tablet-devices. However, since most tablet devices are enlarged mobiles (running a mobile os) ratter than flattened laptops (running a full desktop os), you can't use JavaFX on any of those devices for the time being.
  • The JavaFX is supported on the MS-Windows platform only for the coming time, (but) it will run on Mac, Linux or other platforms unsupported. This means, you might miss the hardware acceleration when not using Windows. Mind you: Roger was using a Mac while doing his presentation and demonstration the code-samples so the MS-Windows-only support might not look as dramatic as it seems at first glance.
  • Of course JavaFX runs on the JVM 6 or higher. If all goes well, JavaFX will be part of JDK 8. Before that JavaFX can be downloaded as a plugin before from java.com, which will be not to painful for users, especially if they already have some version of the Java-plugin installed.

The JavaFX SDK contains a set of sample application called 'Ensemble'. Roger presented a few impressive programs, and showed the source code. The audience, including the Oracle employee hosting the event was very tech oriented so everyone was eager to see the code of all the nice examples.

Furthermore, Roger frequently mentioned Podcasts. I have yet to listen to them, but maybe if I have some time left. Should find a way to broadcast audio while doing the dishes.
All in all a nice event. Oracle may turn JavaFX in something that might be practical and usable on a limited number of platforms, ratter then trying to take over the world (or more specifically taking on Android, Flex, Apple IOS).

As you might notice, I've got no code examples or screen-shots. I hope to get access to the beta release of JavaFX 2.0, I'm quite interested in trying out all those nifty things, and expect some nice blog postings on JavaFX soon!

Update 2011-06-01: The public beta of JavaFX is out! I've published on JavaFX on the Xebia-blog.

Read more


subscribe via RSS