svn commit: r1364066 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/ core/src/main/java/org/apache/struts2/config/ core/src/main/java/org/apache/struts2/interceptor/ core/src/main/r
Author: lukaszlenart Date: Sat Jul 21 11:15:34 2012 New Revision: 1364066 URL: http://svn.apache.org/viewvc?rev=1364066&view=rev Log: WW-3552 adds usage of TextProvider to allow provide user's implementation Added: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultLocaleProvider.java Removed: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/interceptor/ Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties struts/struts2/trunk/core/src/main/resources/struts-default.xml struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java?rev=1364066&r1=1364065&r2=1364066&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java Sat Jul 21 11:15:34 2012 @@ -194,6 +194,9 @@ public final class StrutsConstants { /** XWork default text provider */ public static final String STRUTS_XWORKTEXTPROVIDER = "struts.xworkTextProvider"; +/** The {@link com.opensymphony.xwork2.LocaleProvider} implementation class */ +public static final String STRUTS_LOCALE_PROVIDER = "struts.localeProvider"; + /** The name of the parameter to create when mapping an id (used by some action mappers) */ public static final String STRUTS_ID_PARAMETER_NAME = "struts.mapper.idParameterName"; @@ -239,4 +242,5 @@ public final class StrutsConstants { public static final String STRUTS_CONVERTER_DATE = "struts.converter.date"; public static final String STRUTS_CONVERTER_NUMBER = "struts.converter.number"; public static final String STRUTS_CONVERTER_STRING = "struts.converter.string"; + } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java?rev=1364066&r1=1364065&r2=1364066&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java Sat Jul 21 11:15:34 2012 @@ -24,6 +24,7 @@ package org.apache.struts2.config; import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.FileManager; import com.opensymphony.xwork2.FileManagerFactory; +import com.opensymphony.xwork2.LocaleProvider; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.TextProvider; import com.opensymphony.xwork2.UnknownHandlerManager; @@ -180,6 +181,12 @@ import java.util.StringTokenizer; * Allows provide custom TextProvider for whole application * * + * com.opensymphony.xwork2.LocaleProvider + * struts.localeProvider + * singleton + * Allows provide custom TextProvider for whole application + * + * * org.apache.struts2.components.UrlRenderer * struts.urlRenderer * singleton @@ -282,6 +289,7 @@ public class BeanSelectionProvider imple alias(FileManagerFactory.class, StrutsConstants.STRUTS_FILE_MANAGER_FACTORY, builder, props); alias(XWorkConverter.class, StrutsConstants.STRUTS_XWORKCONVERTER, builder, props); alias(TextProvider.class, StrutsConstants.STRUTS_XWORKTEXTPROVIDER, builder, props, Scope.DEFAULT); +alias(LocaleProvider.class, StrutsConstants.STRUTS_LOCALE_PROVIDER, builder, props); alias(ActionProxyFactory.class, StrutsConstants.STRUTS_ACTIONPROXYFACTORY, builder, props); alias(ObjectTypeDeterminer.class, StrutsConstants.STRUTS_OBJECTTYPEDETERMINER, builder, props); alias(ActionMapper.class, StrutsConstants.STRUTS_MAPPER_CLASS, builder, props); Modified: struts/struts2/trunk/co
svn commit: r1364073 - in /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi: BundlePackageLoader.java OsgiConfigurationProvider.java PackageLoader.java
Author: lukaszlenart Date: Sat Jul 21 12:36:57 2012 New Revision: 1364073 URL: http://svn.apache.org/viewvc?rev=1364073&view=rev Log: WW-3851 adds FileManager dependency Modified: struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/PackageLoader.java Modified: struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java?rev=1364073&r1=1364072&r2=1364073&view=diff == --- struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java (original) +++ struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java Sat Jul 21 12:36:57 2012 @@ -21,33 +21,35 @@ package org.apache.struts2.osgi; -import java.io.IOException; -import java.net.URL; -import java.util.*; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - +import com.opensymphony.xwork2.FileManager; import com.opensymphony.xwork2.ObjectFactory; -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; -import com.opensymphony.xwork2.config.PackageProvider; import com.opensymphony.xwork2.config.entities.PackageConfig; import com.opensymphony.xwork2.config.impl.DefaultConfiguration; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; -import com.opensymphony.xwork2.util.location.Location; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** * Package loader implementation that loads resources from a bundle */ public class BundlePackageLoader implements PackageLoader { + private static final Logger LOG = LoggerFactory.getLogger(BundlePackageLoader.class); -public List loadPackages(Bundle bundle, BundleContext bundleContext, ObjectFactory objectFactory, Map pkgConfigs) throws ConfigurationException { +public List loadPackages(Bundle bundle, BundleContext bundleContext, ObjectFactory objectFactory, +FileManager fileManager, Map pkgConfigs) throws ConfigurationException { Configuration config = new DefaultConfiguration("struts.xml"); BundleConfigurationProvider prov = new BundleConfigurationProvider("struts.xml", bundle, bundleContext); for (PackageConfig pkg : pkgConfigs.values()) { Modified: struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java?rev=1364073&r1=1364072&r2=1364073&view=diff == --- struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java (original) +++ struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java Sat Jul 21 12:36:57 2012 @@ -22,6 +22,8 @@ package org.apache.struts2.osgi; import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.FileManager; +import com.opensymphony.xwork2.FileManagerFactory; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; @@ -54,6 +56,7 @@ public class OsgiConfigurationProvider i private Configuration configuration; private ObjectFactory objectFactory; +private FileManager fileManager; private OsgiHost osgiHost; private BundleContext bundleContext; @@ -130,7 +133,7 @@ public class OsgiConfigurationProvider i //XML config PackageLoader loader = new BundlePackageLoader(); -for (PackageConfig pkg : loader.loadPackages(bundle, bundleContext, objectFactory, configuration.getPackageConfigs())) { +for (PackageConfig pkg : loader.loadPackages(bundle, bundleContext, objectFactory, fileManager, configuration.getPackageConfigs())) { configuration.addPackageConfig(pkg.getName(), pkg); bundleAccessor.addPackageFromBundle(bundle, pkg.getName());
svn commit: r1364077 - in /struts/struts2/trunk/core/src/test: java/org/apache/struts2/views/freemarker/ resources/ resources/org/apache/struts2/views/freemarker/ resources/template/test/
Author: lukaszlenart Date: Sat Jul 21 12:57:02 2012 New Revision: 1364077 URL: http://svn.apache.org/viewvc?rev=1364077&view=rev Log: WW-3828 adds additional test to check if dynamic attributes work with custom theme Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl - copied, changed from r1344134, struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl struts/struts2/trunk/core/src/test/resources/template/test/text.ftl Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl struts/struts2/trunk/core/src/test/resources/struts.xml Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java?rev=1364077&r1=1364076&r2=1364077&view=diff == --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java Sat Jul 21 12:57:02 2012 @@ -265,6 +265,33 @@ public class FreeMarkerResultTest extend assertEquals(expected, stringWriter.toString()); } +public void testDynamicAttributesInTheme() throws Exception { +FreemarkerManager freemarkerManager = container.getInstance(FreemarkerManager.class); +Configuration freemarkerConfig = freemarkerManager.getConfiguration(ServletActionContext.getServletContext()); + freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); + +ServletContext servletContext = EasyMock.createNiceMock(ServletContext.class); + +File file = new File(FreeMarkerResultTest.class.getResource("customTextField.ftl").toURI()); + EasyMock.expect(servletContext.getRealPath("/tutorial/org/apache/struts2/views/freemarker/customTextField.ftl")).andReturn(file.getAbsolutePath()); + +file = new File(ClassLoaderUtil.getResource("template/test/text.ftl", getClass()).toURI()); + EasyMock.expect(servletContext.getRealPath("/template/test/text.ftl")).andReturn(file.getAbsolutePath()); + + EasyMock.expect(servletContext.getAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY)).andReturn(freemarkerConfig).anyTimes(); +EasyMock.replay(servletContext); + +freemarkerConfig.setServletContextForTemplateLoading(servletContext, null); +ServletActionContext.setServletContext(servletContext); + +request.setRequestURI("/tutorial/test8.action"); +Dispatcher dispatcher = Dispatcher.getInstance(); +ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(request, dispatcher.getConfigurationManager()); +dispatcher.serviceAction(request, response, servletContext, mapping); +String expected = ""; +assertEquals(expected, stringWriter.toString()); +} + protected void setUp() throws Exception { super.setUp(); mgr = new FreemarkerManager(); Copied: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl (from r1344134, struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl) URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl?p2=struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl&p1=struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl&r1=1344134&r2=1364077&rev=1364077&view=diff == --- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl (original) +++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl Sat Jul 21 12:57:02 2012 @@ -20,6 +20,4 @@ * under the License. */ --> -<@s.radio name="client" id="client_" list='{"foo", "bar"}' /> - -<@s.radio name="car" list={"ford": "Ford Motor Co", "toyota": "Toyota"} listKey="key" listValue="value" /> +<@s.textfield theme="test" autofocus=true /> Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl?rev=1364077&r1=1364076&r2=1364077&view=diff =
svn commit: r1364079 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java test/java/com/opensymphony/xwork2/validator/DefaultAction
Author: lukaszlenart Date: Sat Jul 21 13:12:48 2012 New Revision: 1364079 URL: http://svn.apache.org/viewvc?rev=1364079&view=rev Log: WW-3850 solves problem with NPE when ActionValidationManager is trying to load Object-validation.xml Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java?rev=1364079&r1=1364078&r2=1364079&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java Sat Jul 21 13:12:48 2012 @@ -328,7 +328,7 @@ public class DefaultActionValidatorManag private List loadFile(String fileName, Class clazz, boolean checkFile) { List retList = Collections.emptyList(); URL fileUrl = ClassLoaderUtil.getResource(fileName, clazz); -if ((checkFile && fileManager.fileNeedsReloading(fileUrl.toString())) || !validatorFileCache.containsKey(fileName)) { +if ((checkFile && fileUrl != null && fileManager.fileNeedsReloading(fileUrl.toString())) || !validatorFileCache.containsKey(fileName)) { InputStream is = null; try { Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java?rev=1364079&r1=1364078&r2=1364079&view=diff == --- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java (original) +++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java Sat Jul 21 13:12:48 2012 @@ -18,6 +18,7 @@ package com.opensymphony.xwork2.validato import com.mockobjects.dynamic.C; import com.mockobjects.dynamic.Mock; import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.FileManagerFactory; import com.opensymphony.xwork2.SimpleAction; import com.opensymphony.xwork2.StubValueStack; import com.opensymphony.xwork2.TestBean; @@ -164,6 +165,25 @@ public class DefaultActionValidatorManag mockValidatorFileParser.verify(); } +/** + * Test to verify WW-3850. + * + * @since 2.3.5 + */ +public void testBuildsValidatorsForClassError() { +// for this test we need to have a file manager with reloadingConfigs to true + container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs("true"); +// no validator found, but no check on file since it is not in cache +actionValidatorManager.getValidators(List.class, null); +// this second call will try reload a not existing file +// and causes a NPE (see WW-3850) +try { +actionValidatorManager.getValidators(List.class, null); +} catch (Exception e) { +fail("Exception occurred " + e); +} +} + /* // TODO: this all need to be converted to real unit tests
svn commit: r1364090 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/components/Head.java main/java/org/apache/struts2/components/Radio.java site/resources/tags/head.html site/resour
Author: lukaszlenart Date: Sat Jul 21 13:39:17 2012 New Revision: 1364090 URL: http://svn.apache.org/viewvc?rev=1364090&view=rev Log: WW-3804 enables Radio tag to use dynamic attributes Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java struts/struts2/trunk/core/src/site/resources/tags/head.html struts/struts2/trunk/core/src/site/resources/tags/radio.html Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java?rev=1364090&r1=1364089&r2=1364090&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Head.java Sat Jul 21 13:39:17 2012 @@ -21,14 +21,13 @@ package org.apache.struts2.components; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.struts2.views.annotations.StrutsTag; -import org.apache.struts2.StrutsConstants; - import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.ValueStack; +import org.apache.struts2.StrutsConstants; +import org.apache.struts2.views.annotations.StrutsTag; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** * @@ -48,8 +47,11 @@ import com.opensymphony.xwork2.util.Valu * * */ -@StrutsTag(name="head", tldBodyContent="empty", tldTagClass="org.apache.struts2.views.jsp.ui.HeadTag", -description="Render a chunk of HEAD for your HTML file") +@StrutsTag(name="head", +tldBodyContent="empty", +tldTagClass="org.apache.struts2.views.jsp.ui.HeadTag", +description="Render a chunk of HEAD for your HTML file", +allowDynamicAttributes = true) public class Head extends UIBean { public static final String TEMPLATE = "head"; Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java?rev=1364090&r1=1364089&r2=1364090&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java Sat Jul 21 13:39:17 2012 @@ -52,7 +52,10 @@ import javax.servlet.http.HttpServletRes * * */ -@StrutsTag(name="radio", tldTagClass="org.apache.struts2.views.jsp.ui.RadioTag", description="Renders a radio button input field") +@StrutsTag(name="radio", +tldTagClass="org.apache.struts2.views.jsp.ui.RadioTag", +description="Renders a radio button input field", +allowDynamicAttributes = true) public class Radio extends ListUIBean { final public static String TEMPLATE = "radiomap"; Modified: struts/struts2/trunk/core/src/site/resources/tags/head.html URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/head.html?rev=1364090&r1=1364089&r2=1364090&view=diff == --- struts/struts2/trunk/core/src/site/resources/tags/head.html (original) +++ struts/struts2/trunk/core/src/site/resources/tags/head.html Sat Jul 21 13:39:17 2012 @@ -20,7 +20,7 @@ Please do not edit it directly. - Dynamic Attributes Allowed: false + Dynamic Attributes Allowed: true Modified: struts/struts2/trunk/core/src/site/resources/tags/radio.html URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/radio.html?rev=1364090&r1=1364089&r2=1364090&view=diff == --- struts/struts2/trunk/core/src/site/resources/tags/radio.html (original) +++ struts/struts2/trunk/core/src/site/resources/tags/radio.html Sat Jul 21 13:39:17 2012 @@ -20,7 +20,7 @@ Please do not edit it directly. - Dynamic Attributes Allowed: false + Dynamic Attributes Allowed: true
svn commit: r1364095 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java
Author: lukaszlenart Date: Sat Jul 21 13:49:58 2012 New Revision: 1364095 URL: http://svn.apache.org/viewvc?rev=1364095&view=rev Log: WW-3448 add support for query string in forms Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java?rev=1364095&r1=1364094&r2=1364095&view=diff == --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java Sat Jul 21 13:49:58 2012 @@ -145,6 +145,13 @@ public class ServletUrlRenderer implemen } } +Map actionParams = null; +if (action != null && action.indexOf("?") > 0) { +String queryString = action.substring(action.indexOf("?") + 1); +actionParams = urlHelper.parseQueryString(queryString, false); +action = action.substring(0, action.indexOf("?")); +} + ActionMapping nameMapping = actionMapper.getMappingFromActionName(action); String actionName = nameMapping.getName(); String actionMethod = nameMapping.getMethod(); @@ -155,7 +162,7 @@ public class ServletUrlRenderer implemen ActionMapping mapping = new ActionMapping(actionName, namespace, actionMethod, formComponent.parameters); String result = urlHelper.buildUrl(formComponent.actionMapper.getUriFromActionMapping(mapping), -formComponent.request, formComponent.response, null, null, formComponent.includeContext, true); +formComponent.request, formComponent.response, actionParams, null, formComponent.includeContext, true); formComponent.addParameter("action", result); // let's try to get the actual action class and name
svn commit: r1364110 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/ test/java/com/opensymphony/xwork2/ test/resources/com/opensymphony/xwork2/
Author: lukaszlenart Date: Sat Jul 21 14:47:35 2012 New Revision: 1364110 URL: http://svn.apache.org/viewvc?rev=1364110&view=rev Log: WW-3833 adds new getFormatted method to support localization and conversion errors Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/ActionSupportTest.java struts/struts2/trunk/xwork-core/src/test/resources/com/opensymphony/xwork2/ActionSupportTest$MyActionSupport_da.properties Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java?rev=1364110&r1=1364109&r2=1364110&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java Sat Jul 21 14:47:35 2012 @@ -22,6 +22,7 @@ import com.opensymphony.xwork2.util.logg import com.opensymphony.xwork2.util.logging.LoggerFactory; import java.io.Serializable; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Locale; @@ -134,6 +135,25 @@ public class ActionSupport implements Ac return getTextProvider().getText(key, defaultValue, args, stack); } +/** + * Dedicated method to support I10N and conversion errors + * + * @param key message which contains formatting string + * @param expr that should be formatted + * @return formatted expr with format specified by key + */ +public String getFormatted(String key, String expr) { +Map conversionErrors = ActionContext.getContext().getConversionErrors(); +if (conversionErrors.containsKey(expr)) { +String[] vals = (String[]) conversionErrors.get(expr); +return vals[0]; +} else { +final ValueStack valueStack = ActionContext.getContext().getValueStack(); +final Object val = valueStack.findValue(expr); +return getText(key, Arrays.asList(val)); +} +} + public ResourceBundle getTexts() { return getTextProvider().getTexts(); } Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/ActionSupportTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/ActionSupportTest.java?rev=1364110&r1=1364109&r2=1364110&view=diff == --- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/ActionSupportTest.java (original) +++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/ActionSupportTest.java Sat Jul 21 14:47:35 2012 @@ -313,8 +313,35 @@ public class ActionSupportTest extends X assertEquals(rb, mas.getTexts(MyActionSupport.class.getName())); } +public void testFormattingSupport() throws Exception { +ActionContext.getContext().setLocale(new Locale("da")); +MyActionSupport mas = new MyActionSupport(); +ActionContext.getContext().getValueStack().push(mas); + +mas.setVal(234d); + +String formatted = mas.getFormatted("format.number", "val"); + +assertEquals("234,0", formatted); +} + +public void testFormattingSupportWithConversionError() throws Exception { +ActionContext.getContext().getConversionErrors().put("val", new String[]{"4567def"}); +ActionContext.getContext().setLocale(new Locale("da")); +MyActionSupport mas = new MyActionSupport(); +ActionContext.getContext().getValueStack().push(mas); + +mas.setVal(234d); + +String formatted = mas.getFormatted("format.number", "val"); + +assertEquals("4567def", formatted); +} + private class MyActionSupport extends ActionSupport { +private Double val; + @Override public String doDefault() throws Exception { return "santa"; @@ -325,6 +352,14 @@ public class ActionSupportTest extends X super.validate(); // to have code coverage addActionMessage("validation was called"); } + +public Double getVal() { +return val; +} + +public void setVal(Double val) { +this.val = val; +} } } Modified: struts/struts2/trunk/xwork-core/src/test/resources/com/opensymphony/xwork2/ActionSupportTest$MyActionSupport_da.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/resources/com/opensymphony/xwork2/ActionSupportTest%24MyActionSupport_da.properties?rev=1364110&r1=1364109&r2=1364110&view=diff ===
[CONF] Confluence Changes in the last 24 hours
This is a daily summary of all recent changes in Confluence. - Updated Spaces: - Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL) Pages - CMIS created by bibryam (02:40 PM) https://cwiki.apache.org/confluence/display/CAMEL/CMIS AWS-DDB edited by bibryam (01:23 PM) https://cwiki.apache.org/confluence/display/CAMEL/AWS-DDB OFBiz (Open For Business) Project Open Wiki (https://cwiki.apache.org/confluence/display/OFBIZ) Pages - Apache OFBiz User List edited by venkatmang...@gmail.com (12:47 PM) https://cwiki.apache.org/confluence/display/OFBIZ/Apache+OFBiz+User+List Apache Qpid (https://cwiki.apache.org/confluence/display/qpid) Pages - 0.18 Release edited by justi9 (07:35 PM) https://cwiki.apache.org/confluence/display/qpid/0.18+Release Apache Struts 2 Plugin Registry (https://cwiki.apache.org/confluence/display/S2PLUGINS) Pages - Struts2 Conversation Scope Plugin v1.7.1 Released created by rees.byars (10:53 AM) https://cwiki.apache.org/confluence/display/S2PLUGINS/Struts2+Conversation+Scope+Plugin+v1.7.1+Released Apache Shiro (https://cwiki.apache.org/confluence/display/SHIRO) Pages - Version 2 Brainstorming edited by lhazlewood (08:45 PM) https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming Apache Tapestry (https://cwiki.apache.org/confluence/display/TAPESTRY) Pages - Download edited by bobharner (10:52 AM) https://cwiki.apache.org/confluence/display/TAPESTRY/Download Apache Wicket (https://cwiki.apache.org/confluence/display/WICKET) Pages - Wicket Ajax edited by mgrigorov (09:36 AM) https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax Apache Struts 2 Documentation (https://cwiki.apache.org/confluence/display/WW) Pages - Formatting Dates and Numbers edited by lukaszlenart (10:46 AM) https://cwiki.apache.org/confluence/display/WW/Formatting+Dates+and+Numbers Change your notification preferences: https://cwiki.apache.org/confluence/users/viewnotifications.action