We used getText
in actions, setMessageKey
in validators and
in jsp files for an i18n application.
When Struts 2 cou
You need to create custom implementation of TextProvider
and override getText
methods in it.
1) Create class (e.g. EmptyDefaultTextProvider
) extending one of TextProvider
existing implementations (e.g. TextProviderSupport
).
2) Override all getText
methods like that:
public String getText(String key, String defaultValue) {
return super.getText(key, "");
}
3) Use your custom class as the default text provider. Put below in struts.xml.
<constant name="struts.xworkTextProvider" value="emptyDefaultTextProvider" />
<bean type="com.opensymphony.xwork2.TextProvider" name="emptyDefaultTextProvider"
class="packagepath.EmptyDefaultTextProvider" scope="default" />