Hi,
I have a situation that I want to change possible choices in a palette
according to a DropDown.
I added to the DropDown the Ajax Updating
add(new AjaxFormComponentUpdatingBehavior("onchange") {...}
I have this palette:
final CustomPalette palette = new CustomPalette("palette", new
PropertyModel(rolesCoverage, "comparedConfigurations"),
                allConfigurationsModel, choiceRenderer, 10, true);
and:
        final IModel allConfigurationsModel = new AbstractReadOnlyModel() {
            private static final long serialVersionUID = 1L;

            @Override
            public Object getObject() {
                final List<Configuration> allConfigs =
sageDal.getConfigurations();
                allConfigs.remove(rolesCoverage.getMainConfiguration());
                return allConfigs;
            }
        };
The page uses CompoundPropertModel: super(id, new
CompoundPropertyModel(rolesCoverage)); in the constructor.
The problem that I encountered is that if I added to the target of the
DropDown the palette, it kept remembering my selected values.

In order to change that I hacked a bit with our CustomPalette:
    @Override
    protected Component newChoicesComponent() {
        final Component result = super.newChoicesComponent();
        externalizedChoiceComponent = result;
        externalizedChoiceComponent.setOutputMarkupId(true);
        return result;
    }

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

And in the DropDown, instead of adding the palette, I used
target.addComponent(customPalette.getExternalizedChoiceComponent());

It works.

My question is if this is the correct way? Is there a better way doing that?

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

Reply via email to