From commits-return-19618-archive-asf-public=cust-asf.ponee.io@struts.apache.org Sat Mar 6 15:06:42 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id A2919180670 for ; Sat, 6 Mar 2021 16:06:42 +0100 (CET) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id 8E392431D6 for ; Sat, 6 Mar 2021 15:06:41 +0000 (UTC) Received: (qmail 6898 invoked by uid 500); 6 Mar 2021 15:06:41 -0000 Mailing-List: contact commits-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 commits@struts.apache.org Received: (qmail 6887 invoked by uid 99); 6 Mar 2021 15:06:40 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Mar 2021 15:06:40 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 5DDA48164E; Sat, 6 Mar 2021 15:06:40 +0000 (UTC) Date: Sat, 06 Mar 2021 15:06:40 +0000 To: "commits@struts.apache.org" Subject: [struts] 01/01: WW-5117 Moves action on top just before the tag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: lukaszlenart@apache.org In-Reply-To: <161504319994.26990.7243094141238079396@gitbox.apache.org> References: <161504319994.26990.7243094141238079396@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: struts X-Git-Refname: refs/heads/WW-5117-reorders-stack X-Git-Reftype: branch X-Git-Rev: 4afa345c659c0fe75cd3a4c01dff749dcd0e84ea X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20210306150640.5DDA48164E@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5117-reorders-stack in repository https://gitbox.apache.org/repos/asf/struts.git commit 4afa345c659c0fe75cd3a4c01dff749dcd0e84ea Author: Lukasz Lenart AuthorDate: Sat Mar 6 16:06:23 2021 +0100 WW-5117 Moves action on top just before the tag --- .../components/template/FreemarkerTemplateEngine.java | 11 ++++++++--- .../resources/template/simple/dynamic-attributes.ftl | 2 +- core/src/test/java/org/apache/struts2/TestAction.java | 12 +++++++++++- .../org/apache/struts2/views/jsp/ui/HiddenTest.java | 17 +++++++++++++++++ .../org/apache/struts2/views/jsp/ui/Hidden-3.txt | 5 +++++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java b/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java index a272697..b3cb544 100644 --- a/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java +++ b/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java @@ -64,7 +64,7 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine { public void setFreemarkerManager(FreemarkerManager mgr) { this.freemarkerManager = mgr; } - + public void renderTemplate(TemplateRenderingContext templateContext) throws Exception { // get the various items required from the stack ValueStack stack = templateContext.getStack(); @@ -144,15 +144,20 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine { } }; + LOG.debug("Puts action on the top of the stack, just before the tag"); + Object actionFromStack = stack.pop(); try { stack.push(templateContext.getTag()); + stack.push(actionFromStack); template.process(model, writer); } finally { - stack.pop(); + stack.pop(); // removes action + stack.pop(); // removes tag + stack.push(actionFromStack); // puts back action } } protected String getSuffix() { return "ftl"; } -} \ No newline at end of file +} diff --git a/core/src/main/resources/template/simple/dynamic-attributes.ftl b/core/src/main/resources/template/simple/dynamic-attributes.ftl index a6e3943..95de4b7 100644 --- a/core/src/main/resources/template/simple/dynamic-attributes.ftl +++ b/core/src/main/resources/template/simple/dynamic-attributes.ftl @@ -29,4 +29,4 @@ ${aKey}="${value?html}"<#rt/> <#rt/> -<#rt/> \ No newline at end of file +<#rt/> diff --git a/core/src/test/java/org/apache/struts2/TestAction.java b/core/src/test/java/org/apache/struts2/TestAction.java index 97fa175..35b48b3 100644 --- a/core/src/test/java/org/apache/struts2/TestAction.java +++ b/core/src/test/java/org/apache/struts2/TestAction.java @@ -49,6 +49,7 @@ public class TestAction extends ActionSupport { private List list3; private SomeEnum status = SomeEnum.COMPLETED; private Float floatNumber; + private Long id; private final Map texts = new HashMap(); @@ -213,7 +214,7 @@ public class TestAction extends ActionSupport { public void setStatus(SomeEnum status) { this.status = status; } - + public List getStatusList() { return Arrays.asList(SomeEnum.values()); } @@ -225,4 +226,13 @@ public class TestAction extends ActionSupport { public void setFloatNumber(Float floatNumber) { this.floatNumber = floatNumber; } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + } diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/HiddenTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/HiddenTest.java index 37b5303..e66fc5a 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/HiddenTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/HiddenTest.java @@ -62,6 +62,23 @@ public class HiddenTest extends AbstractUITagTest { verify(TextFieldTag.class.getResource("Hidden-2.txt")); } + public void testDynamicAttributes() throws Exception { + TestAction testAction = (TestAction) action; + testAction.setId(27357L); + + HiddenTag tag = new HiddenTag(); + tag.setPageContext(pageContext); + tag.setId("einszwei"); + tag.setName("first"); + tag.setValue("%{id}"); + tag.setDynamicAttribute("", "data-wuffmiauww", "%{id}"); + + tag.doStartTag(); + tag.doEndTag(); + + verify(TextFieldTag.class.getResource("Hidden-3.txt")); + } + /** * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag, diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Hidden-3.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Hidden-3.txt new file mode 100644 index 0000000..c02c136 --- /dev/null +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Hidden-3.txt @@ -0,0 +1,5 @@ + + + + +