1. opensymphony
  2. webwork

Commits

plightbo  committed ad6ca18

token tag passes, w00t w00t

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

  • Participants
  • Parent commits c603753
  • Branches master

Comments (0)

Files changed (3)

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

View file
  • Ignore whitespace
         return EVAL_BODY_INCLUDE;
     }
 
-    public void render(Context context, Writer writer) throws Exception {
-        Template template = velocityEngine.getTemplate(this.getTemplateName());
-        template.merge(context, writer);
-    }
-
     /**
      * A contract that requires each concrete UI Tag to specify which template should be used as a default.  For
      * example, the CheckboxTab might return "checkbox.vm" while the RadioTag might return "radio.vm".  This value

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

View file
  • Ignore whitespace
 
     final public static String TEMPLATE = "token.vm";
 
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    String token;
-
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public String getToken() {
-        return token;
-    }
-
     public String getTokenNameField() {
         return TokenHelper.TOKEN_NAME_FIELD;
     }
      * @throws JspException
      */
     public int doEndTag() throws JspException {
-        //if (name == null) {
-        //    name = TokenHelper.DEFAULT_TOKEN_NAME;
-        //}
+        if (nameAttr == null) {
+            nameAttr = TokenHelper.DEFAULT_TOKEN_NAME;
+        }
 
-        //token = buildToken(name.toString());
+        String token = buildToken(nameAttr.toString());
+        addParam("token", token);
 
         return super.doEndTag();
     }
 
-    /**
-     * Clears all the instance variables to allow this instance to be reused.
-     */
-    public void release() {
-        super.release();
-        token = null;
-        //name = null;
-    }
-
-    public void render(Context context, Writer writer) throws Exception {
-        //if (name == null) {
-        //    name = TokenHelper.DEFAULT_TOKEN_NAME;
-        //}
-
-        //token = buildTokenForVelocity(context, name.toString());
-
-        super.render(context, writer);
-    }
-
     protected String getDefaultTemplate() {
         return TEMPLATE;
     }
         return myToken.toString();
     }
 
-    private String buildTokenForVelocity(Context context, String name) {
-        Object myToken = context.get(name);
-
-        if (myToken == null) {
-            verifySession();
-            ;
-            myToken = TokenHelper.setToken(name.toString());
-            context.put(name, myToken);
-        }
-
-        return myToken.toString();
-    }
-
     /**
      * 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.

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

View file
  • Ignore whitespace
-<input type="hidden" name="${tag.tokenNameField}" value="${tag.name}"/>
-<input type="hidden" name="${tag.name}" value="${tag.token}"/>
+<input type="hidden" name="${tag.tokenNameField}" value="$parameters.name"/>
+<input type="hidden" name="$parameters.name" value="$parameters.token"/>