org.apache.struts2.components
类 Text

java.lang.Object
  继承者 org.apache.struts2.components.Component
      继承者 org.apache.struts2.components.ContextBean
          继承者 org.apache.struts2.components.Text
所有已实现的接口:
Param.UnnamedParametric

public class Text
extends ContextBean
implements Param.UnnamedParametric

Render a I18n text message.

The message must be in a resource bundle with the same name as the action that it is associated with. In practice this means that you should create a properties file in the same package as your Java class with the same name as your class, but with .properties extension.

If the named message is not found in a property file, then the body of the tag will be used as default message. If no body is used, then the stack will be searched, and if a value is returned, it will written to the output. If no value is found on the stack, the key of the message will be written out.

Example:

 

 Accessing messages from a given bundle (the i18n Shop example bundle in the first example) and using bundle defined through the framework in the second example.

 

 <!-- First Example -->
 <s:i18n name="struts.action.test.i18n.Shop">
     <s:text name="main.title"/>
 </s:i18n>

 <!-- Second Example -->
 <s:text name="main.title" />

 <!-- Third Examlpe -->
 <s:text name="i18n.label.greetings">
    <s:param >Mr Smith</s:param>
 </s:text>

 
 
 

 <-- Fourth Example -->
 <s:text name="some.key" />

 <-- Fifth Example -->
 <s:text name="some.invalid.key" >
    The Default Message That Will Be Displayed
 </s:text>

 
 

另请参见:
Param

字段摘要
 
从类 org.apache.struts2.components.Component 继承的字段
COMPONENT_STACK
 
构造方法摘要
Text(com.opensymphony.xwork2.util.ValueStack stack)
           
 
方法摘要
 void addParameter(Object value)
          Adds the given value as a parameter to the outer tag.
 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 setSearchValueStack(String searchStack)
           
 boolean usesBody()
          Overwrite to set if body should be used.
 
从类 org.apache.struts2.components.ContextBean 继承的方法
setId, setVar
 
从类 org.apache.struts2.components.Component 继承的方法
addAllParameters, altSyntax, copyParams, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, start
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

Text

public Text(com.opensymphony.xwork2.util.ValueStack stack)
方法详细信息

setName

public void setName(String name)

setSearchValueStack

public void setSearchValueStack(String searchStack)

usesBody

public boolean usesBody()
从类 Component 复制的描述
Overwrite to set if body should be used.

覆盖:
Component 中的 usesBody
返回:
always false for this component.

end

public boolean end(Writer writer,
                   String body)
从类 Component 复制的描述
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

覆盖:
Component 中的 end
参数:
writer - the output writer.
body - the rendered body.
返回:
true if the body should be evaluated again

addParameter

public void addParameter(String key,
                         Object value)
从类 Component 复制的描述
Adds the given key and value to this component's own parameter.

If the provided key is null nothing happens. If the provided value is null any existing parameter with the given key name is removed.

覆盖:
Component 中的 addParameter
参数:
key - the key of the new parameter to add.
value - the value assoicated with the key.

addParameter

public void addParameter(Object value)
从接口 Param.UnnamedParametric 复制的描述
Adds the given value as a parameter to the outer tag.

指定者:
接口 Param.UnnamedParametric 中的 addParameter
参数:
value - the value