struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4713) Drop "searchValueStack" attribute from tag <s:text/>
Date Sat, 11 Nov 2017 14:04:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16248535#comment-16248535
] 

ASF GitHub Bot commented on WW-4713:
------------------------------------

sdutry closed pull request #182: WW-4713 Drop searchValueStack attribute from tag <s:text/>
URL: https://github.com/apache/struts/pull/182
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/struts2/components/Text.java b/core/src/main/java/org/apache/struts2/components/Text.java
index a5ea21715..e697dac94 100644
--- a/core/src/main/java/org/apache/struts2/components/Text.java
+++ b/core/src/main/java/org/apache/struts2/components/Text.java
@@ -49,9 +49,8 @@
  *
  * <p>
  * If the named message is not found in a property file, then the body of the
- * tag will be used as default message. If no body is used, then the stack can
- * be searched, and if a value is returned, it will written to the output.
- * If no value is found on the stack, the key of the message will be written out.
+ * tag will be used as default message. If no value is found, the key of the 
+ * message will be written out.
  * </p>
  * <!-- END SNIPPET: javadoc -->
  *
@@ -123,7 +122,6 @@
     protected List<Object> values = Collections.emptyList();
     protected String actualName;
     protected String name;
-    protected String searchStack;
     private boolean escapeHtml = false;
     private boolean escapeJavaScript = false;
     private boolean escapeXml = false;
@@ -138,11 +136,6 @@ public void setName(String name) {
         this.name = name;
     }
 
-    @StrutsTagAttribute(description="Search the stack if property is not found on resources",
type = "Boolean", defaultValue = "false")
-    public void setSearchValueStack(String searchStack) {
-        this.searchStack = searchStack;
-    }
-
     @StrutsTagAttribute(description="Whether to escape HTML", type="Boolean", defaultValue="false")
     public void setEscapeHtml(boolean escape) {
         this.escapeHtml = escape;
@@ -179,13 +172,7 @@ public boolean end(Writer writer, String body) {
             defaultMessage = actualName;
         }
 
-        Boolean doSearchStack = false;
-        if (searchStack != null) {
-            Object value = findValue(searchStack, Boolean.class);
-            doSearchStack = value != null ? (Boolean) value : false;
-        }
-
-        String msg = TextProviderHelper.getText(actualName, defaultMessage, values, getStack(),
doSearchStack);
+        String msg = TextProviderHelper.getText(actualName, defaultMessage, values, getStack());
 
         if (msg != null) {
             try {
diff --git a/core/src/main/java/org/apache/struts2/views/jsp/TextTag.java b/core/src/main/java/org/apache/struts2/views/jsp/TextTag.java
index c0420dfad..8f93ad61f 100644
--- a/core/src/main/java/org/apache/struts2/views/jsp/TextTag.java
+++ b/core/src/main/java/org/apache/struts2/views/jsp/TextTag.java
@@ -34,7 +34,6 @@
     private static final long serialVersionUID = -3075088084198264581L;
 
     protected String name;
-    protected String searchValueStack;
     private boolean escapeHtml = false;
     private boolean escapeJavaScript = false;
     private boolean escapeXml = false;
@@ -49,7 +48,6 @@ protected void populateParams() {
 
         Text text = (Text) component;
         text.setName(name);
-        text.setSearchValueStack(searchValueStack);
         text.setEscapeHtml(escapeHtml);
         text.setEscapeJavaScript(escapeJavaScript);
         text.setEscapeXml(escapeXml);
@@ -60,10 +58,6 @@ public void setName(String name) {
         this.name = name;
     }
 
-    public void setSearchValueStack(String searchStack) {
-        this.searchValueStack = searchStack;
-    }
-
     public void setEscapeHtml(boolean escapeHtml) {
         this.escapeHtml = escapeHtml;
     }
diff --git a/core/src/site/resources/tags/text.html b/core/src/site/resources/tags/text.html
index f068caddb..611774c85 100644
--- a/core/src/site/resources/tags/text.html
+++ b/core/src/site/resources/tags/text.html
@@ -74,14 +74,6 @@
 					<td align="left" valign="top">Name of resource property to fetch</td>
 				</tr>
 				<tr>
-					<td align="left" valign="top">searchValueStack</td>
-					<td align="left" valign="top">false</td>
-					<td align="left" valign="top">false</td>
-					<td align="left" valign="top">false</td>
-					<td align="left" valign="top">Boolean</td>
-					<td align="left" valign="top">Search the stack if property is not found on resources</td>
-				</tr>
-				<tr>
 					<td align="left" valign="top">var</td>
 					<td align="left" valign="top">false</td>
 					<td align="left" valign="top"></td>
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
index 856b9335b..fce231a7e 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/TextTagTest.java
@@ -215,47 +215,6 @@ public void testTextTagUsesLocaleFromValueStack() throws JspException
{
         assertEquals(value_int, writer.toString());
     }
 
-     public void testTextTagCanSearchStackToFindValue() throws JspException {
-        String key = "result";
-
-        tag.setName(key);
-        tag.setSearchValueStack("true");
-        final StringBuffer buffer = writer.getBuffer();
-        buffer.delete(0, buffer.length());
-        ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack();
-        newStack.getContext().put(ActionContext.CONTAINER, container);
-        TestAction testAction = new TestAction();
-        container.inject(testAction);
-        testAction.setResult("bar");
-        newStack.push(testAction);
-        request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, newStack);
-
-
-        tag.doStartTag();
-        tag.doEndTag();
-        assertEquals("bar", writer.toString());
-    }
-
-    public void testTextTagDoNotSearchStackByDefault() throws JspException {
-        String key = "result";
-
-        tag.setName(key);
-        final StringBuffer buffer = writer.getBuffer();
-        buffer.delete(0, buffer.length());
-        ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack();
-        newStack.getContext().put(ActionContext.CONTAINER, container);
-        TestAction testAction = new TestAction();
-        container.inject(testAction);
-        testAction.setResult("bar");
-        newStack.push(testAction);
-        request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, newStack);
-
-
-        tag.doStartTag();
-        tag.doEndTag();
-        assertEquals("result", writer.toString());
-    }
-
     public void testWithNoMessageAndBodyIsNotEmptyBodyIsReturned() throws Exception {
         final String key = "key.does.not.exist";
         final String bodyText = "body text";


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Drop "searchValueStack" attribute from tag <s:text/>
> ----------------------------------------------------
>
>                 Key: WW-4713
>                 URL: https://issues.apache.org/jira/browse/WW-4713
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Tags
>    Affects Versions: 2.5.8
>            Reporter: Lukasz Lenart
>            Assignee: Stefaan Dutry
>             Fix For: 2.6
>
>
> This attribute is only used to evaluate a {{defaultMessage}} against a ValueStack which
is useless in most cases as the {{defaultMessage}} should be a static text, not an expression.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message