|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Objectorg.apache.struts2.components.Component
org.apache.struts2.components.ContextBean
org.apache.struts2.components.Bean
public class Bean
Instantiates a class that conforms to the JavaBeans specification. This tag has a body which can contain
a number of Param
elements to set any mutator methods on that class.
If the var attribute is set on the BeanTag, it will place the instantiated bean into the stack's Context.
Examples:
<-- in freemarker form --> [@s.bean name="org.apache.struts2.example.counter.SimpleCounter" var="counter"] [s:param name="foo" value="BAR"/] The value of foo is : [s:property value="foo"/], when inside the bean tag.
[/s:bean] <-- in jsp form --> <s:bean name="org.apache.struts2.example.counter.SimpleCounter" var="counter"> <s:param name="foo" value="BAR" /> The value of foot is : <s:property value="foo"/>, when inside the bean tag <br /> </s:bean>
This example instantiates a bean called SimpleCounter and sets the foo property (setFoo('BAR')). The SimpleCounter object is then pushed onto the Valuestack, which means that we can call its accessor methods (getFoo()) with the Property tag and get their values.
In the above example, the id has been set to a value of counter. This means that the SimpleCounter class will be placed into the stack's context. You can access the SimpleCounter class using a Struts tag:
<-- jsp form --> <s:property value="#counter" /> <-- freemarker form --> [s:property value="#counter.foo"/]
In the property tag example, the # tells Ognl to search the context for the SimpleCounter class which has an id(key) of counter
Param
字段摘要 |
---|
从类 org.apache.struts2.components.Component 继承的字段 |
---|
COMPONENT_STACK |
构造方法摘要 | |
---|---|
Bean(com.opensymphony.xwork2.util.ValueStack stack)
|
方法摘要 | |
---|---|
void |
addParameter(String key,
Object value)
Adds the given key and value to this component's own parameter. |
boolean |
end(Writer writer,
String body)
Callback for the end tag of this component. |
void |
setName(String name)
|
void |
setObjectFactory(com.opensymphony.xwork2.ObjectFactory objectFactory)
|
void |
setReflectionProvider(com.opensymphony.xwork2.util.reflection.ReflectionProvider prov)
|
boolean |
start(Writer writer)
Callback for the start tag of this component. |
从类 org.apache.struts2.components.ContextBean 继承的方法 |
---|
setId, setVar |
从类 org.apache.struts2.components.Component 继承的方法 |
---|
addAllParameters, altSyntax, copyParams, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, usesBody |
从类 java.lang.Object 继承的方法 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
构造方法详细信息 |
---|
public Bean(com.opensymphony.xwork2.util.ValueStack stack)
方法详细信息 |
---|
public void setObjectFactory(com.opensymphony.xwork2.ObjectFactory objectFactory)
public void setReflectionProvider(com.opensymphony.xwork2.util.reflection.ReflectionProvider prov)
public boolean start(Writer writer)
Component
复制的描述
Component
中的 start
writer
- the output writer.
public boolean end(Writer writer, String body)
Component
复制的描述
Component
中的 end
writer
- the output writer.body
- the rendered body.
public void addParameter(String key, Object value)
Component
复制的描述
Component
中的 addParameter
key
- the key of the new parameter to add.value
- the value assoicated with the key.public void setName(String name)
|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |