Hi all,
I have a problem with the Palette component:
I'm using a palette with a model populated by an EJB entity, and I want it
to show the correct selection status when it is displayed.
I mean that when the 'edit' button is clicked on a user, the current 'event'
that s\he has selected is shown
In code:
The following:

>         /*all the events (2) - checked this - it's not null*/
>         List<EventsEntity> events =
> LookupHelper.getInstance().lookupEventsEntityFacade().findAll();
>         /*selected events for this user (same 2) - checked this - it's not
> null*/
>         List<EventsEntity> selectedEvents = new
> ArrayList<EventsEntity>(model.getObject().getEvents());
>         IChoiceRenderer<EventsEntity> renderer = new
> ChoiceRenderer<EventsEntity>("name", "id");
>         palette =
>                 new Palette<EventsEntity>("palette",
>                 /*Selected Events*/new
> ListModel<EventsEntity>(selectedEvents),
>                 /*unselected*/new CollectionModel<EventsEntity>(events),
>                 renderer,
>                 10,
>                 false);
>
>         add(palette);



>             //For debugging purposes:
>             for (Iterator<EventsEntity> it = palette.getSelectedChoices();
> it.hasNext();) {
>                 EventsEntity eventsEntity = it.next();
>                 log.error("Selected choice: " + eventsEntity.getName());
>         }

Throws an exception saying that the  'palette.getSelectedChoices();' returns
null
I would expect it to write the selected events to the log...

Am I doing something wrong? did I misunderstand the API?
it said:

> Palette
>
> public *Palette*(java.lang.String id,
>                org.apache.wicket.model.IModel<java.util.Collection<T 
> <http://static.ddpoker.com/javadoc/wicket-extensions/1.4-m2/org/apache/wicket/extensions/markup/html/form/palette/Palette.html>>>
>  model,
>                org.apache.wicket.model.IModel<java.util.Collection<? extends 
> T 
> <http://static.ddpoker.com/javadoc/wicket-extensions/1.4-m2/org/apache/wicket/extensions/markup/html/form/palette/Palette.html>>>
>  choicesModel,
>                org.apache.wicket.markup.html.form.IChoiceRenderer<T 
> <http://static.ddpoker.com/javadoc/wicket-extensions/1.4-m2/org/apache/wicket/extensions/markup/html/form/palette/Palette.html>>
>  choiceRenderer,
>                int rows,
>                boolean allowOrder)
>
> *Parameters:*id - Component idmodel - Model representing collection of
> user's selectionschoicesModel - Model representing collection of all
> available choiceschoiceRenderer - Render used to render choices. This must
> use unique IDs for the objects, not the index.rows - Number of choices to
> be visible on the screen with out scrollingallowOrder - Allow user to move
> selections up and down

Using Wicket 1.4, EJB 3, Jboss 5.1 inside of a Liferay Portal environment.
TiA,
Elad Katz.

Reply via email to