Here what I did:
choiceComponent in the original Palette is private, so in my custom palette
I externalized it:

private Component externalizedChoiceComponent;

Then, I overridden the method newChoicesComponent :
    @Override
    protected Component newChoicesComponent() {
        final Component result = super.newChoicesComponent();
        externalizedChoiceComponent = result;
        externalizedChoiceComponent.setOutputMarkupId(true);
        return result;
    }

    public Component getExternalizedChoiceComponent() {
        return this.externalizedChoiceComponent;
    }

My situation was that I wanted to change the choices with a DropDown
component.
We have a custom DropDown that is ajaxified:
        final DropDownChoice configurationChoice = new
DropDownChoiceWithAjaxIndicator("mainConfiguration",
                getConfigurationsModel(), new
ChoiceRenderer("configurationName", "configurationName")) {
            private static final long serialVersionUID = 1L;

            @Override
            public void updateOnChange(AjaxRequestTarget target) {

target.addComponent(palette.getExternalizedChoiceComponent());
            }
        };

Below is the IModel for the palette that needs to be changed:
        final IModel allConfigurationsModel = new AbstractReadOnlyModel() {
            private static final long serialVersionUID = 1L;

            @Override
            public Object getObject() {
               // Do whatever you want to get the correct choices
            }
        };
And this is the Palette creation:
        final CustomPalette palette = new CustomPalette("palette", new
PropertyModel(rolesCoverageDasboard,
                "comparedConfigurations"), allConfigurationsModel,
choiceRenderer, 10, true);

Is this what you need?

BTW,
I think I'll have a look at the Recorder, though I'm not sure I can use it.

Maybe we should open a JIRA to have getChoicesComponent() in the Palette?
(we use 1.3.6)

Eyal Golan
[email protected]

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary


On Mon, Jun 22, 2009 at 11:57 PM, Rangel Preis <[email protected]> wrote:

> Sorry Fernando but it's not helpful.
>
> When i click in my search button (a button out of palette)  i want to
> change all data from the left side of palette (Available itens).
> I don't want to interact with the palette buttons i want to use a
> button out of the component.
>
> Using
> PropertyModel availableItens = new PropertyModel(this, "listDirector");
> or
> Model availableItens = new Model<Serializable>((Serializable)
> this.listDirector);
>
> ......
>
> form.add(new Palette("palette", selectedItens, availableItens,
> renderer, 10, true));
>
> form.add(new(AjaxLink btFilterPaletteContent = new
> AjaxLink("btFilterPaletteContent"){
>
>   @Override
>   public void onClick(AjaxRequestTarget target) {
>        What i can put here to change my avaliable itens (the palette left
> list)?
>       target.addComponent(this.form);
>   }
> };)
>
>
>
>
> 2009/6/22 Fernando Wermus <[email protected]>:
> > If I understood correctly you would want to do this (which It can be
> found
> > at Palette comments at the begining)
> >
> >  <strong>Ajaxifying the palette</strong>: The palette itself cannot be
> > ajaxified because it is a
> >  panel and therefore does not receive any javascript events. Instead ajax
> > behaviors can be
> >  attached to the recorder component which supports the javascript
> > <code>onchange</code> event. The
> >  recorder component can be retrieved via a call to {...@link
> > #getRecorderComponent()}.
> >
> >  Example:
> >
> >  <pre>
> >          Form form=new Form(...);
> >          Palette palette=new Palette(...);
> >          palette.getRecorderComponent().add(new
> > AjaxFormComponentUpdatingBehavior(&quot;onchange&quot;) {...});
> >
> > Then when someone click in any of the buttons you can take a decision
> over
> > the selected items or choiced items. You can do this without ajax
> replacing
> > the newUp, new newDown protected methods.
> >
> > I hope I help you a bit.
> >
> > On Mon, Jun 22, 2009 at 12:08 PM, Rangel Preis <[email protected]>
> wrote:
> >
> >> Hi, how can i filter the possible choices in the palette component i
> >> read the topics below put it not helpful for me.
> >>
> >>
> >>
> http://www.nabble.com/how-to-add-filter-for-Palette-choice-td23269578.html#a23269578
> >>
> >>
> http://www.nabble.com/changing-choices-component-in-Palette-td23982514.html#a23982514
> >>
> >> I have this:
> >>
> >> final IChoiceRenderer<String> renderer = new
> >> ChoiceRenderer<String>("name", "name");
> >> form.add(new Palette("paletteDiretores", selectedItens,
> >> availableItens, renderer, 10, true));
> >>
> >> And a button:
> >>
> >> AjaxLink btFilterPaletteContent = new
> AjaxLink("btFilterPaletteContent"){
> >>
> >>    @Override
> >>    public void onClick(AjaxRequestTarget target) {
> >>        availableItens = search new itens....
> >>    }
> >> };
> >>
> >> I try this and don't work, if i inspect the objet the value is OK, but
> >> in the screen the palette become blank.
> >>
> >> i try to use propertymodel to avaliableitens... don't work too..
> >> I just want to chance the content of the avaliable itens in the panel
> >> without affect the selecteds itens.
> >>
> >> Anyone can help me?
> >>
> >> Thanks.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
> >
> > --
> > Fernando Wermus.
> >
> > www.linkedin.com/in/fernandowermus
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to