svn commit: r1503127 - in /struts/struts2/trunk: ./ apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/ core/src/main/java/org/apache/struts2/dispatcher/mapper/ core/src/test/java/org/apache/strut
Author: rgielen Date: Mon Jul 15 08:02:23 2013 New Revision: 1503127 URL: http://svn.apache.org/r1503127 Log: Merged from STRUTS_2_3_15_X WW-4140 - Lukasz' patch applied [from revision 1502979] Modified: struts/struts2/trunk/ (props changed) struts/struts2/trunk/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java Propchange: struts/struts2/trunk/ -- Merged /struts/struts2/branches/STRUTS_2_3_15_X:r1502979 Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl?rev=1503127&r1=1503126&r2=1503127&view=diff == --- struts/struts2/trunk/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl Mon Jul 15 08:02:23 2013 @@ -37,17 +37,13 @@ <@s.textfield label="Enter Some Text" name="text" /> - <@s.submit name="action:actionPrefix" value="%{'action prefix'}" cssClass="btn" /> + <@s.submit action="actionPrefix" value="%{'action prefix'}" cssClass="btn" /> - <@s.submit name="method:alternateMethod" value="%{'method prefix'}" cssClass="btn" /> - - <@s.submit name="redirect:http://www.google.com"; value="%{'redirect prefix'}" cssClass="btn" /> - - <@s.submit name="redirect-action:redirectActionPrefix" value="%{'redirect-action prefix'}" cssClass="btn" /> + <@s.submit method="alternateMethod" value="%{'method prefix'}" cssClass="btn" /> <@s.submit value="Normal Submit" cssClass="btn" /> - <@s.submit name="action:redirectActionPrefixAction" value="%{'redirect-action without prefix'}" cssClass="btn" /> + <@s.submit action="redirectActionPrefixAction" value="%{'redirectAction without prefix'}" cssClass="btn" /> Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?rev=1503127&r1=1503126&r2=1503127&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java Mon Jul 15 08:02:23 2013 @@ -33,11 +33,15 @@ import org.apache.commons.lang3.StringUt import org.apache.struts2.RequestUtils; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.dispatcher.ServletRedirectResult; import org.apache.struts2.util.PrefixTrie; import javax.servlet.http.HttpServletRequest; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.regex.Pattern; /** @@ -164,8 +168,6 @@ public class DefaultActionMapper impleme protected static final String METHOD_PREFIX = "method:"; protected static final String ACTION_PREFIX = "action:"; -protected static final String REDIRECT_PREFIX = "redirect:"; -protected static final String REDIRECT_ACTION_PREFIX = "redirectAction:"; protected boolean allowDynamicMethodCalls = true; protected boolean allowSlashesInActionNames = false; @@ -186,8 +188,7 @@ public class DefaultActionMapper impleme put(METHOD_PREFIX, new ParameterAction() { public void execute(String key, ActionMapping mapping) { if (allowDynamicMethodCalls) { -mapping.setMethod(key.substring( -METHOD_PREFIX.length())); + mapping.setMethod(key.substring(METHOD_PREFIX.length())); } } }); @@ -203,34 +204,10 @@ public class DefaultActionMapper impleme name = name.substring(0, bang); } } -mapping
svn commit: r1503160 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/interceptor/ core/src/test/java/org/apache/struts2/interceptor/ xwork-core/src/main/java/com/opensymphony/xwork2/
Author: grobmeier Date: Mon Jul 15 10:06:07 2013 New Revision: 1503160 URL: http://svn.apache.org/r1503160 Log: WW-4141: Added support for saving locale in cookie Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java (with props) struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java (with props) Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java Added: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java?rev=1503160&view=auto == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java (added) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java Mon Jul 15 10:06:07 2013 @@ -0,0 +1,176 @@ +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import org.apache.struts2.ServletActionContext; +import org.apache.struts2.StrutsStatics; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; +import java.util.Locale; +import java.util.Map; + +/** + * + * This interceptor extends the original xwork i18n interceptor + * and adds functionality to support cookies. + * + * + * + * + * + * + * + * parameterName (optional) - the name of the HTTP request parameter that dictates the locale to switch to and save + * in the session. By default this is request_locale + * + * requestCookieParameterName (optional) - the name of the HTTP request parameter that dictates the locale to switch to + * and save in a cookien. By default this is request_cookie_locale + * + * requestOnlyParameterName (optional) - the name of the HTTP request parameter that dictates the locale to switch to + * for the current request only, without saving it in the session. By default this is request_only_locale + * + * attributeName (optional) - the name of the session key to store the selected locale. By default this is + * WW_TRANS_I18N_LOCALE + * + * + * + * + * + * + *+ * + * + * + * + */ +public class I18nInterceptor extends com.opensymphony.xwork2.interceptor.I18nInterceptor { +private static final long serialVersionUID = 4587460933182760358L; + +public static final String DEFAULT_COOKIE_ATTRIBUTE = DEFAULT_SESSION_ATTRIBUTE; + +public static final String COOKIE_STORAGE = "cookie"; + +public static final String DEFAULT_COOKIE_PARAMETER = "request_cookie_locale"; +protected String requestCookieParameterName = DEFAULT_COOKIE_PARAMETER; + +protected class CookieLocaleFinder extends LocaleFinder { +protected CookieLocaleFinder(ActionInvocation invocation) { +super(invocation); +} + +@Override +protected void find() { +//get requested locale +Map params = actionInvocation.getInvocationContext().getParameters(); +storage = Storage.SESSION.toString(); + +requestedLocale = findLocaleParameter(params, parameterName); + +if (requestedLocale != null) { +return; +} + +requestedLocale = findLocaleParameter(params, requestCookieParameterName); +if (requestedLocale != null) { +storage = COOKIE_STORAGE; +return; +} + +requestedLocale = findLocaleParameter(params, requestOnlyParameterName); +if (requestedLocale != null) { +stor+ * + * good_result.ftl + *
svn commit: r1503163 - /struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
Author: grobmeier Date: Mon Jul 15 10:13:26 2013 New Revision: 1503163 URL: http://svn.apache.org/r1503163 Log: WW-4128: Document that I18nInterceptor sets the Locale according to browser settings (thanks to Antonio Sánchez) Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java?rev=1503163&r1=1503162&r2=1503163&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java Mon Jul 15 10:13:26 2013 @@ -39,6 +39,8 @@ import java.util.Map; * For example, using the default parameter name, a request to foo.action?request_locale=en_US, then the * locale for US English is saved in the user's session and will be used for all future requests. * + if there is no locale set (for example with the first visit), the interceptor uses the browser locale. + * * * * Interceptor parameters:
svn propchange: r1503163 - svn:log
Author: markt Revision: 1503163 Modified property: svn:log Modified: svn:log at Mon Jul 15 10:29:39 2013 -- --- svn:log (original) +++ svn:log Mon Jul 15 10:29:39 2013 @@ -1 +1,5 @@ -WW-4128: Document that I18nInterceptor sets the Locale according to browser settings (thanks to Antonio Sánchez) +WW-4128: Document that I18nInterceptor sets the Locale according to browser settings (thanks to Antonio Sanchez) + +Note: UTF-8 log messages edited by ASF infra team to work around an installation issue with the + svn server (not an svn bug) that breaks replication from master to slave servers when log + messages contain UTF-8.
svn commit: r1503167 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.jav
Author: grobmeier Date: Mon Jul 15 10:32:37 2013 New Revision: 1503167 URL: http://svn.apache.org/r1503167 Log: WW-4134: MessageStoreInterceptor java.lang.IllegalStateException if there is no session Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java?rev=1503167&r1=1503166&r2=1503167&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java Mon Jul 15 10:32:37 2013 @@ -39,9 +39,12 @@ import com.opensymphony.xwork2.util.logg * * * An interceptor to store a {@link ValidationAware} action's messages / errors and field errors into - * HTTP Session, such that it will be retrieveable at a later stage. This allows the action's message / + * HTTP Session, such that it will be retrievable at a later stage. This allows the action's message / * errors and field errors to be available longer that just the particular HTTP request. * + * If no session exists, nothing will be stored and can be retrieved later. In other terms, + * the application is responsible to open the session. + * * * * In the 'STORE' mode, the interceptor will store the {@link ValidationAware} action's message / errors @@ -56,7 +59,7 @@ import com.opensymphony.xwork2.util.logg * * In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored action's message / errors * and field errors and put them back into the {@link ValidationAware} action, and after Action execution, - * if the {@link Result} is an instance of {@link ServletRedirectResult}, the action's message / errors + * if the {@link com.opensymphony.xwork2.Result} is an instance of {@link ServletRedirectResult}, the action's message / errors * and field errors into automatically be stored in the HTTP session.. * * @@ -147,7 +150,7 @@ import com.opensymphony.xwork2.util.logg */ public class MessageStoreInterceptor extends AbstractInterceptor { -private static final long serialVersionUID = 4491997514314242420L; +private static final long serialVersionUID = 9161650888603380164L; private static final Logger LOG = LoggerFactory.getLogger(MessageStoreInterceptor.class); @@ -219,6 +222,14 @@ public class MessageStoreInterceptor ext if (action instanceof ValidationAware) { // retrieve error / message from session Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION); + +if (session == null) { +if (LOG.isDebugEnabled()) { +LOG.debug("Session is not open, no errors / messages could be retrieve for action ["+action+"]"); +} +return; +} + ValidationAware validationAwareAction = (ValidationAware) action; if (LOG.isDebugEnabled()) { @@ -271,6 +282,13 @@ public class MessageStoreInterceptor ext // store error / messages into session Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION); +if (session == null) { +if (LOG.isDebugEnabled()) { +LOG.debug("Could not store action ["+action+"] error/messages into session, because session hasn't been opened yet."); +} +return; +} + if (LOG.isDebugEnabled()) { LOG.debug("store action ["+action+"] error/messages into session "); } Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java?rev=1503167&r1=1503166&r2=1503167&view=diff == --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java Mon Jul 15 10:32:37 2013 @@ -113,6 +113,45 @@ public class MessageStoreInterceptorTest EasyMock.verify(mockActionInvocation); } +public void testIgnoreMessageWithoutSession() throws Exception { +MessageStoreIntercepto
svn commit: r1503265 - in /struts/sandbox/trunk/struts2examples/annotations/src/main/java: example/ example/actions/ example/actions/HelloAction.java example/actions/RegisterAction.java example/model/
Author: bphillips Date: Mon Jul 15 14:23:23 2013 New Revision: 1503265 URL: http://svn.apache.org/r1503265 Log: changed package name as annotations are ignored when in package org.apache.struts Added: struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/ struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/ struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/HelloAction.java struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/RegisterAction.java struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/model/ struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/model/Person.java Removed: struts/sandbox/trunk/struts2examples/annotations/src/main/java/org/ Added: struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/HelloAction.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/HelloAction.java?rev=1503265&view=auto == --- struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/HelloAction.java (added) +++ struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/HelloAction.java Mon Jul 15 14:23:23 2013 @@ -0,0 +1,48 @@ +package example.actions; + +import org.apache.log4j.Logger; + + +import com.opensymphony.xwork2.ActionSupport; + +/** + * Acts as a controller to handle actions + * related to registering a user. + * @author bruce phillips + * + */ +public class HelloAction extends ActionSupport { + + private static final long serialVersionUID = 1L; + + private static final Logger logger = Logger.getLogger( HelloAction.class.getName() ); + + private String message; + + + public String execute() throws Exception { + + logger.info("In execute method of class Hello"); + + message = "Hello from Struts 2 with no XML configuration."; + + return SUCCESS; + + } + + + public void setMessage(String message) { + this.message = message; + } + + + public String getMessage() { + return message; + } + + + + + + +} Added: struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/RegisterAction.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/RegisterAction.java?rev=1503265&view=auto == --- struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/RegisterAction.java (added) +++ struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/actions/RegisterAction.java Mon Jul 15 14:23:23 2013 @@ -0,0 +1,58 @@ +package example.actions; + +import org.apache.log4j.Logger; +import org.apache.struts2.convention.annotation.Action; + +import com.opensymphony.xwork2.ActionSupport; + +import example.model.Person; + +/** + * Acts as a controller to handle actions + * related to registering a user. + * @author bruce phillips + * + */ +public class RegisterAction extends ActionSupport { + + private static final long serialVersionUID = 1L; + + private static final Logger logger = Logger.getLogger( RegisterAction.class.getName() ); + + private Person personBean; + + @Action("register-input") + public String input() throws Exception { + + logger.info("In input method of class RegisterAction"); + + return INPUT; + + } + + public String execute() throws Exception { + + logger.info("In execute method of class RegisterAction"); + + //call Service class to store personBean's state in database + + return SUCCESS; + + } + + + + + public Person getPersonBean() { + + return personBean; + + } + + public void setPersonBean(Person person) { + + personBean = person; + + } + +} Added: struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/model/Person.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/model/Person.java?rev=1503265&view=auto == --- struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/model/Person.java (added) +++ struts/sandbox/trunk/struts2examples/annotations/src/main/java/example/model/Person.java Mon
[CONF] Confluence Changes in the last 24 hours
Apache ActiveMQ Pages Page: WebSockets edited by Dejan Bosanac[10:09 AM] (view changes) Apache Camel Pages Page: Team edited by Aki Yoshida[09:30 AM] (view changes) Apache Open Climate Workbench Pages Page: Easy-RCMET edited by Shakeh[09:34 PM] (view changes) Page: UI Demo edited by MIchael Joyce[03:54 PM] (view changes) Apache Cloudstack Pages Page: High Availability Developer's Guide created by Chiradeep Vittal[10:16 AM] Page: Ability to delete or archive Events and Alerts edited by Sanjay Tripathi[09:54 AM] (view changes) Page: AWS Style Healthchecks with Netscaler - Second cycle created by Abhinav Roy[07:04 AM] Page: IP Reservation Second cycle created by Abhinav Roy[07:11 AM] Page: Dedicated resources - Public IP Addresses - Second cycle created by Abhinav Roy[07:03 AM] Page: Dedicated Resources - Public Vlans - Second cycle created by Abhinav Roy[07:01 AM] Page: Syslog Enhancements Second Cycle created by Abhinav Roy[06:59 AM] Page: BareMetal test execution result edited by angie shen[03:22 AM] (view changes) Comments Page: Change Account Membership - VM has a new comment [ gavinlee] Page: BareMetal test execution result has a new comment [ angie shen] Apache Curator Pages Page: Third Party Articles edited by Jordan Zimmerman[08:59 PM] (view changes) Apache Flex Pages Page: Release Guide for the SDK edited by Justin Mclean[03:30 AM] (view changes) Apache Hive Pages Page: How to edit the website created by Brock Noland[06:57 PM] Page: LanguageManual UDF edited by Lefty Leverenz[08:00 AM]