[ 
https://issues.apache.org/jira/browse/ISIS-915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14327423#comment-14327423
 ] 

Dan Haywood commented on ISIS-915:
----------------------------------

This has been partly addressed in 1.8.0, in that a view model can reference 
another view model as a single property; however collections are not supported.

Even then, the implementation is rather nasty... we have URL encoded OID of the 
inner referenced view model within the URL encoded OID of the outer referencing 
view model.

Should instead really we should build some sort of XML/JSON structure of the 
graph of view models, and then serialize into the URL encoded string.

> Framework should transparently allow view models to reference other view 
> models.
> --------------------------------------------------------------------------------
>
>                 Key: ISIS-915
>                 URL: https://issues.apache.org/jira/browse/ISIS-915
>             Project: Isis
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: core-1.6.0
>            Reporter: Vladimir Nisevic
>            Assignee: Dan Haywood
>             Fix For: core-1.9.0
>
>
> The description below shows the current behaviour; the core tries to 
> interpret the "Street" reference as a persisted entity.
> The workaround is to have explicitly implement ViewModel (rather than 
> annotated with @ViewModel) and to traverse the graph manually.  Using 
> XmlSnapshotService could be one way to do this (or at least to provide 
> inspiration on how to accomplish this).
> Note though that ISIS-916 is a prereq in order to implement such as 
> workaround.
> ~~~
> Having this ViewModel annotated classes
> {code}
> @org.apache.isis.applib.annotation.ViewModel
> public class Address2 {
>     public Address2(String lkmsId) {
>         this.lkmsId = lkmsId;
>     }
>     public String title() {
>         return "Address lkmsId:" + lkmsId;
>     }
>     public String iconName() {
>         return "Location_icon";
>     }
>     // {{ LkmsId (property)
>     private String lkmsId;
>     @MemberOrder(sequence = "1")
>     public String getLkmsId() {
>         return lkmsId;
>     }
>     public void setLkmsId(final String lkmsId) {
>         this.lkmsId = lkmsId;
>     }
>     // }}
>     // {{ Street (property)
>     private Street2 street;
>     @MemberOrder(sequence = "3")
>     public Street2 getStreet() {
>         return street;
>     }
>     public void setStreet(final Street2 street) {
>         this.street = street;
>     }
>     // }}
>     // {{ Housenumber (property)
>     private String houseNumber;
>     @MemberOrder(sequence = "2")
>     public String getHouseNumber() {
>         return houseNumber;
>     }
>     public void setHouseNumber(final String housenumber) {
>         this.houseNumber = housenumber;
>     }
>     // }}
> }
> {code}
> and 
> {code}
> @ViewModel
> public class Street2 {
>     public Street2(String lkmsId) {
>         this.lkmsId = lkmsId;
>     }
>     public String title() {
>         return "Street lkmsId:" + lkmsId;
>     }
>     // {{ LkmsId (property)
>     private String lkmsId;
>     @MemberOrder(sequence = "1")
>     public String getLkmsId() {
>         return lkmsId;
>     }
>     public void setLkmsId(final String lkmsId) {
>         this.lkmsId = lkmsId;
>     }
>     // }}
>     // {{ Streetname (property)
>     private String streetname;
>     @MemberOrder(sequence = "2")
>     public String getStreetname() {
>         return streetname;
>     }
>     public void setStreetname(final String aName) {
>         this.streetname = aName;
>     }
>     // }}
>     // {{ Plz (property)
>     private String plz;
>     @MemberOrder(sequence = "3")
>     public String getPlz() {
>         return plz;
>     }
>     public void setPlz(final String plz) {
>         this.plz = plz;
>     }
>     // }}
> }
> {code}
> When calling the domain service method
> {code}
>  @Prototype
>     @Render(Type.EAGERLY)
>     public Address2 retreiveAnnotatedAddressModelSample() {
>         Address2 address = new Address2("11");
>         address.setHouseNumber("12");
>         Street2 street = new Street2("123");
>         street.setStreetname("5th street");
>         street.setPlz("1100");
>         address.setStreet(street);
>         return address;
>     }
> {code}
> will bring this exception 
> {code}
> Handling the following exception
> org.apache.isis.core.runtime.persistence.PojoRecreationException: Could not 
> recreate pojo for oid oid 
> *a1.ase.viewmodel.annotated.Address2:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG1lbWVudG8-PGxrbXNJZD4xMTwvbGttc0lkPjxob3VzZU51bWJlcj4xMjwvaG91c2VOdW1iZXI-PHN0cmVldC5ib29rbWFyaz5hMS5hc2Uudmlld21vZGVsLmFubm90YXRlZC5TdHJlZXQyOlBEOTRiV3dnZG1WeWMybHZiajBpTVM0d0lpQmxibU52WkdsdVp6MGlWVlJHTFRnaVB6NEtQRzFsYldWdWRHOC1QR3hyYlhOSlpENHhNak04TDJ4cmJYTkpaRDQ4YzNSeVpXVjBibUZ0WlQ0MWRHZ2djM1J5WldWMFBDOXpkSEpsWlhSdVlXMWxQanh3YkhvLU1URXdNRHd2Y0d4NlBqd3ZiV1Z0Wlc1MGJ6ND08L3N0cmVldC5ib29rbWFyaz48L21lbWVudG8-
>       at 
> org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault.adapterFor(AdapterManagerDefault.java:311)
> ...
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to