org.apache.struts2.components
Class Set

java.lang.Object
  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.ContextBean
          extended by org.apache.struts2.components.Set

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 eveluates 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 name="personName" value="person.name"/>
 Hello, <s:property value="#personName"/>. How are you?
 
 


Field Summary
protected  String scope
           
protected  String value
           
 
Fields inherited from class org.apache.struts2.components.ContextBean
var
 
Fields inherited from class org.apache.struts2.components.Component
actionMapper, COMPONENT_STACK, parameters, stack, throwExceptionOnELFailure
 
Constructor Summary
Set(ValueStack stack)
           
 
Method Summary
 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 shold be used.
 
Methods inherited from class org.apache.struts2.components.ContextBean
getVar, putInContext, setId
 
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, popComponentStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpressionIfAltSyntax, stripExpressionIfAltSyntax, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scope

protected String scope

value

protected String value
Constructor Detail

Set

public Set(ValueStack stack)
Method Detail

end

public boolean end(Writer writer,
                   String body)
Description copied from class: Component
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

Overrides:
end in class Component
Parameters:
writer - the output writer.
body - the rendered body.
Returns:
true if the body should be evaluated again

setVar

public void setVar(String var)
Overrides:
setVar in class ContextBean

setName

public void setName(String name)

setScope

public void setScope(String scope)

setValue

public void setValue(String value)

usesBody

public boolean usesBody()
Description copied from class: Component
Overwrite to set if body shold be used.

Overrides:
usesBody in class Component
Returns:
always false for this component.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.