Commits

Anonymous committed b4c5d92

WW-1038: velocity and FM support for new tags

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

Comments (0)

Files changed (11)

src/java/com/opensymphony/webwork/components/ActionError.java

  */
 package com.opensymphony.webwork.components;
 
+import com.opensymphony.xwork.util.OgnlValueStack;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import com.opensymphony.xwork.util.OgnlValueStack;
-
 /**
  * <!-- START SNIPPET: javadoc -->
- * 
+ *
  * Create a list ( &lt;ul&gt; and &lt;li&gt; ) of action errors if they exists.
- * 
+ *
  * <!-- END SNIPPET: javadoc -->
- * 
+ *
  * <p/> <b>Examples</b>
- * 
+ *
  * <pre>
  * <!-- START SNIPPET: example -->
- * 
  *    &lt;ww:actionerror /&gt;
- * 
  * <!-- END SNIPPET: example -->
  * </pre>
- * 
+ *
  * @author tm_jee
  * @version $Date$ $Id$
  * @ww.tag name="actionerror" tld-body-content="empty" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.ActionErrorTag"
  */
 public class ActionError extends UIBean {
 
-	public static final String TEMPLATE = "actionerror";
-	
-	
-	public ActionError(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
-		super(stack, request, response);
-	}
+    public static final String TEMPLATE = "actionerror";
+
+
+    public ActionError(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
+        super(stack, request, response);
+    }
 
-	protected String getDefaultTemplate() {
-		return TEMPLATE;
-	}
+    protected String getDefaultTemplate() {
+        return TEMPLATE;
+    }
 
 }

src/java/com/opensymphony/webwork/components/ActionMessage.java

  */
 package com.opensymphony.webwork.components;
 
+import com.opensymphony.xwork.util.OgnlValueStack;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import com.opensymphony.xwork.util.OgnlValueStack;
-
 /**
  * <!-- START SNIPPET: javadoc -->
- * 
+ *
  * Create a list ( &lt;ul&gt; and &lt;li&gt; ) of action messages if they exists.
- * 
+ *
  * <!-- END SNIPPET: javadoc -->
- * 
+ *
  * <p/> <b>Examples</b>
- * 
+ *
  * <pre>
  * <!-- START SNIPPET: example -->
- * 
  *    &lt;ww:actionmessage /&gt;
- * 
  * <!-- END SNIPPET: example -->
  * </pre>
- * 
+ *
+ * @author tm_jee
  * @author tm_jee
  * @version $Date$ $Id$
  * @ww.tag name="actionmessage" tld-body-content="empty" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.ActionMessageTag"
  * description="Render action messages if they exists"
  * @since 2.2
- * 
- * @author tm_jee
- * @version $Date$ $Id$
  */
 public class ActionMessage extends UIBean {
 
-	private static final String TEMPLATE = "actionmessage";
-	
-	public ActionMessage(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
-		super(stack, request, response);
-	}
+    private static final String TEMPLATE = "actionmessage";
+
+    public ActionMessage(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
+        super(stack, request, response);
+    }
 
-	protected String getDefaultTemplate() {
-		return TEMPLATE;
-	}
+    protected String getDefaultTemplate() {
+        return TEMPLATE;
+    }
 }

src/java/com/opensymphony/webwork/components/FieldError.java

  */
 package com.opensymphony.webwork.components;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.opensymphony.webwork.components.Param.UnnamedParametric;
+import com.opensymphony.xwork.util.OgnlValueStack;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
-import com.opensymphony.webwork.components.Param.UnnamedParametric;
-import com.opensymphony.xwork.util.OgnlValueStack;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <!-- START SNIPPET: javadoc -->
- * 
+ *
  * Create a list ( &lt;ul&gt; and &lt;li&gt; ) of action messages if they exists.
- * 
+ *
  * <!-- END SNIPPET: javadoc -->
- * 
+ *
  * <p/> <b>Examples</b>
- * 
+ *
  * <pre>
  * <!-- START SNIPPET: example -->
- * 
  *    &lt;!-- example 1 --&gt;
  *    &lt;ww:fielderror /&gt;
- *    
+ *
  *    &lt;!-- example 2 --&gt;
  *    &lt;ww:fielderror&gt;
  *         &lt;ww:param&gt;field1&lt;/ww:param&gt;
  *         &lt;ww:param&gt;field2&lt;/ww:param&gt;
  *    &lt;/ww:fielderror&gt;
- *    
+ *
  *    OR
- *    
+ *
  *    &lt;ww:fielderror&gt;
  *    		&lt;ww:param value="%{'field1'}" /&gt;
  *    		&lt;ww:param value="%{'field2'}" /&gt;
  *    &lt;/ww:fielderror&gt;
- *    
- * 
  * <!-- END SNIPPET: example -->
  * </pre>
- * 
- * 
+ *
+ *
  * <p/> <b>Description</b><p/>
- * 
- * 
+ *
+ *
  * <!-- START SNIPPET: description -->
- * 
- * Example 1: display all field errors<p/>
- * Example 2: display field errors only for 'field1' and 'field2'<p/>
- * 
+ *
+ * Example 1: display all field errors<p/> Example 2: display field errors only for 'field1' and 'field2'<p/>
+ *
  * <!-- END SNIPPET: description -->
- * 
- * 
+ *
  * @author tm_jee
  * @version $Date$ $Id$
  * @ww.tag name="fielderror" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.FieldErrorTag"
  */
 public class FieldError extends UIBean implements UnnamedParametric {
 
-	private List errorFieldNames = new ArrayList();
-	
-	public FieldError(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
-		super(stack, request, response);
-	}
+    private List errorFieldNames = new ArrayList();
+
+    public FieldError(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
+        super(stack, request, response);
+    }
+
+    private static final String TEMPLATE = "fielderror";
+
+    protected String getDefaultTemplate() {
+        return TEMPLATE;
+    }
 
-	private static final String TEMPLATE = "fielderror";
-	
-	protected String getDefaultTemplate() {
-		return TEMPLATE;
-	}
+    public void addParameter(Object value) {
+        if (value != null) {
+            errorFieldNames.add(value.toString());
+        }
+    }
 
-	public void addParameter(Object value) {
-		if (value != null) {
-			errorFieldNames.add(value.toString());
-		}
-	}
-	
-	public List getFieldErrorFieldNames() {
-		return errorFieldNames;
-	}
+    public List getFieldErrorFieldNames() {
+        return errorFieldNames;
+    }
 }
 

src/java/com/opensymphony/webwork/views/freemarker/tags/ActionErrorModel.java

+package com.opensymphony.webwork.views.freemarker.tags;
+
+import com.opensymphony.xwork.util.OgnlValueStack;
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.ActionError;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @see ActionError
+ */
+public class ActionErrorModel extends TagModel {
+    public ActionErrorModel(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+        super(stack, req, res);
+    }
+
+    protected Component getBean() {
+        return new ActionError(stack, req, res);
+    }
+}

src/java/com/opensymphony/webwork/views/freemarker/tags/ActionMessageModel.java

+package com.opensymphony.webwork.views.freemarker.tags;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.ActionMessage;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @see ActionMessage
+ */
+public class ActionMessageModel extends TagModel {
+    public ActionMessageModel(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+        super(stack, req, res);
+    }
+
+    protected Component getBean() {
+        return new ActionMessage(stack, req, res);
+    }
+}

src/java/com/opensymphony/webwork/views/freemarker/tags/FieldErrorModel.java

+package com.opensymphony.webwork.views.freemarker.tags;
+
+import com.opensymphony.xwork.util.OgnlValueStack;
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.FieldError;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @see FieldError
+ */
+public class FieldErrorModel extends TagModel {
+    public FieldErrorModel(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+        super(stack, req, res);
+    }
+
+    protected Component getBean() {
+        return new FieldError(stack, req, res);
+    }
+}

src/java/com/opensymphony/webwork/views/freemarker/tags/WebWorkModels.java

     protected WebTableModel table;
     protected PropertyModel property;
     protected IteratorModel iterator;
+    protected ActionErrorModel actionError;
+    protected ActionMessageModel actionMessage;
+    protected FieldErrorModel fieldError;
 
     public WebWorkModels(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         this.stack = stack;
 
         return iterator;
     }
+
+    public ActionErrorModel getActionError() {
+        if (actionError == null) {
+            actionError = new ActionErrorModel(stack, req, res);
+        }
+
+        return actionError;
+    }
+
+    public ActionMessageModel getActionMessage() {
+        if (actionMessage == null) {
+            actionMessage = new ActionMessageModel(stack, req, res);
+        }
+
+        return actionMessage;
+    }
+
+    public FieldErrorModel getFieldError() {
+        if (fieldError == null) {
+            fieldError = new FieldErrorModel(stack, req, res);
+        }
+
+        return fieldError;
+    }
 }

src/java/com/opensymphony/webwork/views/velocity/VelocityManager.java

         addDirective(sb, TokenDirective.class);
         addDirective(sb, URLDirective.class);
         addDirective(sb, WebTableDirective.class);
+        addDirective(sb, ActionErrorDirective.class);
+        addDirective(sb, ActionMessageDirective.class);
+        addDirective(sb, FieldErrorDirective.class);
 
         String directives = sb.toString();
 

src/java/com/opensymphony/webwork/views/velocity/components/ActionErrorDirective.java

+package com.opensymphony.webwork.views.velocity.components;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.ActionError;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @see ActionError
+ */
+public class ActionErrorDirective extends AbstractDirective {
+    public String getBeanName() {
+        return "actionerror";
+    }
+
+    protected Component getBean(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+        return new ActionError(stack, req, res);
+    }
+}

src/java/com/opensymphony/webwork/views/velocity/components/ActionMessageDirective.java

+package com.opensymphony.webwork.views.velocity.components;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.ActionMessage;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @see ActionMessage
+ */
+public class ActionMessageDirective extends AbstractDirective {
+    public String getBeanName() {
+        return "actionmessage";
+    }
+
+    protected Component getBean(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+        return new ActionMessage(stack, req, res);
+    }
+}

src/java/com/opensymphony/webwork/views/velocity/components/FieldErrorDirective.java

+package com.opensymphony.webwork.views.velocity.components;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.FieldError;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @see FieldError
+ */
+public class FieldErrorDirective extends AbstractDirective {
+    public String getBeanName() {
+        return "fielderror";
+    }
+
+    protected Component getBean(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+        return new FieldError(stack, req, res);
+    }
+}