| java.lang.Object org.apache.struts2.components.Component org.apache.struts2.components.Set
Set | public class Set extends Component (Code) | |
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 eveluates is set as value for the scoped variable.
The scopes available are as follows :-
- 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
NOTE:
If no scope is specified, it will default to action scope.
Parameters
- 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.
Examples
<s:set name="personName" value="person.name"/>
Hello, <s:property value="#personName"/>. How are you?
|
Constructor Summary | |
public | Set(ValueStack stack) |
Set | public Set(ValueStack stack)(Code) | | |
Methods inherited from org.apache.struts2.components.Component | public void addAllParameters(Map params)(Code)(Java Doc) public void addParameter(String key, Object value)(Code)(Java Doc) public boolean altSyntax()(Code)(Java Doc) public void copyParams(Map params)(Code)(Java Doc) protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult)(Code)(Java Doc) protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort, boolean escapeAmp)(Code)(Java Doc) protected String determineNamespace(String namespace, ValueStack stack, HttpServletRequest req)(Code)(Java Doc) public boolean end(Writer writer, String body)(Code)(Java Doc) protected boolean end(Writer writer, String body, boolean popComponentStack)(Code)(Java Doc) protected StrutsException fieldError(String field, String errorMsg, Exception e)(Code)(Java Doc) protected Component findAncestor(Class clazz)(Code)(Java Doc) protected String findString(String expr)(Code)(Java Doc) protected String findString(String expr, String field, String errorMsg)(Code)(Java Doc) protected Object findValue(String expr)(Code)(Java Doc) protected Object findValue(String expr, String field, String errorMsg)(Code)(Java Doc) protected Object findValue(String expr, Class toType)(Code)(Java Doc) public Stack getComponentStack()(Code)(Java Doc) public String getId()(Code)(Java Doc) public Map getParameters()(Code)(Java Doc) public ValueStack getStack()(Code)(Java Doc) protected void popComponentStack()(Code)(Java Doc) public void setActionMapper(ActionMapper mapper)(Code)(Java Doc) public void setId(String id)(Code)(Java Doc) public boolean start(Writer writer)(Code)(Java Doc) protected String toString(Throwable t)(Code)(Java Doc) public boolean usesBody()(Code)(Java Doc)
|
|
|