Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F1C3C200D49 for ; Fri, 10 Nov 2017 00:06:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id F040A160C02; Thu, 9 Nov 2017 23:06:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 45794160BEF for ; Fri, 10 Nov 2017 00:06:08 +0100 (CET) Received: (qmail 85165 invoked by uid 500); 9 Nov 2017 23:06:07 -0000 Mailing-List: contact users-help@isis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@isis.apache.org Delivered-To: mailing list users@isis.apache.org Received: (qmail 85153 invoked by uid 99); 9 Nov 2017 23:06:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Nov 2017 23:06:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 50AA71A40AC for ; Thu, 9 Nov 2017 23:06:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.88 X-Spam-Level: * X-Spam-Status: No, score=1.88 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id ePzwFrDiZn0y for ; Thu, 9 Nov 2017 23:06:01 +0000 (UTC) Received: from mail-qk0-f169.google.com (mail-qk0-f169.google.com [209.85.220.169]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 4A2BB60FDC for ; Thu, 9 Nov 2017 22:46:34 +0000 (UTC) Received: by mail-qk0-f169.google.com with SMTP id 2so8977820qkg.13 for ; Thu, 09 Nov 2017 14:46:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Th1BFHY4alYwpOs3a3dP85SQNmdi5BYceDIUrYUzNRw=; b=f3SbqzzmdRAkjk5Mhi2pDMkTL6TzO0w4loW0vmLjVYz1abuuom64xkWDp2KaEQxHZg EvkAMCQ2R3tljxuItBoT1X+ujkFcIg4W88/MQXFEr+mQCmC4O32uUuiJMmxbnpZXPFb2 6xr6TimT3j8GClCewLMLTeCbvtQDjIZPfPpzApHdGpFZpWM3FKr+mLgrP3ktlvrkhZ5B MYgcBFPrHX6dBJJhk73qfkzNo2IF3zy/ruaTLEOEZc3sysKwcrQLZnJRkF0GBJnEzRg5 ER2B6CJbQwNiAaZBqEeLp94DL22q6dK+DRCgpzanq1SSJPXiousAaUyx+0vwGmSx6cX8 IQ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Th1BFHY4alYwpOs3a3dP85SQNmdi5BYceDIUrYUzNRw=; b=FD6qR7jbBYv52BuKuR/Vlzlc9PXbHZMNidcDop6JXrhGAL9VvKuuKPRdtXPa+KmKIm aGckT60eBLlEhH/Uyer00YpiTC+V057NeKjcgGrTHppEc65+1u9MLi5GPkanSVn41nG4 UbwOXq7dYqKgJTgWSQHpYd/Y2V0IyrY41h0uN43je6e8jp8AuPIFfM/ywWihho66bOe3 BzVQZOPCArwhzZ5VCLXcJPG6/z4H4WReSwGBZ0hAGUebpHpVEsNDjaxcNux8+M3jRdlq Vqsx+3cNUUM2qSHneyIbGd2MgUiSb5hCCHATWAYI4Mh2UuHaPB80lrC1JlUu06rntch6 6mNw== X-Gm-Message-State: AJaThX46CWZcu3tNOTscOq6x3x42SZrd7cQB2CEFxwnlDCO9RgJ/32qH 8cRfIwYPlY7USuQBxsnzPms2r6Yf9jR+ZQg3yD8= X-Google-Smtp-Source: AGs4zMZAqv0DKFK9h2iVRCWx7vsz6i59YHYuuBL4GFT5S4/nUx8jE273Gb004FJCu+Srj6II7Mu+8ZOmZoSXFs+sN5c= X-Received: by 10.55.15.201 with SMTP id 70mr3429882qkp.95.1510267593147; Thu, 09 Nov 2017 14:46:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.40.232 with HTTP; Thu, 9 Nov 2017 14:46:32 -0800 (PST) Received: by 10.140.40.232 with HTTP; Thu, 9 Nov 2017 14:46:32 -0800 (PST) In-Reply-To: References: From: Paul Benedict Jabines Date: Fri, 10 Nov 2017 06:46:32 +0800 Message-ID: Subject: Re: View Model has List of domain object To: users@isis.apache.org Content-Type: multipart/alternative; boundary="001a1147109867c872055d9493e0" archived-at: Thu, 09 Nov 2017 23:06:09 -0000 --001a1147109867c872055d9493e0 Content-Type: text/plain; charset="UTF-8" Nice. Thanks Dan. On 10 Nov 2017 4:01 a.m., "Dan Haywood" wrote: Hi Paul, You say in your menu you add to the collection, so I'm guessing your view model is something like: @ViewModel public class MyViewModel { private List domainObjects = new ArrayList<>(); public List getDomainObjects() { return domainObjects; } public void setDomainObjects(List domainObjects) { this.domainObjects = domainObjects; } ... } and I guess in your menu there's code like: List domainObjects = ... // whatever MyViewModel vm = new MyViewModel(); vm.setDomainObjects(someDomainObjects); return vm; If that's the case, then the reason this fails is that @ViewModel does not serialize out the state of collections, only properties. The same is true if you use @DomainObject(nature=VIEW_MODEL), or =INTERNAL_ENTITY, or =EXTERNAL_ENTITY ... it all works the same way under the covers. However, there is good news. If you instead define the view model using JAXB then the state of the collection *is* serialized out. Note though that the domain object will need to be annotated with @XmlTypeAdapter(PersistentEntityAdapter.class). For more info, see [1] HTH Dan [1] http://isis.apache.org/guides/ugfun/ugfun.html#_ugfun_ programming-model_view-models_jaxb On Thu, 9 Nov 2017 at 17:01 Paul Benedict Jabines wrote: > Hi, > > I have tried to create a view model which has a property domainObjects, > which is a List. Now, in code the Menu instantiate the View > Model and add something to the list of domain object, but when the program > runs and I call on the method on the menu, it returns the view model but > the List is empty. > I look at the simple app archetype, the HomePageViewModel's getObjects() > calls the repo and return whatever the repo returns. > > public List getObjects() { > return simpleObjectRepository.listAll(); > } > Is it not allowed to add the collection inside Menu? > Is there something I did not understand about the View Model? > > > > -- > - Paul > > < > https://www.avast.com/sig-email?utm_medium=email&utm_ source=link&utm_campaign=sig-email&utm_content=webmail > > > Virus-free. > www.avast.com > < > https://www.avast.com/sig-email?utm_medium=email&utm_ source=link&utm_campaign=sig-email&utm_content=webmail > > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > --001a1147109867c872055d9493e0--