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 boolean |
trimBody |
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 |
setScope(String scope) |
void |
setTrimBody(boolean trimBody) |
void |
setValue(String value) |
void |
setVar(String var) |
boolean |
usesBody()
Overwrite to set if body should be used.
|
getVar, putInContext
addAllParameters, addParameter, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, getStandardAttributes, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpressionIfAltSyntax, toString
protected String scope
protected String value
protected boolean trimBody
public Set(ValueStack stack)
public boolean end(Writer writer, String body)
Component
public void setVar(String var)
setVar
in class ContextBean
public void setScope(String scope)
public void setValue(String value)
public void setTrimBody(boolean trimBody)
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.