Save This Page
Home » struts-2.1.8.1-src » org.apache » struts2 » components » [javadoc | source]
org.apache.struts2.components
public class: Text [javadoc | source]
java.lang.Object
   org.apache.struts2.components.Component
      org.apache.struts2.components.ContextBean
         org.apache.struts2.components.Text

All Implemented Interfaces:
    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>


Field Summary
protected  List values     
protected  String actualName     
protected  String name     
protected  String searchStack     
Fields inherited from org.apache.struts2.components.ContextBean:
var
Fields inherited from org.apache.struts2.components.Component:
COMPONENT_STACK,  stack,  parameters,  actionMapper,  throwExceptionOnELFailure
Constructor:
 public Text(ValueStack stack) 
Method from org.apache.struts2.components.Text Summary:
addParameter,   addParameter,   end,   setName,   setSearchValueStack,   usesBody
Methods from org.apache.struts2.components.ContextBean:
getVar,   putInContext,   setId,   setVar
Methods from org.apache.struts2.components.Component:
addAllParameters,   addParameter,   altSyntax,   altSyntax,   completeExpressionIfAltSyntax,   copyParams,   determineActionURL,   determineNamespace,   end,   end,   fieldError,   findAncestor,   findString,   findString,   findStringIfAltSyntax,   findValue,   findValue,   findValue,   getComponentStack,   getParameters,   getStack,   popComponentStack,   setActionMapper,   setThrowExceptionsOnELFailure,   start,   stripExpressionIfAltSyntax,   stripExpressionIfAltSyntax,   toString,   usesBody
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.components.Text Detail:
 public  void addParameter(Object value) 
 public  void addParameter(String key,
    Object value) 
 public boolean end(Writer writer,
    String body) 
 public  void setName(String name) 
 public  void setSearchValueStack(String searchStack) 
 public boolean usesBody()