All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opensymphony.webwork.components.If Maven / Gradle / Ivy

There is a newer version: 2.2.5
Show newest version
package com.opensymphony.webwork.components;

import com.opensymphony.xwork.util.OgnlValueStack;

import java.io.Writer;

/**
 * 
 *
 * 

Perform basic condition flow. 'If' tag could be used by itself or * with 'Else If' Tag and/or single/multiple 'Else' Tag.

* * * * * * *
    * *
  • test* (Boolean) - Logic to determined if body of tag is to be displayed
  • * *
* * * * *
 * 
 *  <ww:if test="%{false}">
 *	    <div>Will Not Be Executed</div>
 *  </ww:if>
 * 	<ww:elseif test="%{true}">
 *	    <div>Will Be Executed</div>
 *  </ww:elseif>
 *  <ww:else>
 *	    <div>Will Not Be Executed</div>
 *  </ww:else>
 * 
 * 
* * @author tmjee * * @see Else * @see ElseIf * * @ww.tag name="if" tld-body-content="JSP" description="If tag" tld-tag-class="com.opensymphony.webwork.views.jsp.IfTag" */ public class If extends Component { public static final String ANSWER = "webwork.if.answer"; Boolean answer; String test; /** * Expression to determine if body of tag is to be displayed * @ww.tagattribute required="true" type="Boolean" */ public void setTest(String test) { this.test = test; } public If(OgnlValueStack stack) { super(stack); } public boolean start(Writer writer) { answer = (Boolean) findValue(test, Boolean.class); if (answer == null) { answer = Boolean.FALSE; } stack.getContext().put(ANSWER, answer); return answer.booleanValue(); } public boolean end(Writer writer, String body) { return super.end(writer, body); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy