| java.lang.Object com.opensymphony.webwork.components.Component com.opensymphony.webwork.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).
The set tag accepts body. However the followings need to be take note when using set tag with body
- body are treated as String and will not be parsed by OGNL
- body could be scriptlet or JSP tags, the String representation of scriptlet or JSP tags will be used
- A non-empty will take precedence if there's also a value attribute present, if the body is empty, then the value attribute will be used
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
<ww:set name="personName" value="person.name"/>
Hello, <ww:property value="%{#personName}"/>. How are you?
<ww:set name="personName">
<ww:property value="%{'some string'}" />
</ww:set>
Hello, <ww:property value="%{#personName}"/>. How are you?
<ww:set name="personName">
<c:set value="${person.name}" />
</ww:set>
Hello, <ww:property value="%{#personName}"/>. How are you?
author: Patrick Lightbody author: Rene Gielen version: $Revision: 2871 $ since: 2.2 |
setName | public void setName(String name)(Code) | | The name of the new variable that is assigned the value of value
|
setScope | public void setScope(String scope)(Code) | | The scope in which to assign the variable. Can be application, session, request, page, or action.
|
setValue | public void setValue(String value)(Code) | | The value that is assigned to the variable named name
|
Methods inherited from com.opensymphony.webwork.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, boolean escapeXml)(Code)(Java Doc) protected String determineNamespace(String namespace, OgnlValueStack 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 WebWorkException 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 OgnlValueStack getStack()(Code)(Java Doc) protected void popComponentStack()(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)
|
|
|