01: package com.opensymphony.webwork.components;
02:
03: import com.opensymphony.xwork.util.OgnlValueStack;
04:
05: import java.io.Writer;
06: import java.util.Map;
07:
08: /**
09: * <!-- START SNIPPET: javadoc -->
10: *
11: * <p>Perform basic condition flow. 'If' tag could be used by itself or with 'Else If' Tag and/or single/multiple 'Else'
12: * Tag.</p>
13: *
14: * <!-- END SNIPPET: javadoc -->
15: *
16: * <!-- START SNIPPET: params -->
17: *
18: * no params
19: *
20: * <!-- END SNIPPET: params -->
21: *
22: *
23: * <pre>
24: * <!-- START SNIPPET: example -->
25: * <ww:if test="%{false}">
26: * <div>Will Not Be Executed</div>
27: * </ww:if>
28: * <ww:elseif test="%{true}">
29: * <div>Will Be Executed</div>
30: * </ww:elseif>
31: * <ww:else>
32: * <div>Will Not Be Executed</div>
33: * </ww:else>
34: * <!-- END SNIPPET: example -->
35: * </pre>
36: *
37: * @author Rick Salsa (rsal@mb.sympatico.ca)
38: * @author tmjee
39: * @ww.tag name="else" bodycontent="JSP" description="Else tag" tld-tag-class="com.opensymphony.webwork.views.jsp.ElseTag"
40: */
41: public class Else extends Component {
42: public Else(OgnlValueStack stack) {
43: super (stack);
44: }
45:
46: public boolean start(Writer writer) {
47: Map context = stack.getContext();
48: Boolean ifResult = (Boolean) context.get(If.ANSWER);
49:
50: context.remove(If.ANSWER);
51:
52: return !((ifResult == null) || (ifResult.booleanValue()));
53:
54: }
55: }
|