Commits

jcarreira  committed 87a076e

One more change to make the TextProviderSupport use the Locale in the value stack if it's passed in.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@628573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 8245b5e

Comments (0)

Files changed (5)

File lib/core/xwork.jar

Binary file modified.

File src/test/com/opensymphony/webwork/views/jsp/ui/TestAction1.java

+/*
+ * Copyright (c) 2004 Opensymphony. All Rights Reserved.
+ */
+package com.opensymphony.webwork.views.jsp.ui;
+
+import com.opensymphony.xwork.ActionSupport;
+
+/**
+ * TestAction1
+ *
+ * @author Jason Carreira <jcarreira@eplus.com>
+ */
+public class TestAction1 extends ActionSupport {
+}

File src/test/com/opensymphony/webwork/views/jsp/ui/TestAction1.properties

+simpleKey=This is TestBean1

File src/test/com/opensymphony/webwork/views/jsp/ui/TestAction1_de.properties

+simpleKey=This is TestBean1 in German

File src/test/com/opensymphony/webwork/views/jsp/ui/TextTagTest.java

 package com.opensymphony.webwork.views.jsp.ui;
 
 import com.opensymphony.webwork.TestAction;
+import com.opensymphony.webwork.ServletActionContext;
 import com.opensymphony.webwork.views.jsp.AbstractTagTest;
 import com.opensymphony.xwork.Action;
 import com.opensymphony.xwork.ActionContext;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 
 
 /**
         assertEquals(value, writer.toString());
     }
 
+    public void testTextTagUsesValueStackInRequestNotActionContext() throws JspException {
+        String key = "'simpleKey'";
+        String value1 = "Simple Message";
+        String value2="This is TestBean1";
+        tag.setName(key);
+        assertEquals(Tag.EVAL_PAGE, tag.doEndTag());
+        assertEquals(value1, writer.toString());
+        final StringBuffer buffer = writer.getBuffer();
+        buffer.delete(0,buffer.length());
+        OgnlValueStack newStack = new OgnlValueStack();
+        newStack.getContext().put(ActionContext.LOCALE,Locale.US);
+        newStack.push(new TestAction1());
+        request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, newStack);
+        assertNotSame(ActionContext.getContext().getValueStack().peek(),newStack.peek());
+
+        assertEquals(Tag.EVAL_PAGE, tag.doEndTag());
+        assertEquals(value2, writer.toString());
+    }
+
+    public void testTextTagUsesLocaleFromValueStack() throws JspException {
+        stack.pop();
+        stack.push(new TestAction1());
+        ActionContext.getContext().setLocale(Locale.US);
+        String key = "'simpleKey'";
+        String value_en="This is TestBean1";
+        tag.setName(key);
+        assertEquals(Tag.EVAL_PAGE, tag.doEndTag());
+        assertEquals(value_en, writer.toString());
+        final StringBuffer buffer = writer.getBuffer();
+        buffer.delete(0,buffer.length());
+        String value_de="This is TestBean1 in German";
+        OgnlValueStack newStack = new OgnlValueStack(stack);
+        newStack.getContext().put(ActionContext.LOCALE,Locale.GERMANY);
+        assertNotSame(newStack.getContext().get(ActionContext.LOCALE),ActionContext.getContext().getLocale());
+        request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, newStack);
+        assertEquals(ActionContext.getContext().getValueStack().peek(),newStack.peek());
+        assertEquals(Tag.EVAL_PAGE, tag.doEndTag());
+        assertEquals(value_de, writer.toString());
+    }
+
     public void testWithNoMessageAndBodyIsNotEmptyBodyIsReturned() throws Exception {
         final String key = "'key.does.not.exist'";
         final String bodyText = "body text";