public class Set extends ContextBean
The set tag assigns a value to a variable in a specified scope. It is useful when you wish to assign a variable to a complex expression and then simply reference that variable each time rather than the complex expression. This is useful in both cases: when the complex expression takes time (performance improvement) or is hard to read (code readability improvement).
If the tag is used with body content, the evaluation of the value parameter is omitted. Instead, the String to which the body evaluates is set as value for the scoped variable.
The scopes available are as follows:
NOTE:
If no scope is specified, it will default to action scope.
Parameters
Examples
<s:set var="personName" value="person.name"/> Hello, <s:property value="#personName"/> <s:set var="janesName">Jane Doe</s:set> <s:property value="#janesName"/>
Modifier and Type | Field and Description |
---|---|
protected String |
scope |
protected String |
value |
var
actionMapper, COMPONENT_STACK, devMode, parameters, stack, standardAttributesMap, throwExceptionOnELFailure
Constructor and Description |
---|
Set(ValueStack stack) |
Modifier and Type | Method and Description |
---|---|
boolean |
end(Writer writer,
String body)
Callback for the end tag of this component.
|
void |
setName(String name) |
void |
setScope(String scope) |
void |
setValue(String value) |
void |
setVar(String var) |
boolean |
usesBody()
Overwrite to set if body should be used.
|
getVar, putInContext, setId
addAllParameters, addParameter, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, getStandardAttributes, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpressionIfAltSyntax, toString
public Set(ValueStack stack)
public boolean end(Writer writer, String body)
Component
public void setVar(String var)
setVar
in class ContextBean
public void setName(String name)
public void setScope(String scope)
public void setValue(String value)
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.