Hi Kevin,
within...

On 18/04/2011 19:36, Kevin Meyer - KMZ wrote:
Hi Dan, I guess this one is for you...

I'm playing around with creating a custom view using Wicket, to take
advantage of the Wicket Palette form component.

Nice.  Great that you're trying this out.


I have a simple class (Tag) which basically just extends
AbstractDomainObject and has a single String member (called
Description).

In the palette contructor, I have to pass in a IModel choicesModel.

If I use the java.util.List that is returned by allInstances, I get a "Unable
to serialize class" exception, complaining:

[class=dom.todo.Tag$$EnhancerByCGLIB$$b459b0e9]<----- field that
is not serializable

OK, so here's the scoop. I've provided a bunch of implementations of IModel, all of which implement Wicket's LoadableDetachableModel and so should "do the right thing".

The most common model to use is EntityModel, which wraps an ObjectAdapter (which in turn wraps up a single domain object entity).

In your case, though, you should use EntityCollectionModel, which can be used to wrap either a standalone collection (eg returned from an action) or a parented action (eg Order/OrderDetail).

Hopefully if you have a look at some of the existing panels and how they use these models, you'll get the idea.



The palette is still rendered, though. I have not yet put in any handlers
to try and receive the choices list and adjust the eventual target
collection.

I wanted to ask: What do you recommend I use to hold, store, and
retrieve the collection of domain objects that are to be manipulated
using the wicket Palette component?
the models (eg EntityModel) in org.apache.isis.viewer.wicket.model.models; see above.



Should I use a collection of a simple wrapper class (that is not
persisted, etc), that represents the domain object as just an integer ID
(sequence?) and a title?  I can see advantages to not passing the
"live" domain object for serialisation by Wicket. For a first pass, I will
assume that the ID is just the index of the objects in the returned
collection...
  ...So far this seems to work (i.e. it does not throw a "not serializable"
exception.
So, as you see from the above, the wicket viewer is a little more sophisticated than this, and (hopefully!) will work with any object or list with not too much effort.

Cheers
Dan

Regards,
Kevin



Reply via email to