From 43d1be37746d00a5e438e793c68431c52627fee0 Mon Sep 17 00:00:00 2001 From: James Holmes Date: Tue, 27 May 2008 14:42:46 +0000 Subject: [PATCH] Update hidden tag to support being disabled per WW-2566. Thanks to Jelmer Kuperus for the patch. I added a unit test as well. git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@660539 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/resources/template/simple/hidden.ftl | 3 +++ core/src/site/resources/tags/hidden.html | 2 +- .../apache/struts2/views/jsp/ui/HiddenTest.java | 17 +++++++++++++++++ .../apache/struts2/views/jsp/ui/Hidden-2.txt | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 core/src/test/resources/org/apache/struts2/views/jsp/ui/Hidden-2.txt diff --git a/core/src/main/resources/template/simple/hidden.ftl b/core/src/main/resources/template/simple/hidden.ftl index e22eda75e..3a6d38f2a 100644 --- a/core/src/main/resources/template/simple/hidden.ftl +++ b/core/src/main/resources/template/simple/hidden.ftl @@ -34,5 +34,8 @@ <#if parameters.cssStyle?exists> style="${parameters.cssStyle?html}"<#rt/> +<#if parameters.disabled?default(false)> + disabled="disabled"<#rt/> + <#include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" /> /> \ No newline at end of file diff --git a/core/src/site/resources/tags/hidden.html b/core/src/site/resources/tags/hidden.html index 3e3b7c563..0239180fc 100644 --- a/core/src/site/resources/tags/hidden.html +++ b/core/src/site/resources/tags/hidden.html @@ -113,7 +113,7 @@ Please do not edit it directly. : false String - String that will be appended to the labe + String that will be appended to the label labelposition 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 9406da834..ea34dcce3 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 @@ -48,6 +48,23 @@ public class HiddenTest extends AbstractUITagTest { verify(TextFieldTag.class.getResource("Hidden-1.txt")); } + public void testDisabled() throws Exception { + TestAction testAction = (TestAction) action; + testAction.setFoo("bar"); + + HiddenTag tag = new HiddenTag(); + tag.setPageContext(pageContext); + tag.setLabel("mylabel"); + tag.setName("myname"); + tag.setValue("%{foo}"); + tag.setDisabled("true"); + + tag.doStartTag(); + tag.doEndTag(); + + verify(TextFieldTag.class.getResource("Hidden-2.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-2.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Hidden-2.txt new file mode 100644 index 000000000..2cc5ab6c7 --- /dev/null +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Hidden-2.txt @@ -0,0 +1 @@ +