Package org.apache.struts2.components

# Class If

java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.If

public class If extends Component

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

      <s:if test="%{false}">
          <div>Will Not Be Executed</div>
      </s:if>
      <s:elseif test="%{true}">
          <div>Will Be Executed</div>
      </s:elseif>
      <s:else>
          <div>Will Not Be Executed</div>
      </s:else>

See Also:
  - `Else`
  - `ElseIf`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ANSWER`

  ### Fields inherited from class org.apache.struts2.components.Component

  `actionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `If(ValueStack stack)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `end(Writer writer, String body)`
  Callback for the end tag of this component.
  `void`
  `setTest(String test)`
  `boolean`
  `start(Writer writer)`
  Callback for the start tag of this component.

  ### Methods inherited from class org.apache.struts2.components.Component

  `addAllAttributes, addParameter, completeExpression, copyAttributes, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, stripExpression, toString, usesBody`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ANSWER

    public static final String ANSWER
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### If

    public If(ValueStack stack)

- ## Method Details

  - ### setTest

    public void setTest(String test)

  - ### start

    public boolean start(Writer writer)
    Description copied from class: `Component`
    Callback for the start tag of this component. Should the body be evaluated?
    Overrides:
      `start` in class `Component`
    Parameters:
      `writer` - the output writer.
    Returns:
      true if the body should be evaluated

  - ### end

    public boolean end(Writer writer, String body)
    Description copied from class: `Component`
    Callback for the end tag of this component. Should the body be evaluated again?
    NOTE: will pop component stack.
    Overrides:
      `end` in class `Component`
    Parameters:
      `writer` - the output writer.
      `body` - the rendered body.
    Returns:
      true if the body should be evaluated again