You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Tom Briers (JIRA)" <ji...@apache.org> on 2013/08/21 15:31:52 UTC

[jira] [Commented] (WW-4179) Error messages from JakartaMultiPartRequest are not in the correct language

    [ https://issues.apache.org/jira/browse/WW-4179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13746037#comment-13746037 ] 

Tom Briers commented on WW-4179:
--------------------------------

I have been investigating this issue further and was thinking about the following solution for my application.  The idea is to implement my own DefaultLocaleProvider which would check to see if it can find a locale in the session of the ActionContext.

The implementation would look as follows:

{code:title=I18nDefaultLocaleProvider.java}
public class I18nDefaultLocaleProvider
	implements LocaleProvider
{

	private final static Logger LOG = LoggerFactory.getLogger(I18nDefaultLocaleProvider.class);

	@Override
	public Locale getLocale()
	{
		ActionContext ctx = ActionContext.getContext();
		if (ctx != null)
		{
			Locale sessionLocale = (Locale) ctx.getSession().get("some constant in the session, might be the one found in the I18nInterceptor");
			if (sessionLocale != null)
			{
				return sessionLocale;
			}
			else
			{
				return ctx.getLocale();
			}
		}
		else
		{
			if (LOG.isDebugEnabled())
			{
				LOG.debug("Action context not initialized");
			}
			return null;
		}
	}
}
{code}

However, I'm unable to test this because I cannot find any way to override the DefaultLocaleProvider implementation used by struts2.

_Is there a way to override this?_

Also, since I cannot test this, I'm assuming the ActionContext recovered at this point in the execution chain already contains the correct context to recover the session.
                
> Error messages from JakartaMultiPartRequest are not in the correct language
> ---------------------------------------------------------------------------
>
>                 Key: WW-4179
>                 URL: https://issues.apache.org/jira/browse/WW-4179
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.3.15.1
>            Reporter: Tom Briers
>
> When we upload a file that exceeds the `struts.multipart.maxSize` we don't get the message in the correct language.
> This seems to be due to the fact that the interceptors are executed after the parse method (including i18n) meaning the correct locale is not yet available.
> Is there a way to fix this or to get around this limitation?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira