You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/06/22 09:14:02 UTC

[1/4] struts git commit: Uses LocaleProvider and default TextProvider instead of evaluating expression

Repository: struts
Updated Branches:
  refs/heads/master d5e0fe920 -> cd13846e1


Uses LocaleProvider and default TextProvider instead of evaluating expression


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8dfe1785
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8dfe1785
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8dfe1785

Branch: refs/heads/master
Commit: 8dfe178585d06858eb307cfb2a1bf1995243476a
Parents: d5e0fe9
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Jun 22 10:38:12 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jun 22 11:03:41 2016 +0200

----------------------------------------------------------------------
 .../org/apache/struts2/components/I18n.java     | 38 +++++++++++---------
 1 file changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/8dfe1785/core/src/main/java/org/apache/struts2/components/I18n.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/I18n.java b/core/src/main/java/org/apache/struts2/components/I18n.java
index 4db0e07..a04840f 100644
--- a/core/src/main/java/org/apache/struts2/components/I18n.java
+++ b/core/src/main/java/org/apache/struts2/components/I18n.java
@@ -21,7 +21,13 @@
 
 package org.apache.struts2.components;
 
-import com.opensymphony.xwork2.ActionContext;
+import java.io.Writer;
+import java.util.ResourceBundle;
+
+import org.apache.struts2.views.annotations.StrutsTag;
+import org.apache.struts2.views.annotations.StrutsTagAttribute;
+import org.apache.struts2.StrutsException;
+
 import com.opensymphony.xwork2.LocaleProvider;
 import com.opensymphony.xwork2.TextProvider;
 import com.opensymphony.xwork2.TextProviderFactory;
@@ -31,13 +37,6 @@ import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.struts2.StrutsException;
-import org.apache.struts2.views.annotations.StrutsTag;
-import org.apache.struts2.views.annotations.StrutsTagAttribute;
-
-import java.io.Writer;
-import java.util.Locale;
-import java.util.ResourceBundle;
 
 /**
  * <!-- START SNIPPET: javadoc -->
@@ -92,6 +91,8 @@ public class I18n extends Component {
     protected String name;
     protected Container container;
     private TextProvider textProvider;
+    private TextProvider defaultTextProvider;
+    private LocaleProvider localeProvider;
 
     public I18n(ValueStack stack) {
         super(stack);
@@ -102,26 +103,31 @@ public class I18n extends Component {
         this.container = container;
     }
 
+    @Inject
+    public void setTextProvider(TextProvider textProvider) {
+        this.defaultTextProvider = textProvider;
+    }
+
+    @Inject
+    public void setLocaleProvider(LocaleProvider localeProvider) {
+        this.localeProvider = localeProvider;
+    }
+
     public boolean start(Writer writer) {
         boolean result = super.start(writer);
 
         try {
             String name = this.findString(this.name, "name", "Resource bundle name is required. Example: foo or foo_en");
-            ResourceBundle bundle = (ResourceBundle) findValue("getTexts('" + name + "')");
+            ResourceBundle bundle = defaultTextProvider.getTexts(name);
 
             if (bundle == null) {
-                bundle = LocalizedTextUtil.findResourceBundle(name, (Locale) getStack().getContext().get(ActionContext.LOCALE));
+                bundle = LocalizedTextUtil.findResourceBundle(name, localeProvider.getLocale());
             }
 
             if (bundle != null) {
-                final Locale locale = (Locale) getStack().getContext().get(ActionContext.LOCALE);
                 TextProviderFactory tpf = new TextProviderFactory();
                 container.inject(tpf);
-                textProvider = tpf.createInstance(bundle, new LocaleProvider() {
-                    public Locale getLocale() {
-                        return locale;
-                    }
-                });
+                textProvider = tpf.createInstance(bundle, localeProvider);
                 getStack().push(textProvider);
                 pushed = true;
             }


[3/4] struts git commit: Adds test to guard pre-evaulation of name attribute

Posted by lu...@apache.org.
Adds test to guard pre-evaulation of name attribute


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f096dd61
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f096dd61
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f096dd61

Branch: refs/heads/master
Commit: f096dd611e8f53bec0fde4a022b9c68501bcaf60
Parents: cfcefcf
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Jun 22 10:46:09 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jun 22 11:10:04 2016 +0200

----------------------------------------------------------------------
 .../apache/struts2/views/jsp/ui/TextfieldTest.java  | 16 ++++++++++++++++
 .../apache/struts2/views/jsp/ui/Textfield-14.txt    | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/f096dd61/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
index d814308..8064204 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
@@ -337,4 +337,20 @@ public class TextfieldTest extends AbstractUITagTest {
         verify(TextFieldTag.class.getResource("Textfield-11.txt"));
     }
 
+    public void testNameEvaluation() throws Exception {
+        TestAction testAction = (TestAction) action;
+        testAction.setArray(new String[]{"test", "bar"});
+        testAction.setFooInt(1);
+
+        TextFieldTag tag = new TextFieldTag();
+        tag.setPageContext(pageContext);
+        tag.setName("array[%{fooInt}]");
+
+        tag.doStartTag();
+        tag.doEndTag();
+
+        verify(TextFieldTag.class.getResource("Textfield-12.txt"));
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/f096dd61/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
new file mode 100644
index 0000000..fc43ebf
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
@@ -0,0 +1,16 @@
+<tr>
+<<<<<<< HEAD
+  <td class="tdLabel">
+    <label for="myId" class="label">
+      mylabel
+      <span class="required">*</span>:
+    </label>
+  </td>
+  <td class="tdInput">
+    <input type="text" name="foo" value="bar" id="myId"/>
+  </td>
+=======
+  <td class="tdLabel"></td>
+  <td><input type="text" name="array[1]" value="bar" id="array_1_"/></td>
+>>>>>>> c84810f... Adds test to guard pre-evaulation of name attribute
+</tr>
\ No newline at end of file


[4/4] struts git commit: Fixes test and conflicts

Posted by lu...@apache.org.
Fixes test and conflicts


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/cd13846e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/cd13846e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/cd13846e

Branch: refs/heads/master
Commit: cd13846e198fbecc45072e43ea0ea2b7d3909116
Parents: f096dd6
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Jun 22 11:10:26 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jun 22 11:10:26 2016 +0200

----------------------------------------------------------------------
 .../apache/struts2/views/jsp/ui/TextfieldTest.java    |  2 +-
 .../org/apache/struts2/views/jsp/ui/Textfield-14.txt  | 14 +-------------
 2 files changed, 2 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/cd13846e/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
index 8064204..73ad218 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
@@ -349,7 +349,7 @@ public class TextfieldTest extends AbstractUITagTest {
         tag.doStartTag();
         tag.doEndTag();
 
-        verify(TextFieldTag.class.getResource("Textfield-12.txt"));
+        verify(TextFieldTag.class.getResource("Textfield-14.txt"));
     }
 
 

http://git-wip-us.apache.org/repos/asf/struts/blob/cd13846e/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
index fc43ebf..fcb3703 100644
--- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-14.txt
@@ -1,16 +1,4 @@
 <tr>
-<<<<<<< HEAD
-  <td class="tdLabel">
-    <label for="myId" class="label">
-      mylabel
-      <span class="required">*</span>:
-    </label>
-  </td>
-  <td class="tdInput">
-    <input type="text" name="foo" value="bar" id="myId"/>
-  </td>
-=======
   <td class="tdLabel"></td>
-  <td><input type="text" name="array[1]" value="bar" id="array_1_"/></td>
->>>>>>> c84810f... Adds test to guard pre-evaulation of name attribute
+  <td class="tdInput"><input type="text" name="array[1]" value="bar" id="array_1_"/></td>
 </tr>
\ No newline at end of file


[2/4] struts git commit: Drops commented out test

Posted by lu...@apache.org.
Drops commented out test


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/cfcefcf5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/cfcefcf5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/cfcefcf5

Branch: refs/heads/master
Commit: cfcefcf5898313043ef903ce0873b15fb7cf1df4
Parents: 8dfe178
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Jun 22 10:38:39 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jun 22 11:04:07 2016 +0200

----------------------------------------------------------------------
 .../org/apache/struts2/components/UIBeanTest.java  | 17 -----------------
 1 file changed, 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/cfcefcf5/core/src/test/java/org/apache/struts2/components/UIBeanTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/components/UIBeanTest.java b/core/src/test/java/org/apache/struts2/components/UIBeanTest.java
index 470cc91..b2fc843 100644
--- a/core/src/test/java/org/apache/struts2/components/UIBeanTest.java
+++ b/core/src/test/java/org/apache/struts2/components/UIBeanTest.java
@@ -164,21 +164,4 @@ public class UIBeanTest extends StrutsInternalTestCase {
         assertEquals("12", txtFld.getTheme());
     }
 
-//    I couldn't figure out how to make this test work. Bailing for now.
-//    public void testEscapeLabel() throws Exception {
-//        ValueStack stack = ActionContext.getContext().getValueStack();
-//        MockHttpServletRequest req = new MockHttpServletRequest();
-//        MockHttpServletResponse res = new MockHttpServletResponse();
-//        stack.push(this);
-//
-//        TextField txtFld = new TextField(stack, req, res);
-//        txtFld.setKey("test['foo']");
-//        txtFld.evaluateParams();
-//        assertEquals("test_label", txtFld.getParameters().get("label"));
-//    }
-//
-//    public String getText(String key) {
-//        assertEquals("test[\\'foo\\']", key);
-//        return "test_label";
-//    }
 }