Class Text
- All Implemented Interfaces:
- 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 value is found, the key of the message will not be written out.
Note: If the var attribute is used with this tag, the tag's value will not be written out. Instead the result will be saved into the action context (action scope).
- name* (String) - the i18n message key
- escapeHtml (Boolean) - Escape HTML. Defaults to false
- escapeJavaScript (Boolean) - Escape JavaScript. Defaults to false
- escapeXml (Boolean) - Escape XML. Defaults to false
- escapeCsv (Boolean) - Escape CSV. Defaults to false
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:
- 
Field SummaryFieldsFields inherited from class org.apache.struts2.components.ContextBeanvarFields inherited from class org.apache.struts2.components.ComponentactionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddParameter(Object value) Adds the given value as a parameter to the outer tag.voidaddParameter(String key, Object value) Adds the given key and value to this component's own parameter.booleanCallback for the end tag of this component.voidsetEscapeCsv(boolean escapeCsv) voidsetEscapeHtml(boolean escape) voidsetEscapeJavaScript(boolean escapeJavaScript) voidsetEscapeXml(boolean escapeXml) voidbooleanusesBody()Overwrite to set if body should be used.Methods inherited from class org.apache.struts2.components.ContextBeangetVar, putInContext, setVarMethods inherited from class org.apache.struts2.components.ComponentaddAllAttributes, completeExpression, copyAttributes, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpression, toString
- 
Field Details- 
values
- 
actualName
- 
name
 
- 
- 
Constructor Details- 
Text
 
- 
- 
Method Details- 
setName
- 
setEscapeHtmlpublic void setEscapeHtml(boolean escape) 
- 
setEscapeJavaScriptpublic void setEscapeJavaScript(boolean escapeJavaScript) 
- 
setEscapeXmlpublic void setEscapeXml(boolean escapeXml) 
- 
setEscapeCsvpublic void setEscapeCsv(boolean escapeCsv) 
- 
usesBodypublic boolean usesBody()Description copied from class:ComponentOverwrite to set if body should be used.
- 
endDescription copied from class:ComponentCallback for the end tag of this component. Should the body be evaluated again?
 NOTE: will pop component stack.
- 
addParameterDescription copied from class:ComponentAdds 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.- Overrides:
- addParameterin class- Component
- Parameters:
- key- the key of the new parameter to add.
- value- the value associated with the key.
 
- 
addParameterDescription copied from interface:Param.UnnamedParametricAdds the given value as a parameter to the outer tag.- Specified by:
- addParameterin interface- Param.UnnamedParametric
- Parameters:
- value- the value
 
 
-