public class Set
- extends Component
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
If the tag is used with body content, the evaluation of the value parameter is omitted. Instead, the String to
which the body eveluates is set as value for the scoped variable.
The scopes available are as follows :-
If no scope is specified, it will default to action scope.
- application - the value will be set in application scope according to servlet spec. using the name as its key
- session - the value will be set in session scope according to servlet spec. using the name as key
- request - the value will be set in request scope according to servlet spec. using the name as key
- page - the value will be set in request scope according to servlet sepc. using the name as key
- action - the value will be set in the request scope and Struts' action context using the name as key
- name* (String): The name of the new variable that is assigned the value of value
- value (Object): The value that is assigned to the variable named name
- scope (String): The scope in which to assign the variable. Can be application, session,
request, page, or action. By default it is action.
<s:set name="personName" value="person.name"/>
Hello, <s:property value="#personName"/>. How are you?
|Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setActionMapper, setId, start, toString, usesBody
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected String name
protected String scope
protected String value
public Set(ValueStack stack)
public boolean end(Writer writer,
- Description copied from class:
- Callback for the end tag of this component.
Should the body be evaluated again?
NOTE: will pop component stack.
end in class
writer - the output writer.
body - the rendered body.
- true if the body should be evaluated again
public void setName(String name)
public void setScope(String scope)
public void setValue(String value)
Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.