From issues-return-16504-apmail-struts-issues-archive=struts.apache.org@struts.apache.org Sun Oct 9 02:47:58 2011 Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D3E79F63 for ; Sun, 9 Oct 2011 02:47:58 +0000 (UTC) Received: (qmail 51031 invoked by uid 500); 9 Oct 2011 02:47:58 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 50897 invoked by uid 500); 9 Oct 2011 02:47:57 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 50890 invoked by uid 99); 9 Oct 2011 02:47:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Oct 2011 02:47:56 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Oct 2011 02:47:50 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B002C2B009C for ; Sun, 9 Oct 2011 02:47:29 +0000 (UTC) Date: Sun, 9 Oct 2011 02:47:29 +0000 (UTC) From: "tim shaw (Commented) (JIRA)" To: issues@struts.apache.org Message-ID: <339246890.12218.1318128449722.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1297535969.11291.1318073549744.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (WW-3690) i18n don't work in jsp pages (accessed directly) when locale changed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-3690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13123600#comment-13123600 ] tim shaw commented on WW-3690: ------------------------------ get it. thanks, > i18n don't work in jsp pages (accessed directly) when locale changed > -------------------------------------------------------------------- > > Key: WW-3690 > URL: https://issues.apache.org/jira/browse/WW-3690 > Project: Struts 2 > Issue Type: Bug > Components: Dispatch Filter, Expression Language, Value Stack > Affects Versions: 2.1.8.1 > Environment: tomcat 6.x, java jre1.5 , struts-2.1.8.1 + xwork-2.1.6 > Reporter: tim shaw > Priority: Critical > Labels: i18n, locale, > Attachments: localesetting problem.jpg, testlocal.zip > > > i found i18n tags in jsp pages rendered by action result work fine, but those in jsp pages accessed directly( for example http://localhost/abc/xyz.jsp) can't work properly according to the locale info which already set by the ActionContext.setLocale(locale).or ActionContext.getSession().set("WW_TRANS_I18N_LOCALE",locale) in some action.execute() method before. > in my humble opinion, all of tags in jsp pages ( both accessed directly and rendered by some action result) should work in accordance with some locale take procedences like that: > 1: evaluate the request locale. if there is no locale info,then: > 2: evaluate the session locale, if there is no locale info ,then: > 3: evaluate the default locale configed by StrutsConstants.STRUTS_LOCALE > 4: if there are still no locale info ,then jre system properties will give a hand. > IS IT RIGHT? > to found the problem, i navigated some code snipes about the locale in struts 2.1.8.1 > StrutsPrepareAndExecuteFilter.doFilter method line 78: prepare.createActionContext(request, response); => > PrepareOperations(Line 78) stack.getContext().putAll(dispatcher.createContextMap(request, response, null, servletContext)); => > Dispatcher(Line 535) Map extraContext = createContextMap(requestMap, params, session, application, request, response, context); => > Dispatcher.createContextMap (line 568) > Locale locale; > if (defaultLocale != null) { > locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale()); > } else { > locale = request.getLocale(); > } > here,locale will take precedence like that,first defaultLocale,then request.getLocale(). > and thre result locale will be set in the ActionContext.setLocale() > at last the jsp i18n tags' propertes evaluated by DefaultTextProvider.getText(String),Here is the code: > DefaultTextProvider.java(Line 37 xwork-2.1.6.jar): > return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale()); > and i read the i18ninterceptor ,it will populate the ActionContext.locale by the session locale if no local info given by the current request. (but as we know ,all interceptor will execute only when we access some action!) > so from then on, it seemed that i found the weird i18n tags in direct accessed JSP pages, because there are no further process for these direct accessed jsp pages ,just like the i18ninterceptor for actions. > is there anything i missd or Is is a bug? > btw,my english could be better,sorry for that. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira