struts2 - Change Struts 2, i18n classes behavior when key is not found -


we used gettext in actions, setmessagekey in validators , <s:text> in jsp files i18n application.

when struts 2 not find key in resource bundles returns key itself. example form.transfer.confirm.

how can change behavior in way instead of key struts2 returns empty string.

you need create custom implementation of textprovider , override gettext methods in it.

1) create class (e.g. emptydefaulttextprovider) extending 1 of textprovider existing implementations (e.g. textprovidersupport).

2) override gettext methods that:

public string gettext(string key, string defaultvalue) {      return super.gettext(key, ""); } 

3) use custom class 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" /> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -