Hi Jayesh, The framework determines the object type from the URL and uses the rest of the id to recreate the object. How the id is used depends on whether the object type is an entity or a view model.
In the case of entities, this is used to query the database. In the case of view models, though, these objects aren't persisted as such. Instead they are serialised into their id, so the id actually *is"* the state that was in view model, in effect a memento. There are several ways to implement a view model. One way is to implement the ViewModel interface, which means you have full control over the contents of the id, but also full responsibility for recreating the state. A second option - which from your question I'm guessing is what you might have done - is to annotate either with @ViewModel or @DomainObject(nature=VIEW_MODEL), these are equivalent. This will serialise the state of all properties (as rendered in the UI), but importantly any collections are ignored. The reason I'm guessing that this is what you've done is this last point. A third option, and the one that I prefer to do, is to annotate the object as a jaxb DTO (@XmlRootElement etc). This has the benefit that the state of any collections will also be captured, just do long as the jaxb annotations are correct. One possible issue you might hit if using jaxb, or in general if the state to be serialised is very large, is that a URL can only be about 8000 characters in length. If you hit this as an issue, then you can implement the UrlEncodingService SPI, where your implementation takes responsibility for caching the state somehow serverside and providing some sort of identifier to that state, eg a UUID. Writing this on my phone, so can't provide you with any links to docs, but hopefully that helps Cheers, Dan. . n Sat, 11 May 2019, 05:37 Jayesh Prajapati, <jayesh...@gmail.com> wrote: > Hi, > > *Requirement* > I have a HomePageViewModel where there is one action (button) that does > some processing and return another view model PendingApprovalViewModel. > This PendingApprovalViewModel contains a collection of > TransactionViewModel. For this TransactionViewModel there is a bulk action > as "Approve". > > 1) HomePageViewModel#process() : PendingApprovalViewModel > 2) PendingApprovalViewModel#pendingApprovalTransaction <- > Collection<TransactionViewModel> > 3) TransactionViewModel#approve(Collection<TransactionViewModel>):void > 4) TransactionViewModel#id, label, description, money, valueDate, etc. > > Objective is to show a table/grid of transactions with checkbox and let > user select desired transaction record and click on "Approve" > action/button. > > *Problem Statement* > After processing the PendingApprovalViewModel is returned with transaction > filled in it however, when PendingApprovalViewModel is rendered application > seems to create new instance of PendingApprovalViewModel, instead of > rendering the original view model that was returned. > > When I return Collection<TransactionViewModel> it render all the > TransactionViewModel correctly but without checkbox and "Approve" > button/action. > > Looks like I am missing something very fundamental w.r.to ViewModel. May > be > I need access to request or session where I can store these > TransactionViewModel and amend PendingApprovalViewModel to get it from that > store and return. > > Any advise/help on this will be great. > > *Apache ISIS version : 2.0.0-M1* > > Thank You, > Jayesh >