Author: sletellier Date: 2011-10-11 15:07:34 +0200 (Tue, 11 Oct 2011) New Revision: 137 Url: http://chorem.org/repositories/revision/vradi/137 Log: Make vradiBaseAction extend org.nuiton.web.struts2.BaseAction Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/VradiBaseAction.java Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/VradiBaseAction.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/VradiBaseAction.java 2011-10-11 13:01:38 UTC (rev 136) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/VradiBaseAction.java 2011-10-11 13:07:34 UTC (rev 137) @@ -1,11 +1,7 @@ package org.chorem.vradi.actions; -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.util.ValueStack; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.List; import java.util.Map; import org.apache.struts2.interceptor.SessionAware; import org.chorem.vradi.VradiSession; @@ -13,17 +9,16 @@ import org.chorem.vradi.entities.VradiUser; import org.chorem.vradi.services.VradiDataService; import org.nuiton.util.ApplicationConfig; +import org.nuiton.web.struts2.BaseAction; import org.nuiton.wikitty.WikittyProxy; /** - * TODO sletellier 20110519 : move this method to nuiton utils web - * * Base class which must be extended by every action * Overrides the Struts2 methods to render text in order to explicitly show * the missing i18n translations * Allows access to the session and the proxy */ -public class VradiBaseAction extends ActionSupport implements SessionAware { +public class VradiBaseAction extends BaseAction implements SessionAware { private static final long serialVersionUID = 1L; @@ -41,10 +36,9 @@ protected static final String CONTEXT_ACTION_KEY = "action"; protected static final String CONTEXT_SELECTED_QUERY_KEY = "selectedQuery"; - public static final String UNTRANSLATED_MARKER = "???"; - - protected Map<String, Object> session; + protected transient Map<String, Object> session; + @Override public void setSession(Map<String, Object> session) { this.session = session; @@ -75,77 +69,4 @@ public ApplicationConfig getConfig() { return VradiWebConfig.getConfig(); } - - @Override - public String getText(String aTextName) { - String value = super.getText(aTextName); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String aTextName, String defaultValue) { - String value = super.getText(aTextName, defaultValue); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String aTextName, String defaultValue, String obj) { - String value = super.getText(aTextName, defaultValue, obj); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String aTextName, List<?> args) { - String value = super.getText(aTextName, args); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String key, String[] args) { - String value = super.getText(key, args); - return getSafeText(key, value); - } - - @Override - public String getText(String aTextName, String defaultValue, List<?> args) { - String value = super.getText(aTextName, defaultValue, args); - return getSafeText(aTextName, value); - } - - @Override - public String getText(String key, String defaultValue, String[] args) { - String value = super.getText(key, defaultValue, args); - return getSafeText(key, value); - } - - @Override - public String getText(String key, String defaultValue, List<?> args, - ValueStack stack) { - String value = super.getText(key, defaultValue, args, stack); - return getSafeText(key, value); - } - - @Override - public String getText(String key, String defaultValue, String[] args, - ValueStack stack) { - String value = super.getText(key, defaultValue, args, stack); - return getSafeText(key, value); - } - - /** - * Surrounds the non translated keys with a marker to make them visible - * - * @param key i18n key - * @param value text to check - * @return translated text - */ - protected String getSafeText(String key, String value) { - if (StringUtils.isEmpty(value)) { - if (log.isWarnEnabled()) { - log.warn("Key [" + key + "] is not translated"); - } - return UNTRANSLATED_MARKER + key + UNTRANSLATED_MARKER; - } - return value; - } } \ No newline at end of file