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 836F2200C2B for ; Thu, 16 Feb 2017 01:11:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 81E51160B70; Thu, 16 Feb 2017 00:11:46 +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 CB7F5160B5E for ; Thu, 16 Feb 2017 01:11:45 +0100 (CET) Received: (qmail 59150 invoked by uid 500); 16 Feb 2017 00:11:45 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 59141 invoked by uid 99); 16 Feb 2017 00:11:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 00:11:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 75487C144F for ; Thu, 16 Feb 2017 00:11:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id BMoebTPGLPSt for ; Thu, 16 Feb 2017 00:11:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 1ED6D5FD84 for ; Thu, 16 Feb 2017 00:11:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 80944E0655 for ; Thu, 16 Feb 2017 00:11:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id C5B8024121 for ; Thu, 16 Feb 2017 00:11:41 +0000 (UTC) Date: Thu, 16 Feb 2017 00:11:41 +0000 (UTC) From: "Daniel Dekany (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FREEMARKER-45) Support properties of classes that extend collections MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 16 Feb 2017 00:11:46 -0000 [ https://issues.apache.org/jira/browse/FREEMARKER-45?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1= 5868846#comment-15868846 ]=20 Daniel Dekany commented on FREEMARKER-45: ----------------------------------------- Currently, the best you can do is using `?api`: {{myinstance?api.myProperty= }}. See: http://freemarker.org/docs/ref_builtins_expert.html#ref_buitin_api= _and_has_api Note that this kind of issue exists both for {{List}}-s and {{Map}}-s. For = a {{Map}}, it would be impossible to tell if by {{myinstance.myProperty}} y= ou mean Java {{myinstance.getMyProperty()}} or Java {{myinstance.get("myPro= perty")}}. It's true that for {{List}}-s we could say that if the key is no= t a number, then it must be something else than a {{List}} item index. (Not= e that {{foo.bar}} and {{foo['bar']}} are equivalent in FTL, hence I said "= key".) Actually, a value can be multi-type in FTL, like be both a FTL seque= nce and an FTL hash, which is kind of what you ask for, but multi-types usi= ng have some confusing consequences too (plus we had to decide what Java AP= I-s to expose that way). So at least in the existing "type system" of FreeM= arker 2 I don't see a better compromise, than keeping wrapped {{List}}-s as= clean (single-typed) FTL sequences, and in the quite rare cases when someo= ne has a custom {{List}} class that has some application domain properties = that he need to access, one can still use {{?api}}. (We will see what to do= with this in FreeMarker 3 though... perhaps we should allow named members = regardless of type.) > Support properties of classes that extend collections > ----------------------------------------------------- > > Key: FREEMARKER-45 > URL: https://issues.apache.org/jira/browse/FREEMARKER-45 > Project: Apache Freemarker > Issue Type: Improvement > Reporter: Alexander Hars > > Currently Freemarker wraps classes that extend a collection using special= ized adapters (for example if MyClass extends java.util.List then this clas= s is wrapped using the DefaultListAdapter). This has the effect that all no= n-list properties of MyClass are inaccessible for use in the template.=20 > Assume that MyClass has a method getMyProperty and a MyClass instance is = added to the data model using the hash ''myinstance', then the template > ${myinstance.MyProperty} leads to the following error message:=20 > FreeMarker template error: > For "." left-hand operand: Expected a hash, but this has evaluated to a s= equence (MyClass wrapped into f.t.DefaultListAdapter): > Freemarker needs to expose the non collection-related properties in the s= ame way as it would on a simple object that does not extend a collection. S= upport for collections should not come at the expense of features that are = already available for plain objects. -- This message was sent by Atlassian JIRA (v6.3.15#6346)