1. opensymphony
  2. webwork

Commits

tmjee  committed 12847c5

- Add If, Else, and ElseIf to freemarker model

Issue number: WW-1328
Obtained from:
Submitted by:
Reviewed by:

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

  • Participants
  • Parent commits a298871
  • Branches master

Comments (0)

Files changed (6)

File src/java/com/opensymphony/webwork/components/ElseIf.java

View file
  • Ignore whitespace
         //make the comparision
         answer = (Boolean) findValue(test, Boolean.class);
 
-        return answer != null && answer.booleanValue();
-    }
-
-    public boolean end(Writer writer, String body) {
         if (answer == null) {
             answer = Boolean.FALSE;
         }
         if (answer.booleanValue()) {
             stack.getContext().put(If.ANSWER, answer);
         }
+        
+        return answer != null && answer.booleanValue();
+    }
 
+    public boolean end(Writer writer, String body) {
         return super.end(writer, "");
     }
 

File src/java/com/opensymphony/webwork/components/If.java

View file
  • Ignore whitespace
             answer = Boolean.FALSE;
         }
 
+        stack.getContext().put(ANSWER, answer);
+        
         return answer.booleanValue();
     }
 
     public boolean end(Writer writer, String body) {
-        stack.getContext().put(ANSWER, answer);
-
         return super.end(writer, body);
     }
 }

File src/java/com/opensymphony/webwork/views/freemarker/tags/ElseIfModel.java

View file
  • Ignore whitespace
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.webwork.views.freemarker.tags;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.ElseIf;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+/**
+ * 
+ * @author tm_jee
+ * @version $Date$ $Id$
+ */
+public class ElseIfModel extends TagModel {
+
+	public ElseIfModel(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+		super(stack, req, res);
+	}
+	
+	protected Component getBean() {
+		return new ElseIf(stack);
+	}
+
+}

File src/java/com/opensymphony/webwork/views/freemarker/tags/ElseModel.java

View file
  • Ignore whitespace
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.webwork.views.freemarker.tags;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.Else;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+/**
+ * 
+ * @author tm_jee
+ * @version $Date$ $Id$
+ */
+public class ElseModel extends TagModel {
+
+	public ElseModel(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+		super(stack, req, res);
+	}
+
+	protected Component getBean() {
+		return new Else(stack);
+	}
+
+}

File src/java/com/opensymphony/webwork/views/freemarker/tags/IfModel.java

View file
  • Ignore whitespace
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.webwork.views.freemarker.tags;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.opensymphony.webwork.components.Component;
+import com.opensymphony.webwork.components.If;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+/**
+ * 
+ * @author tm_jee
+ * @version $Date$ $Id$
+ */
+public class IfModel extends TagModel {
+
+	public IfModel(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
+		super(stack, req, res);
+	}
+	
+	protected Component getBean() {
+		return new If(stack);
+	}
+}

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

View file
  • Ignore whitespace
  * Provides @ww.xxx access for various tags.
  *
  * @author plightbo
+ * @author tm_jee
  */
 public class WebWorkModels {
     protected OgnlValueStack stack;
     protected UpDownSelectModel updownselect;
     protected RichTextEditorModel richtexteditorModel;
     protected OptGroupModel optGroupModel;
+    protected IfModel ifModel;
+    protected ElseIfModel elseIfModel;
+    protected ElseModel elseModel;
     
 
     public WebWorkModels(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) {
     	}
     	return optGroupModel;
     }
+    
+    public IfModel getIf() {
+    	if (ifModel == null) {
+    		ifModel = new IfModel(stack, req, res);
+    	}
+    	return ifModel;
+    }
+    
+    public ElseModel getElse() {
+    	if (elseModel ==  null) {
+    		elseModel = new ElseModel(stack, req, res);
+    	}
+    	return elseModel;
+    }
+    
+    public ElseIfModel getElseif() {
+    	if (elseIfModel == null) {
+    		elseIfModel = new ElseIfModel(stack, req, res);
+    	}
+    	return elseIfModel;
+    }
 }