We do something similar to this in Estatio... take a look at IncomingDocAsInvoiceViewModel (or something like that).
If you use Jaxb view models, then it simply requires a property referencing the underlying domain entity (which should be annotated with XmlAdapter(PersistentEntityAdapter.class) so that Jaxb can serialize the reference into an oid. HTH, Dan. On Wed, 4 Oct 2017, 04:45 Stephen Cameron, <[email protected]> wrote: > Hi, > > I want to use view models as a wrapper around a persisted domain entity to > simply present an alternative view of that entity. The idea of caching such > a view model doesn't make sense to me, rather I want the persisted domain > entity to be cached and the view model (representation of it) to be > recreated each time that its needed, probably by having a constructor that > includes the domain entity as a parameter. > > I can create a DomainObject with nature = Nature.INMEMORY_ENTITY, and make > it non bookmarkable, how the title is still a link to a now cached entity > that cannot be recreated. > > Stack trace: > > - org.apache.wicket.WicketRuntimeException > - Can't instantiate page using constructor 'public > > > org.apache.isis.viewer.wicket.ui.pages.entity.EntityPage(org.apache.wicket.request.mapper.parameter.PageParameters)' > and argument > > > 'objectOid=[*one.projectviewmodel:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG1lbWVudG8vPg==]'. > An exception has been thrown during construction! > - > org.apache.wicket.session.DefaultPageFactory#newPage(DefaultPageFactory.java:194) > > > I can see a way to do what I want by creating a persistent domain entity > that references the persistent domain entity of interest, and then just has > getters that refer to the equivalent getter of the domain entity of > interest. > > This need has been created my desire to have a very simple view of a domain > entity without using tabs in the layout.xml and the admin view that does > use layout.xml, but I suspect its a more general need. > > Steve >
