KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > PushTag


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp;
6
7 import com.opensymphony.xwork.util.OgnlValueStack;
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 import javax.servlet.jsp.JspException JavaDoc;
12
13
14 /**
15  * @author $Author: jcarreira $
16  * @version $Revision: 1.9 $
17  */

18 public class PushTag extends WebWorkBodyTagSupport {
19     //~ Static fields/initializers /////////////////////////////////////////////
20

21     private static final Log log = LogFactory.getLog(PushTag.class);
22
23     //~ Instance fields ////////////////////////////////////////////////////////
24

25     private String JavaDoc value;
26     private boolean pushed = false;
27
28     //~ Methods ////////////////////////////////////////////////////////////////
29

30     public void setValue(String JavaDoc value) {
31         this.value = value;
32     }
33
34     public int doEndTag() throws JspException JavaDoc {
35         OgnlValueStack stack = getStack();
36
37         if (pushed && (stack != null)) {
38             stack.pop();
39         }
40
41         return SKIP_BODY;
42     }
43
44     public int doStartTag() throws JspException JavaDoc {
45         OgnlValueStack stack = getStack();
46
47         if (stack != null) {
48             stack.push(findValue(value));
49             pushed = true;
50         } else {
51             pushed = false; // need to ensure push is assigned, otherwise we may have a leftover value
52
}
53
54         return EVAL_BODY_INCLUDE;
55     }
56 }
57
Popular Tags