Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Wicket Custom TextField

Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very new to Wicket (just getting started really) and I find the documentation to be very disappointing, and the framework complex. I love the concept and am attracted by the potential power and reuse of the component architecture especially the promise of rapidly extending and creating custom components.

For my first custom component I wanted to modify a TextField to do some things my project does ALL THE TIME like showing a textbox as plain text when it is disabled. I want to override the onRender(MarkupStream) to write out just text when the control is disabled instead of writing a disabled textbox.

Seems simple enough so I wrote the following in my new TextField:

public void onRender(MarkupStream stream){

The renderNext() was something that the javadoc didn't make clear was part of the implied onRender contract, but I found a brief online reference to and it solved on exception, but now that field throws an exception when run saying it wasn't in the hierarchy when it is disabled.

If I call the super.onRender() everything works fine, but as soon as I try to put out HTML that is not adding to what the super wants to render, the thing breaks. Clearly there is more to the implied contract of the onRender() than the docs are saying. This ought to be so easy, but is very frustrating.

Note: I know I could replace the TextField with a Label, this was meant to be a proof of concept where I can modify the HTML written by a component thus demonstrating how 'easy' it is to make a component do anything we want in the page.

Am I going about the idea of subclassing the Component incorrectly? What must the onRender() do to conform to the mysterious undocumented contract?
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's already a component which does what you'd like to achieve. It's called AjaxEditableLabel (

Else you're right. The documentation sucks quite much for a beginner. I can recommend the book "Wicket in Action" which really rocks. After reading that book you can solve 90% of your problems with the reference library ( and/or a quick search on the mailing list (which is very responsive and helpful).

"now that field throws an exception when run saying it wasn't in the hierarchy when it is disabled."
Try to use a placeholder for the (disabled) component. For that you have to call setOutputMarkupPlaceholderTag(true) on your component (
We noticed he had no friends. So we gave him this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!