Hello,

Inside the Palette there is a Recorder<T> which is basically a customized HiddenField that holds the id of each selected element.


/**
* Returns recorder component. Recorder component is a form component used to track the * selection of the palette. It receives <code>onchange</code> javascript event whenever a
     * change in selection occurs.
     *
     * @return recorder component
     */
    public final Recorder<T> getRecorderComponent()
    {
        return recorderComponent;
    }

So myPalette.getRecorderComponent().add(new FormComponentUpdatingBehavior("onchange"){

protected void onUpdate(AjaxRequestTarget target) {
                            /**
I imagine something like this should do the trick, but i can't find anything like it:

                              Media m = getSelectedItem();
                              imgPanel.setFilname(m.getFileName());
                            */

Iterator selectedChoices = myPalette.getSelectedChoices();

// let the image panel do something with the selected choices.
                            target.addComponent(imgPanel);

});

This should give you what you want.

Regards,

Mike
i have some trouble to access the currently selected item of a Palette component. By selected i mean the item which is highlighted if a user clicks on any of the items within the palette. i need that access because i want to update an Image component which renders an image which reflects the selected item

here is the (simplified) piece of code i use to get notified if the palette is clicked:

final Palette palette = new Palette("palette", mediaModel, paletteModel , renderer, 10, true) { private static final long serialVersionUID = -5683120408447757525L;

                @Override
                protected void onBeforeRender() {
                    super.onBeforeRender();

getChoicesComponent().add(new AjaxFormComponentUpdatingBehavior("onclick") { private static final long serialVersionUID = -6216894553871444828L;

                        @Override
protected void onUpdate(AjaxRequestTarget target) {
                            /**
I imagine something like this should do the trick, but i can't find anything like it:

                              Media m = getSelectedItem();
                              imgPanel.setFilname(m.getFileName());
                            */
                            target.addComponent(imgPanel);
                        }
                    });
                }
            };


max


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to