Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B55218D2F for ; Thu, 30 Apr 2015 07:04:07 +0000 (UTC) Received: (qmail 61617 invoked by uid 500); 30 Apr 2015 07:04:07 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 61579 invoked by uid 500); 30 Apr 2015 07:04:07 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 61568 invoked by uid 99); 30 Apr 2015 07:04:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 07:04:07 +0000 Date: Thu, 30 Apr 2015 07:04:07 +0000 (UTC) From: "Hudson (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-4493) Still can't pass parameters with dashes to tags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-4493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521017#comment-14521017 ] Hudson commented on WW-4493: ---------------------------- SUCCESS: Integrated in Struts-JDK6-develop #148 (See [https://builds.apache.org/job/Struts-JDK6-develop/148/]) WW-4493 Allows to pass parameters witch dashes in names (lukaszlenart: rev 791364cf6d97528ec75b8859450204150d55ed5e) * core/src/main/java/org/apache/struts2/components/Component.java > Still can't pass parameters with dashes to tags > ----------------------------------------------- > > Key: WW-4493 > URL: https://issues.apache.org/jira/browse/WW-4493 > Project: Struts 2 > Issue Type: Bug > Components: Expression Language > Affects Versions: 2.3.20 > Reporter: Jasper Rosenberg > Assignee: Lukasz Lenart > Priority: Minor > Labels: freemarker, tags > Fix For: 2.3.24 > > > The latest freemarker now supports dashes in attribute names, so I can write something like: > {code:xml} > <@s.form name="sendToPhone" data\-ajax="false"> > > {code} > Unfortunately, the parameters are set using ognl internally, so it blows up with an error like: > {noformat} > Caused by: ognl.InappropriateExpressionException: Inappropriate OGNL expression: data - ajax > at ognl.SimpleNode.setValueBody(SimpleNode.java:312) > at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) > at ognl.SimpleNode.setValue(SimpleNode.java:301) > at ognl.Ognl.setValue(Ognl.java:737) > at com.opensymphony.xwork2.ognl.OgnlUtil$1.execute(OgnlUtil.java:287) > at com.opensymphony.xwork2.ognl.OgnlUtil$1.execute(OgnlUtil.java:282) > at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:340) > at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:282) > {noformat} > I think there is a simple solution, which is to send any parameters with an dash directly to the parameters map like so: > {code:title=Component.java|borderStyle=solid} > /** > * Pushes this component's parameter Map as well as the component itself on to the stack > * and then copies the supplied parameters over. Because the component's parameter Map is > * pushed before the component itself, any key-value pair that can't be assigned to component > * will be set in the parameters Map. > * > * @param params the parameters to copy. > */ > public void copyParams(Map params) { > stack.push(parameters); > stack.push(this); > try { > for (Object o : params.entrySet()) { > Map.Entry entry = (Map.Entry) o; > String key = (String) entry.getKey(); > > if (key.indexOf('-') >= 0) { > // UI component attributes may contain hypens (e.g. data-ajax), but ognl > // can't handle that, and there can't be a component property with a hypen > // so into the parameters map it goes. > parameters.put(key, entry.getValue()); > } else { > stack.setValue(key, entry.getValue()); > } > } > } finally { > stack.pop(); > stack.pop(); > } > } > {code} > Hoping this can make it into 2.3.24, thanks! -- This message was sent by Atlassian JIRA (v6.3.4#6332)