The DDC uses the model choises internaly, if you want manage this model, use
it on other places, why don't you keep an refecence to by yourself?

setResponsePage(new ViewPicksPage(playersModel));

on DDC default model will have only the selected item, provided by choices
options you passed

On Fri, Sep 18, 2009 at 10:45 AM, Tim Delesio <[email protected]> wrote:

> I'm trying to default a DDC (DropDownChoice) using the model I am passing
> in.  The page is getting passed in a LoadableDetachableModel which is of
> Type Player.  The list to back the DDC is a List<Player>.
>
> LoadableDetachableModel playersModel = new LoadableDetachableModel()
>        {
>            protected Object load()
>            {
>                return playerManager.getPlayersInLeague(getActiveLeague());
>            }
>        };
>
> And here is the DDC.
>
>  final DropDownChoice downChoice = new DropDownChoice("name", new Model(),
> playersModel, new ChoiceRenderer("username", "id"));
>        add(downChoice);
>
> downChoice.add(new AjaxFormComponentUpdatingBehavior("onChange")
>        {
>
>            @Override
>            protected void onUpdate(AjaxRequestTarget target) {
>                setResponsePage(new ViewPicksPage(downChoice.getModel()));
> }
>
>        });
>
> The above code works but does not obviously does not default the DDC.  I
> want the default to be the playerModel that is being passed in to the page.
> If I pass the playerModel into the DDC (instead of the new Model()) I get
> an
> error saying that I can't set a model on a LDM (loadabledetachablemodel).
> What is the correct way to default the DDC?  I've read that I shouldn't use
> a LDM for backing as it is loadable, but then what model should I use?
>  Keep
> in mind that I am trying to keep the memory footprint low and do not want
> to
> serialize objects unless I have to.
>
> Tim
>

Reply via email to