net.windward.tags
Class IfTag
net.windward.tags.BaseTag
|
+--net.windward.tags.IfTag
- public class IfTag
- extends BaseTag
Conditionally include part of a report. This tag represents a <wr:if ...> in the template. This tag is unique
in that it has two different meanings depending on which attribute is included. You must have either a select= or a
test= attribute. You cannot have both.
For <wr:if select="./name"> ... </wr:if> it is performing an if on the dataset. It looks for
the existence of the node identified by the select and is true if the node exists and false if it does not. If the
attribute notEmpty="true" is set, the node must not only exist, but must have data in it. A single space counts as data.
For <wr:if test="${stat.index}>1"> ... </wr:if> it is performing a boolean evaluation on the
test attribute. In this case it is not hitting the datasource. However, the use of ${name.item} type fields in the
boolean expression allows the evaluation to be performed against var's from forEach and query tags and varStatus' from
forEach tags.
The full usage is
<wr:if select="./name"> ... other text ... <wr:else/> ... other text ... </wr:if> which
will include the template between the if and the else if the referenced node exists and will include the text
between the else and the end if it does not.
The <wr:else/> is optional and in that case everything is skipped if the node does not exist. The <wr:else/>
is only valid inside an if, there can be only 1, and it must be a complete tag (ie have the final />).
The full list of attributes is:
- select - required (unless test is defined) - the node that will be tested for existence. An empty node exists.
- notEmpty - optional (only used with select) - the node must exist and must not be empty.
- test - required (unless select is defined) - the boolean statement to evaluateBoolean.
Operators allowed in the test="" attribute are (identical to c:if): ( ) + - * / div % mod == eq != ne < lt <= le
> gt >= ge && and || or ! not. For variables it handles boolean (the text true or false - no quotes), long,
double, and String. Strings must be in quotes and it handles \" inside a string (but no other escape sequences).
It is an error to enter <wr:if select="./name" test="${stat.index}==1">
It is an error to enter <wr:if select="./name"/>
This tag follows the jstl example of c:if and x:if.
- Version:
- 2.0 November 1, 2003
| Fields inherited from class net.windward.tags.BaseTag |
CHART, COLUMN, DISPLAY_ALWAYS, DISPLAY_NOT_EMPTY, DISPLAY_NOT_NULL, ELSE, END_FOREACH, END_IF, END_LINK, END_MATRIX, ESCAPE, FOREACH, FUNCTION, HTML, IF, IMPORT, LINK, MATRIX, OUT, PROP_COMMENT, PROP_DATASOURCE, PROP_DEFAULT, PROP_DISPLAY, PROP_ENABLED, PROP_INPUT, PROP_PATTERN, PROP_TITLE, PROP_TYPE, PROP_VAR, PROP_WRAP, QUERY, ROW, SET, TAG_DISPLAY_DEFAULT, TAG_DISPLAY_SELECT, TAG_DISPLAY_TAG, TYPE_BITMAP, TYPE_BOTH, TYPE_CURRENCY, TYPE_DATE, TYPE_NUMBER, TYPE_PERCENT, TYPE_TIME, WRAP_BEHIND, WRAP_FRONT, WRAP_INLINE, WRAP_SQUARE |
|
Constructor Summary |
IfTag(java.util.Map map,
boolean selfContained,
int nestLevel,
boolean ignoreErrors)
Create an if element using the passed in map values. |
|
Method Summary |
net.windward.document.Element |
dup(boolean sameRefId)
Makes a duplicate of this object. |
int |
getXmlType()
Returns which type of xml element this is. |
java.lang.String |
toDisplay(int type)
How this node is displayed on the page when in a field. |
java.lang.String |
toString()
This object as a string in the format "If[1]..." where the number is it's level. |
java.lang.String |
toText()
Converts this node back in to it's string representation in the document |
| Methods inherited from class net.windward.tags.BaseTag |
containsAttribute, factory, factory, getAttribute, getAttributes, getBean, getDatasource, getIntAttribute, getLevel, getMode, getNode, getType, setLevel, setNode, toTagText |
MODE_SELECT
public static final int MODE_SELECT
MODE_TEST
public static final int MODE_TEST
PROP_NOT_EMPTY
public static final java.lang.String PROP_NOT_EMPTY
IfTag
public IfTag(java.util.Map map,
boolean selfContained,
int nestLevel,
boolean ignoreErrors)
throws TagException
- Create an if element using the passed in map values.
- Parameters:
map - Must have a select entry.selfContained - Must be false.nestLevel - The nest level for this while. A matching if/while will have the same level.ignoreErrors - - Throws:
TagException - thrown if illegal parameters passed in.
toText
public java.lang.String toText()
throws TagException
- Converts this node back in to it's string representation in the document
- Overrides:
toText in class BaseTag
- Returns:
- <wr:if ... > type string.
toDisplay
public java.lang.String toDisplay(int type)
- How this node is displayed on the page when in a field.
- Overrides:
toDisplay in class BaseTag
- Parameters:
type - One of the DISPLAY_* constants- Returns:
- title, end of select, or <cmd> type string.
dup
public net.windward.document.Element dup(boolean sameRefId)
- Makes a duplicate of this object. A deep clone is done so the new object shares nothing
with the original object.
- Parameters:
sameRefId - - Returns:
- The new duplicate of this object
getXmlType
public int getXmlType()
- Returns which type of xml element this is.
- Overrides:
getXmlType in class BaseTag
- Returns:
- IF
toString
public java.lang.String toString()
- This object as a string in the format "If[1]..." where the number is it's level.
- Returns:
- A String listing this element.
Copyright © 2002 - 2008 Windward Reports - All Rights Reserved. java reporting software