From notifications-return-4900-archive-asf-public=cust-asf.ponee.io@freemarker.incubator.apache.org Thu Jan 18 11:11:07 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 6031F180654 for ; Thu, 18 Jan 2018 11:11:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4FDC4160C36; Thu, 18 Jan 2018 10:11:07 +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 932E4160C2B for ; Thu, 18 Jan 2018 11:11:06 +0100 (CET) Received: (qmail 91267 invoked by uid 500); 18 Jan 2018 10:11:05 -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 91258 invoked by uid 99); 18 Jan 2018 10:11:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jan 2018 10:11:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 5F9961808C2 for ; Thu, 18 Jan 2018 10:11:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -107.911 X-Spam-Level: X-Spam-Status: No, score=-107.911 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id bMW3pBCUrbSG for ; Thu, 18 Jan 2018 10:11:03 +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 89E135F6C2 for ; Thu, 18 Jan 2018 10:11:02 +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 C1740E0DF8 for ; Thu, 18 Jan 2018 10:11:01 +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 0E33021310 for ; Thu, 18 Jan 2018 10:11:01 +0000 (UTC) Date: Thu, 18 Jan 2018 10:11:01 +0000 (UTC) From: "Daniel Dekany (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (FREEMARKER-87) <#list map as key,value> should always iterating on map entries MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Auto-Submitted: auto-generated [ https://issues.apache.org/jira/browse/FREEMARKER-87?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1= 6330335#comment-16330335 ]=20 Daniel Dekany edited comment on FREEMARKER-87 at 1/18/18 10:10 AM: ------------------------------------------------------------------- The template=C2=A0language constructs (such as the {{#list}}=C2=A0directive= ) don't look inside {{TemplateModel}}-s, that is,=C2=A0they don't want to k= now what have you wrapped into the model. They only depend on the {{Templat= eModel}}=C2=A0interfaces. That's also why something that's not a {{Map}}, l= ike a usual JavaBean or a DOM {{Node}}=C2=A0can be treated similarly=C2=A0a= s a=C2=A0{{Map}}=C2=A0in templates, despite that the template language cons= tructs aren't aware of those concepts (JavaBeans, {{Node}}-s, etc.). So, if you don't want to expose the methods like map entries, then=C2=A0don= 't use such a model, like {{MapModel}}. {{DefaultObjectWrapper}}=C2=A0(whic= h is what FreeMarker uses by default) doesn't do that. Using pure {{BeansWr= apper}} is not recommended, but if you have to use that, then you can still= set its {{simpleMapWrapper}}=C2=A0property to {{true}} to avoid exposing m= ethods like that. But again, it's recommended to use {{DefaultObjectWrapper= }}=C2=A0(with {{incompatibleImprovements}}=C2=A0set to some high value, lik= e 2.3.27 as of this writing). However, I'm not sure what's compatible with = Strut's FreeMarker libraries. That the behavior of {{MapModel}} is still isn't practical... yeah. Just do= n't use it. It can't be fixed, as that breaks backward compatibility. was (Author: ddekany): The template=C2=A0language constructs (such as the {{#list}}=C2=A0directive= ) don't look inside {{TemplateModel}}-s, that is,=C2=A0they don't want to k= now what have you wrapped into the model. They only depend on the {{Templat= eModel}}=C2=A0interfaces. That's also why something that's not a {{Map}}, l= ike a usual JavaBean or a DOM {{Node}}=C2=A0can be treated similarly=C2=A0a= s a=C2=A0{{Map}}=C2=A0in templates, despite that the template language cons= tructs aren't aware of those concepts (JavaBeans, {{Node}}-s, etc.). So, if you don't want to expose the methods like map entries, then=C2=A0don= 't use such a model, like {{MapModel}}. {{DefaultObjectWrapper}}=C2=A0(whic= h is what FreeMarker uses by default) doesn't do that. Using pure {{BeansWr= apper=C2=A0}}is not recommended, but if you have to use that, then you can = still set its {{simpleMapWrapper}}=C2=A0property to {{true}} to avoid expos= ing methods like that. But again, it's recommended to use {{DefaultObjectWr= apper}}=C2=A0(with {{incompatibleImprovements}}=C2=A0set to some high value= , like 2.3.27 as of this writing). However, I'm not sure what's compatible = with Strut's FreeMarker libraries. That the behavior of {{MapModel}} is still isn't practical... yeah. Just do= n't use it. It can't be fixed, as that breaks backward compatibility. > <#list map as key,value> should always iterating on map entries > --------------------------------------------------------------- > > Key: FREEMARKER-87 > URL: https://issues.apache.org/jira/browse/FREEMARKER-87 > Project: Apache Freemarker > Issue Type: Bug > Components: engine > Affects Versions: 2.3.27-incubating > Reporter: Yanming Zhou > Priority: Major > Attachments: MapIteratingTest.java > > > I'm using struts2, use FriendlyMapModel instead of default=C2=A0MapModel,= It works fine except map have key such as "size",=C2=A0the value will be u= nexpected SimpleMethodModel, I think freemarker should always use entry val= ue=C2=A0for directive=C2=A0<#list map as key,value>, not matter how=C2=A0Ma= pModel works,=C2=A0MapModel should only affect map.size and map.get('size')= . > I attached a test case. > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)