Commits

plightbo  committed fc2372a

whoa nelly -- lots of changes:
* start of switching UI tag attributes all over to being evaluated
* start of switching all UI tag attributes to being added in the params Map
* made all tests pass (again) in a single suite

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

  • Participants
  • Parent commits bb9b684

Comments (0)

Files changed (22)

 <caucho.com>
 
-    <java compiler='/jdk1.4.1/bin/jikes' compiler-args='-g'/>
-
     <log id='/log' href='stderr:' timestamp='[%Y-%m-%d %H:%M:%S.%s]'/>
 
     <http-server error-log='build/resin-error.log'>

File src/etc/example/xwork.xml

 <xwork>
 
     <include file="webwork-default.xml"/>
-    <include file="config-browser.xml"/>
 
     <package name="default" extends="webwork-default">
 

File src/java/com/opensymphony/webwork/views/jsp/ui/AbstractClosingUITag.java

 public abstract class AbstractClosingUITag extends AbstractUITag {
     //~ Static fields/initializers /////////////////////////////////////////////
 
-    private static final Log log = LogFactory.getLog(AbstractClosingUITag.class);
+    private static final Log LOG = LogFactory.getLog(AbstractClosingUITag.class);
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
             String openTemplateName = buildTemplateName(getOpenTemplate(), getDefaultOpenTemplate());
             mergeTemplate(openTemplateName);
         } catch (Exception e) {
-            log.error("Could not open template", e);
+            LOG.error("Could not open template", e);
 
             return SKIP_PAGE;
         }

File src/java/com/opensymphony/webwork/views/jsp/ui/AbstractDoubleListTag.java

         return doubleName;
     }
 
-    public Object DoubleList(String list) {
-        setDoubleList(list);
-
-        return this;
-    }
-
-    public Object DoubleListKey(String listKey) {
-        setDoubleListKey(listKey);
-
-        return this;
-    }
-
-    public Object DoubleListValue(Object listValue) {
-        this.setDoubleListValue(listValue);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param name
-     */
-    public Object DoubleName(Object doubleName) {
-        setDoubleName(doubleName);
-
-        return this;
-    }
-
     /**
      * Clears all the instance variables to allow this instance to be reused.
      */

File src/java/com/opensymphony/webwork/views/jsp/ui/AbstractListTag.java

         return listValue;
     }
 
-    public Object List(String list) {
-        setList(list);
-
-        return this;
-    }
-
-    public Object ListKey(String listKey) {
-        setListKey(listKey);
-
-        return this;
-    }
-
-    public Object ListValue(Object listValue) {
-        this.setListValue(listValue);
-
-        return this;
-    }
-
     public boolean contains(Object obj1, Object obj2) {
         if ((obj1 == null) || (obj2 == null)) {
             return false;
     }
 
     /**
-* Clears all the instance variables to allow this instance to be reused.
-*/
+     * Clears all the instance variables to allow this instance to be reused.
+     */
     public void release() {
         super.release();
         this.list = null;

File src/java/com/opensymphony/webwork/views/jsp/ui/AbstractUITag.java

 
     //~ Instance fields ////////////////////////////////////////////////////////
 
-    Map params;
-    Object actualValue;
-    Object name;
-    Object value;
+    Map params = new HashMap();
     String id;
-    String label;
-    String onchange;
     String template;
     String theme;
     Writer writer;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public Object getActualValue() {
-        return actualValue;
-    }
 
     public void setId(String id) {
         this.id = id;
     }
 
     public void setLabel(String label) {
-        this.label = label;
-    }
-
-    public String getLabel() {
-        return label;
+        params.put("label", label);
     }
 
     public void setName(Object name) {
-        this.name = name;
-    }
-
-    public Object getName() {
-        return name;
+        params.put("name", name);
     }
 
     public void setOnchange(String onchange) {
-        this.onchange = onchange;
-    }
-
-    public String getOnchange() {
-        return onchange;
+        params.put("onchange", onchange);
     }
 
-    public void setOut(Writer writer) {
-        this.writer = writer;
-    }
 
     /**
      * com.opensymphony.webwork.views.jsp.ParameterizedTag implementation
      * @see ParameterizedTag
      */
     public Map getParams() {
-        if (params == null) {
-            params = new HashMap();
-        }
-
         return params;
     }
 
         return required;
     }
 
-    /**
-     * for Velocity
-     * @return
-     * @throws JspException
-     */
-    public String getShow() throws JspException {
-        int result = doStartTag();
-        doEndTag();
-
-        return "";
-    }
-
     public void setTemplate(String template) {
         this.template = template;
     }
     }
 
     public void setValue(Object value) {
-        this.value = value;
-    }
-
-    public Object getValue() {
-        return value;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param id
-     */
-    public Object Id(String id) {
-        setId(id);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param label
-     */
-    public Object Label(String label) {
-        setLabel(label);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param name
-     */
-    public Object Name(Object name) {
-        setName(name);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param onchange
-     */
-    public Object Onchange(String onchange) {
-        setOnchange(onchange);
-
-        return this;
-    }
-
-    public Object Param(String key, Object value) {
-        this.addParam(key, value);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param required whether or not this tag is required
-     */
-    public Object Required(boolean required) {
-        setRequired(required);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param template
-     */
-    public Object Template(String template) {
-        setTemplate(template);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param theme
-     */
-    public Object Theme(String theme) {
-        setTheme(theme);
-
-        return this;
-    }
-
-    /**
-     * simple setter method for Velocity
-     * @param value
-     */
-    public Object Value(Object value) {
-        setValue(value);
-
-        return this;
+        params.put("value", value);
     }
 
     /**
 
             return EVAL_BODY_INCLUDE;
         } catch (Exception e) {
-            e.printStackTrace();
+            LOG.error("Could npt generate UI template", e);
 
             return SKIP_BODY;
         } finally {
-            this.params = null;
-            this.id = null;
-            this.label = null;
-            this.name = null;
-            this.onchange = null;
-            this.theme = null;
-            this.template = null;
-            this.value = null;
-            this.actualValue = null;
+            nullifyVars();
         }
     }
 
      */
     public void release() {
         super.release();
+        nullifyVars();
+    }
+
+    private void nullifyVars() {
         this.params = null;
         this.id = null;
-        this.label = null;
         this.required = false;
-        this.name = null;
-        this.onchange = null;
         this.theme = null;
         this.template = null;
-        this.value = null;
-        this.actualValue = null;
     }
 
     public void render(Context context, Writer writer) throws Exception {
-        OgnlValueStack stack = ActionContext.getContext().getValueStack();
-
-        if (stack != null) {
-            if (value != null) {
-                actualValue = stack.findValue(value.toString());
-            } else if (name != null) {
-                actualValue = stack.findValue(name.toString());
-            }
-        }
+        evaluateActualValue();
 
         Template template = velocityEngine.getTemplate(this.getTemplateName());
         template.merge(context, writer);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @return
-     * @throws JspException
-     */
     public Object set(String label) throws JspException {
         return this.set(label, null, null, null, null, null, null);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @param name
-     * @return
-     * @throws JspException
-     */
     public Object set(String label, Object name) throws JspException {
         return this.set(label, name, null, null, null, null, null);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @param name
-     * @param value
-     * @return
-     * @throws JspException
-     */
     public Object set(String label, Object name, Object value) throws JspException {
         return this.set(label, name, value, null, null, null, null);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @param name
-     * @param value
-     * @param id
-     * @return
-     * @throws JspException
-     */
     public Object set(String label, Object name, Object value, String id) throws JspException {
         return this.set(label, name, value, id, null, null, null);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @param name
-     * @param value
-     * @param id
-     * @param onchange
-     * @return
-     * @throws JspException
-     */
     public Object set(String label, Object name, Object value, String id, String onchange) throws JspException {
         return this.set(label, name, value, id, onchange, null, null);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @param name
-     * @param value
-     * @param id
-     * @param onchange
-     * @param template
-     * @return
-     * @throws JspException
-     */
     public Object set(String label, Object name, Object value, String id, String onchange, String template) throws JspException {
         return this.set(label, name, value, id, onchange, template, null);
     }
 
-    /**
-     * For Velocity
-     * @param label
-     * @param name
-     * @param value
-     * @param id
-     * @param onchange
-     * @param template
-     * @param theme
-     * @return
-     * @throws JspException
-     */
     public Object set(String label, Object name, Object value, String id, String onchange, String template, String theme) throws JspException {
         this.setLabel(label);
         this.setName(name);
      * already been set
      */
     protected void evaluateActualValue() {
-        if (this.actualValue != null) {
-            return;
-        }
-
-        OgnlValueStack stack = ActionContext.getContext().getValueStack();
-
-        if (stack != null) {
-            if (value != null) {
-                actualValue = stack.findValue(value.toString());
-            } else if (name != null) {
-                actualValue = stack.findValue(name.toString());
-            }
-        }
     }
 
     protected void mergeTemplate(String templateName) throws Exception {
         Context context = VelocityManager.createContext(pageContext.getServletConfig(), pageContext.getRequest(), pageContext.getResponse());
 
         Writer outputWriter = writer;
-        if( outputWriter == null ) {
+        if (outputWriter == null) {
             outputWriter = pageContext.getOut();
         }
 

File src/java/com/opensymphony/webwork/views/jsp/ui/DoubleSelectTag.java

         return size;
     }
 
-    public Object Multiple(boolean multiple) {
-        setMultiple(multiple);
-
-        return this;
-    }
-
-    public Object Size(int size) {
-        setSize(size);
-
-        return this;
-    }
-
     /**
      * Clears all the instance variables to allow this instance to be reused.
      */

File src/java/com/opensymphony/webwork/views/jsp/ui/FileTag.java

         return size;
     }
 
-    public Object Accept(String accept) {
-        this.accept = accept;
-
-        return this;
-    }
-
-    public Object Size(int size) {
-        this.size = size;
-
-        return this;
-    }
-
     /**
      * Clears all the instance variables to allow this instance to be reused.
      */

File src/java/com/opensymphony/webwork/views/jsp/ui/PasswordTag.java

         return size;
     }
 
-    public Object Size(int size) {
-        this.size = size;
-
-        return this;
-    }
-
     /**
      * Clears all the instance variables to allow this instance to be reused.
      */

File src/java/com/opensymphony/webwork/views/jsp/ui/SelectTag.java

         return size;
     }
 
-    public Object Multiple(boolean multiple) {
-        setMultiple(multiple);
-
-        return this;
-    }
-
-    public Object Size(int size) {
-        setSize(size);
-
-        return this;
-    }
-
     /**
      * Clears all the instance variables to allow this instance to be reused.
      */

File src/java/com/opensymphony/webwork/views/jsp/ui/SubmitTag.java

         return align;
     }
 
-    public Object Align(String align) {
-        setAlign(align);
-
-        return this;
-    }
-
     protected String getDefaultTemplate() {
         return TEMPLATE;
     }

File src/java/com/opensymphony/webwork/views/jsp/ui/TextFieldTag.java

         return size;
     }
 
-    public Object Size(int size) {
-        this.size = size;
-
-        return this;
-    }
-
     /**
      * Clears all the instance variables to allow this instance to be reused.
      */

File src/java/com/opensymphony/webwork/views/jsp/ui/TextareaTag.java

         return rows;
     }
 
-    public Object Cols(int cols) {
-        setCols(cols);
-
-        return this;
-    }
-
-    public Object Rows(int rows) {
-        setRows(rows);
-
-        return this;
-    }
-
     protected String getDefaultTemplate() {
         return TEMPLATE;
     }

File src/java/com/opensymphony/webwork/views/jsp/ui/TokenTag.java

     }
 
     /**
-* First looks for the token in the PageContext using the supplied name (or {@link TokenHelper#DEFAULT_TOKEN_NAME}
-* if no name is provided) so that the same token can be re-used for the scope of a request for the same name. If
-* the token is not in the PageContext, a new Token is created and set into the Session and the PageContext with
-* the name.
-* @return
-* @throws JspException
-*/
+     * First looks for the token in the PageContext using the supplied name (or {@link TokenHelper#DEFAULT_TOKEN_NAME}
+     * if no name is provided) so that the same token can be re-used for the scope of a request for the same name. If
+     * the token is not in the PageContext, a new Token is created and set into the Session and the PageContext with
+     * the name.
+     * @return
+     * @throws JspException
+     */
     public int doEndTag() throws JspException {
-        if (name == null) {
-            name = TokenHelper.DEFAULT_TOKEN_NAME;
-        }
+        //if (name == null) {
+        //    name = TokenHelper.DEFAULT_TOKEN_NAME;
+        //}
 
-        token = buildToken(name.toString());
+        //token = buildToken(name.toString());
 
         return super.doEndTag();
     }
 
     /**
-* Clears all the instance variables to allow this instance to be reused.
-*/
+     * Clears all the instance variables to allow this instance to be reused.
+     */
     public void release() {
         super.release();
         token = null;
-        name = null;
+        //name = null;
     }
 
     public void render(Context context, Writer writer) throws Exception {
-        if (name == null) {
-            name = TokenHelper.DEFAULT_TOKEN_NAME;
-        }
+        //if (name == null) {
+        //    name = TokenHelper.DEFAULT_TOKEN_NAME;
+        //}
 
-        token = buildTokenForVelocity(context, name.toString());
+        //token = buildTokenForVelocity(context, name.toString());
 
         super.render(context, writer);
     }
     }
 
     /**
-* This method checks to see if a HttpSession object exists in the context. If a session
-* doesn't exist, it creates a new one and adds it to the context.
-*/
+     * This method checks to see if a HttpSession object exists in the context. If a session
+     * doesn't exist, it creates a new one and adds it to the context.
+     */
     private void verifySession() {
         Map session = ServletActionContext.getContext().getSession();
 

File src/java/templates/xhtml/controlheader.vm

   </tr>
   #end
 #end
-#set( $labelValue = $stack.findValue("getText('$tag.Label')") )
-#if( !$labelValue )
-#set( $labelValue = $tag.Label )
-#end
 <tr>
-  <td align="right" valign="top"#if($error) class="error"#end><label class="label">$!{labelValue}:</label></td>
+  <td align="right" valign="top"#if($error) class="error"#end><label class="label">$stack.findValue(${tag.params.get('label')}):</label></td>
   <td#if($error) class="error"#end>
 

File src/java/templates/xhtml/label.vm

 #parse( "/templates/xhtml/controlheader.vm" )
-$!{tag.ActualValue}
+$!{tag.params.get('name')}
 #parse( "/templates/xhtml/controlfooter.vm" )

File src/test/com/opensymphony/webwork/dispatcher/VelocityResultTest.java

         namespace = "/html";
         result = new VelocityResult();
         stack = new OgnlValueStack();
+        ActionContext.getContext().setValueStack(stack);
         velocity = new TestVelocityEngine();
         mockActionProxy = new Mock(ActionProxy.class);
         mockActionProxy.expectAndReturn("getNamespace", "/html");

File src/test/com/opensymphony/webwork/util/InvocationSessionStoreTest.java

     }
 
     protected void setUp() throws Exception {
-        ActionContext actionContext = ActionContext.getContext();
+        stack = new OgnlValueStack();
+        ActionContext actionContext = new ActionContext(stack.getContext());
+        ActionContext.setContext(actionContext);
+
         session = new HashMap();
         actionContext.setSession(session);
 
         invocationMock = new Mock(ActionInvocation.class);
         invocation = (ActionInvocation) invocationMock.proxy();
 
-        stack = new OgnlValueStack();
         actionContext.setValueStack(stack);
         invocationMock.matchAndReturn("getStack", stack);
 

File src/test/com/opensymphony/webwork/util/TokenHelperTest.java

 package com.opensymphony.webwork.util;
 
 import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.util.OgnlValueStack;
 
 import junit.framework.TestCase;
 
         ActionContext.getContext().setParameters(params);
         assertTrue(TokenHelper.validToken());
     }
+
+    protected void setUp() throws Exception {
+        OgnlValueStack stack = new OgnlValueStack();
+        ActionContext actionContext = new ActionContext(stack.getContext());
+        ActionContext.setContext(actionContext);
+    }
 }

File src/test/com/opensymphony/webwork/views/jsp/IteratorTagTest.java

         // create the mock http servlet request
         MockHttpServletRequest request = new MockHttpServletRequest();
         ActionContext.getContext().setValueStack(stack);
+        request.setupGetAttribute(stack);
 
         // create the mock page context
         MockPageContext pageContext = new MockPageContext();

File src/test/com/opensymphony/webwork/views/jsp/PropertyTagTest.java

  */
 public class PropertyTagTest extends TestCase {
     //~ Methods ////////////////////////////////////////////////////////////////
+    OgnlValueStack stack = new OgnlValueStack();
+    MockHttpServletRequest request = new MockHttpServletRequest();
+
+    protected void setUp() throws Exception {
+        ActionContext.getContext().setValueStack(stack);
+        request.setupGetAttribute(stack);
+    }
 
     public void testDefaultValue() {
         PropertyTag tag = new PropertyTag();
 
         Foo foo = new Foo();
 
-        OgnlValueStack stack = new OgnlValueStack();
         stack.push(foo);
 
-        MockHttpServletRequest request = new MockHttpServletRequest();
-        ActionContext.getContext().setValueStack(stack);
-
         MockJspWriter jspWriter = new MockJspWriter();
         jspWriter.setExpectedData("TEST");
 
 
         Foo foo = new Foo();
 
-        OgnlValueStack stack = new OgnlValueStack();
         stack.push(foo);
 
-        MockHttpServletRequest request = new MockHttpServletRequest();
-        ActionContext.getContext().setValueStack(stack);
-
         MockJspWriter jspWriter = new MockJspWriter();
         jspWriter.setExpectedData("");
 
         Foo foo = new Foo();
         foo.setTitle("test");
 
-        OgnlValueStack stack = new OgnlValueStack();
         stack.push(foo);
 
-        MockHttpServletRequest request = new MockHttpServletRequest();
-        ActionContext.getContext().setValueStack(stack);
-
         MockJspWriter jspWriter = new MockJspWriter();
         jspWriter.setExpectedData("test");
 
         Foo foo = new Foo();
         foo.setTitle("test");
 
-        OgnlValueStack stack = new OgnlValueStack();
         stack.push(foo);
 
-        MockHttpServletRequest request = new MockHttpServletRequest();
-        ActionContext.getContext().setValueStack(stack);
-
         MockJspWriter jspWriter = new MockJspWriter();
         jspWriter.setExpectedData("Foo is: test");
 

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

 
         LabelTag tag = new LabelTag();
         tag.setPageContext(pageContext);
-        tag.setLabel("mylabel");
-        tag.setName("myname");
+        tag.setLabel("'mylabel'");
+        tag.setName("'myname'");
         tag.setValue("foo");
 
         int result = tag.doEndTag();