Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.components
Class Text

    java.lang.Object
      org.apache.struts2.components.Component
          org.apache.struts2.components.Text

All Implemented Interfaces:
  Param.UnnamedParametric

    public class Text

extends Component
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, then the body of the tag will be used as default message. If no body is used, then the name of the message will be used.

- name* (String) - the i18n message key

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>

See Also:
  `Param`

Field Summary
`protected String` | `actualName`
`private static Log` | `LOG`
`protected String` | `name`
`protected List` | `values`

Fields inherited from class org.apache.struts2.components.Component
`actionMapper, COMPONENT_STACK, id, parameters, stack`

Constructor Summary
`Text(ValueStack stack)`

Method Summary
`void` | `addParameter(Object value)` Adds the given value as a parameter to the outer tag.
`void` | `addParameter(String key, Object value)` Add's the given key and value to this components own parameter.
`boolean` | `end(Writer writer, String body)` Callback for the end tag of this component.
`void` | `setName(String name)`
`boolean` | `usesBody()` Overwrite to set if body shold be used.

Methods inherited from class org.apache.struts2.components.Component
`addAllParameters, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setActionMapper, setId, start, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOG

    private static final Log LOG

### values

    protected List values

### actualName

    protected String actualName

### name

    protected String name

Constructor Detail

### Text

    public Text(ValueStack stack)

Method Detail

### setName

    public void setName(String name)

### 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.

### 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

### addParameter

    public void addParameter(String key,
                             Object value)

  Description copied from class: `Component`
  Add's the given key and value to this components own parameter.

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

  Overrides:
    `addParameter` in class `Component`
  Parameters:
    `key` - the key of the new parameter to add.
    `value` - the value assoicated with the key.

### addParameter

    public void addParameter(Object value)

  Description copied from interface: `Param.UnnamedParametric`
  Adds the given value as a parameter to the outer tag.

  Specified by:
    `addParameter` in interface `Param.UnnamedParametric`
  Parameters:
    `value` - the value

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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