PaulH98 wrote:

Michael O'Cleirigh wrote:
Hi Paul,

What I would do would be to find a javascript implementation that does what you want and then have the selection events fill in a hidden field which will then be available on the server side when the form is posted. This would be similar to how the Palette works in wicket-extensions

You then define a custom IConverter to convert the string input from the hidden field into the IModel<List<Leaf>> or IModel<List<Node>> or what ever makes sense for your model..

There is probably something in wicket-stuff already but here is a link to a jquery plugin for a tree table:



Thanks Mike... Is there any document on how to write such a component like
Palette that communicates with javascript? I just skipped through the
Palette java an js source code and found they are kind of hard to
understand. "Wicket in Action" does not seem to cover this topic either.

Hi Paul,

Most of the wicket + javascript integrations in wicket-stuff ( will show how communication between wicket and javascript can work. They can get a little messy but once implemented are nice/simple to deal with since they are self contained.

When the page is rendered custom javascript is also rendered that connects the component javascript (in your case the stock tree table) with the wicket components (in your case the hiddenField.getMarkupID() that will be used to fill in the selection details).

This can be done by rendering out the wicket markup id details into a global variable in the DOM or as a property in a custom object in the DOM.

In the case of Palette it uses its own DOM object called Wicket.Palette (see palette.js which is adjacent to This is where the work is done to move values between the choicesComponent and selectionComponent. The recorderComponent is a customized HiddenField that stores the list of values that are shown in the selectionComponent. The buttons are configured with onclick actions which are connected to the contextualized Wicket.Palette.action functions.

Each of the Wicket.Palette.action functions expect three arguments:
1. the markup id of  the choices component
2. the markup id of the selection component
3. the markup id of the recorder component.

Which are filled in automatically for the palette being rendered.

For your example you could create a custom hidden field like this and define the converter so that it will have a comma seperated string content but resolve into a list of Elements:

   new HiddenField<List<Element>>(id) {

/* (non-Javadoc) * @see org.apache.wicket.Component#getConverter(java.lang.Class)
           public IConverter getConverter(Class<?> type) {
               return new IConverter() {
@Override public String convertToString(List<Element> valueList, Locale locale) {

// convert value list into a comma seperated string like A,B,C...
                       return string;
@Override public Object convertToObject(String value, Locale locale) { // convert a comma seperated string A,B,C... back into the list of elements
                       String[] elements = value.split(",");

List<Element> elementList = new LinkedList<Element>(); for (String e : elements) {

                              // convert
return elementList;

Then your javascript hooks for the on selection will append the id value of the selected element into the hidden field.

When the form posts the formsubmittingComponent.onSubmit() action can just call hiddenField.getModelObject() to get the list of selected elements to process.

Hope this helps you get started,


To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to