Compare commits

..

1 Commits

Author SHA1 Message Date
Ted Nathan Husted df365f17ea WW-1650 Tag r500931 as Struts 2.0.4
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_4@500932 13f79535-47bb-0310-9956-ffa450edef68
2007-01-29 03:40:41 +00:00
96 changed files with 746 additions and 1440 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-api</artifactId>
@@ -1,23 +1,3 @@
/*
* $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;
/**
@@ -1,23 +1,3 @@
/*
* $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;
/**
@@ -1,23 +1,3 @@
/*
* $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;
import java.util.List;
@@ -1,23 +1,3 @@
/*
* $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;
/**
@@ -1,23 +1,3 @@
/*
* $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;
import org.apache.struts2.MessageAware;
@@ -1,23 +1,3 @@
/*
* $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.servlet;
import java.util.Map;
@@ -1,23 +1,3 @@
/*
* $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.servlet;
import javax.servlet.http.HttpServletRequest;
@@ -1,23 +1,3 @@
/*
* $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.servlet;
import javax.servlet.http.HttpServletResponse;
@@ -1,23 +1,3 @@
/*
* $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.spi;
import java.lang.reflect.Method;
@@ -1,23 +1,3 @@
/*
* $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.spi;
/**
@@ -1,23 +1,3 @@
/*
* $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.spi;
import org.apache.struts2.Messages;
@@ -1,23 +1,3 @@
/*
* $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.spi;
import org.apache.struts2.spi.RequestContext;
@@ -1,23 +1,3 @@
/*
* $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.spi;
import org.apache.struts2.spi.RequestContext;
@@ -1,23 +1,3 @@
/*
* $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.spi;
/**
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-blank</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-mailreader</artifactId>
+1 -1
View File
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-showcase</artifactId>
@@ -1,23 +1,3 @@
/*
* $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.showcase.freemarker;
import com.opensymphony.xwork2.ActionSupport;
+1 -1
View File
@@ -33,7 +33,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<scm>
+4 -3
View File
@@ -1,3 +1,4 @@
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/struts2-core-2.0.4.jar -destjar struts2-core-j4-2.0.4.jar
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/struts2-api-2.0.4.jar -destjar struts2-api-j4-2.0.4.jar
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/xwork-2.0.0.jar -destjar xwork-j4-2.0.0.jar
java -jar retrotranslator-transformer-1.1.0.jar -srcjar ../lib/struts2-core-2.0.3.jar -destjar struts2-core-j4-2.0.3.jar
java -jar retrotranslator-transformer-1.1.0.jar -srcjar ../lib/struts2-api-2.0.3.jar -destjar struts2-api-j4-2.0.3.jar
java -jar retrotranslator-transformer-1.1.0.jar -srcjar ../lib/struts2-extras-2.0.3.jar -destjar struts2-extras-j4-2.0.3.jar
java -jar retrotranslator-transformer-1.1.0.jar -srcjar ../lib/xwork-2.0.0.jar -destjar xwork-j4-2.0.0-RC1.jar
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
@@ -264,7 +264,7 @@
<dependency>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.8</version>
<version>2.3.4</version>
</dependency>
<dependency>
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: StrutsTestCase.java 476696 2006-11-19 03:56:18Z tmjee $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -60,6 +60,6 @@ public class DoubleSelect extends DoubleListUIBean {
super.evaluateExtraParams();
// force the onchange parameter
addParameter("onchange", getParameters().get("id") + "Redirect(this.options.selectedIndex)");
addParameter("onchange", getParameters().get("name") + "Redirect(this.options.selectedIndex)");
}
}
@@ -32,8 +32,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
/**
@@ -92,11 +90,6 @@ public class OptGroup extends Component {
}
};
}
@Inject
public void setContainer(Container container) {
container.inject(internalUiBean);
}
public boolean end(Writer writer, String body) {
Select select = (Select) findAncestor(Select.class);
@@ -1,23 +1,3 @@
/*
* $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.components;
@@ -20,13 +20,9 @@
*/
package org.apache.struts2.components;
import java.io.Writer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -137,9 +133,6 @@ import com.opensymphony.xwork2.util.ValueStack;
*/
@StrutsTag(name="submit", tldTagClass="org.apache.struts2.views.jsp.ui.SubmitTag", description="Render a submit button")
public class Submit extends FormButton implements RemoteUICallBean{
private static final Log LOG = LogFactory.getLog(Submit.class);
final public static String TEMPLATE = "submit";
protected String href;
@@ -224,25 +217,6 @@ public class Submit extends FormButton implements RemoteUICallBean{
protected boolean supportsImageType() {
return true;
}
/**
* Overrides to be able to render body in a template rather than always before the template
*/
public boolean end(Writer writer, String body) {
evaluateParams();
try {
addParameter("body", body);
mergeTemplate(writer, buildTemplateName(template, getDefaultTemplate()));
} catch (Exception e) {
LOG.error("error when rendering", e);
}
finally {
popComponentStack();
}
return false;
}
@StrutsTagAttribute(description="Topic that will trigger the remote call")
public void setListenTopics(String listenTopics) {
@@ -289,11 +289,6 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider {
PackageConfig pkgConfig = loadPackageConfig(actionNamespace, actionPackage, cls);
// In case the package changed due to namespace annotation processing
if (!actionPackage.equals(pkgConfig.getName())) {
actionPackage = pkgConfig.getName();
}
Annotation annotation = cls.getAnnotation(ParentPackage.class);
if (annotation != null) {
String parent = ((ParentPackage)annotation).value();
@@ -328,6 +323,7 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider {
actionConfig.setPackageName(actionPackage);
actionConfig.setResults(new ResultMap<String,ResultConfig>(cls, actionName, pkgConfig));
pkgConfig.addActionConfig(actionName, actionConfig);
}
@@ -481,6 +477,33 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider {
return map;
}
/**
* Retrieve ResultConfig from cache.
*
* @param key Name of ResultConfig
* @return ResultConfig correspnding to key
*/
public V get(Object key) {
V result = super.get(key);
if (result != null) {
return result;
} else {
// This code should never actually be called,
// due to how the runtime configuration is created.
String actionPath = pkgConfig.getNamespace() + "/" + actionName;
String fileName = actionPath + "-" + key + defaultPageExtension;
if (pageLocator.locate(defaultPagePrefix + fileName) == null) {
fileName = actionPath + defaultPageExtension;
}
String location = defaultPagePrefix + fileName;
return (V) createResultConfig(key, null, location, null);
}
}
/**
* Creates a default ResultConfig,
* using either the resultClass or the default ResultType for configuration package
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: DefaultActionMapper.java 498085 2007-01-20 08:13:11Z mrdon $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,259 +1,239 @@
/*
* $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.config;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.RuntimeConfiguration;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import com.opensymphony.xwork2.ObjectFactory;
import java.util.*;
import java.lang.reflect.Method;
/**
* MethodConfigurationProvider creates ActionConfigs for potential action
* methods that lack a corresponding action mapping,
* so that these methods can be invoked without extra or redundant configuration.
* <p/>
* As a dynamic method, the behavior of this class could be represented as:
* <p/>
* <code>
* int bang = name.indexOf('!');
* if (bang != -1) {
* String method = name.substring(bang + 1);
* mapping.setMethod(method);
* name = name.substring(0, bang);
* }
* </code>
* <p/>
* If the action URL is "foo!bar", the the "foo" action is invoked,
* calling "bar" instead of "execute".
* <p/>
* Instead of scanning each request at runtime, the provider creates action mappings
* for each method that could be matched using a dynamic approach.
* Advantages over a dynamic approach are that:
* <p/>
* <ul>
* <ol>The "dynamic" methods are not a special case, but just another action mapping,
* with all the features of a hardcoded mapping.
* <ol>When needed, a manual action can be provided for a method and invoked with the same
* syntax as an automatic action.
* <ol>The ConfigBrowser can display all potential actions.
* </ul>
*/
public class MethodConfigurationProvider implements ConfigurationProvider {
/**
* Stores configuration property.
*/
private Configuration configuration;
/**
* Updates configuration property.
* @param configuration New configuration
*/
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
// See superclass for Javadoc
public void destroy() {
// Override to provide functionality
}
// See superclass for Javadoc
public void init(Configuration configuration) throws ConfigurationException {
setConfiguration(configuration);
configuration.rebuildRuntimeConfiguration();
}
// See superclass for Javadoc
public void register(ContainerBuilder containerBuilder, LocatableProperties locatableProperties) throws ConfigurationException {
// Override to provide functionality
}
// See superclass for Javadoc
public void loadPackages() throws ConfigurationException {
Set namespaces = Collections.EMPTY_SET;
RuntimeConfiguration rc = configuration.getRuntimeConfiguration();
Map allActionConfigs = rc.getActionConfigs();
if (allActionConfigs != null) {
namespaces = allActionConfigs.keySet();
}
if (namespaces.size() == 0) {
throw new ConfigurationException("MethodConfigurationProvider.loadPackages: namespaces.size == 0");
}
boolean added = false;
for (Object namespace : namespaces) {
Map actions = (Map) allActionConfigs.get(namespace);
Set actionNames = actions.keySet();
for (Object actionName : actionNames) {
ActionConfig actionConfig = (ActionConfig) actions.get(actionName);
added = added | addDynamicMethods(actions, (String) actionName, actionConfig);
}
}
reload = added;
}
/**
* Store needsReload property.
*/
boolean reload;
// See superclass for Javadoc
public boolean needsReload() {
return reload;
}
/**
* Stores ObjectFactory property.
*/
ObjectFactory factory;
/**
* Updates ObjectFactory property.
* @param factory
*/
public void setObjectFactory(ObjectFactory factory) {
this.factory = factory;
}
/**
* Provides ObjectFactory property.
* @return
* @throws ConfigurationException if ObjectFactory has not been set.
*/
private ObjectFactory getObjectFactory() throws ConfigurationException {
if (factory == null) {
factory = ObjectFactory.getObjectFactory();
if (factory == null) throw new
ConfigurationException("MethodConfigurationProvider.getObjectFactory: ObjectFactory==null");
}
return factory;
}
/**
* Verifies that character at a String position is upper case.
* @param pos Position to test
* @param string Text containing position
* @return True if character at a String position is upper case
*/
private boolean upperAt(int pos, String string) {
int len = string.length();
if (len < pos) return false;
String ch = string.substring(pos, pos+1);
return ch.equals(ch.toUpperCase());
}
/**
* Scans class for potential Action mehods,
* automatically generating and registering ActionConfigs as needed.
* <p/>
* The system iterates over the set of namespaces and the set of actionNames
* in a Configuration and retrieves each ActionConfig.
* For each ActionConfig that invokes the default "execute" method,
* the provider inspects the className class for other non-void,
* no-argument methods that do not begin with "getX" or "isX".
* For each qualifying method, the provider looks for another actionName in
* the same namespace that equals action.name + "!" + method.name.
* If that actionName is not found, System copies the ActionConfig,
* changes the method property, and adds it to the package configuration
* under the new actionName (action!method).
* <p/>
* The system ignores ActionConfigs with a method property set so as to
* avoid creating alias methods for alias methods.
* The system ignores "getX" and "isX" methods since these would appear to be
* JavaBeans property and would not be intended as action methods.
* (The X represents any upper character or non-letter.)
* @param actions All ActionConfigs in namespace
* @param actionName Name of ActionConfig to analyze
* @param actionConfig ActionConfig corresponding to actionName
*/
protected boolean addDynamicMethods(Map actions, String actionName, ActionConfig actionConfig) throws ConfigurationException {
String configMethod = actionConfig.getMethodName();
boolean hasMethod = (configMethod != null) && (configMethod.length() > 0);
if (hasMethod) return false;
String className = actionConfig.getClassName();
Set actionMethods = new HashSet();
Class actionClass;
ObjectFactory factory = getObjectFactory();
try {
actionClass = factory.getClassInstance(className);
} catch (ClassNotFoundException e) {
throw new ConfigurationException(e);
}
Method[] methods = actionClass.getMethods();
for (Method method : methods) {
String returnString = method.getReturnType().getName();
boolean isString = "java.lang.String".equals(returnString);
if (isString) {
Class[] parameterTypes = method.getParameterTypes();
boolean noParameters = (parameterTypes.length == 0);
String methodString = method.getName();
boolean notGetMethod = !((methodString.startsWith("get")) && upperAt(3, methodString));
boolean notIsMethod = !((methodString.startsWith("is")) && upperAt(2, methodString));
boolean notToString = !("toString".equals(methodString));
boolean notExecute = !("execute".equals(methodString));
boolean qualifies = noParameters && notGetMethod && notIsMethod && notToString && notExecute;
if (qualifies) {
actionMethods.add(methodString);
}
}
}
for (Object actionMethod : actionMethods) {
String methodName = (String) actionMethod;
StringBuilder sb = new StringBuilder();
sb.append(actionName);
sb.append("!"); // TODO: Make "!" a configurable character
sb.append(methodName);
String newActionName = sb.toString();
boolean haveAction = actions.containsKey(newActionName);
if (haveAction) continue;
ActionConfig newActionConfig = new ActionConfig(
newActionName,
actionConfig.getClassName(),
actionConfig.getParams(),
actionConfig.getResults(),
actionConfig.getInterceptors(),
actionConfig.getExceptionMappings());
newActionConfig.setMethodName(methodName);
String packageName = actionConfig.getPackageName();
newActionConfig.setPackageName(packageName);
PackageConfig packageConfig = configuration.getPackageConfig(packageName);
packageConfig.addActionConfig(newActionName, actionConfig);
}
return (actionMethods.size() > 0);
}
}
package org.apache.struts2.config;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.RuntimeConfiguration;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import com.opensymphony.xwork2.ObjectFactory;
import java.util.*;
import java.lang.reflect.Method;
/**
* MethodConfigurationProvider creates ActionConfigs for potential action
* methods that lack a corresponding action mapping,
* so that these methods can be invoked without extra or redundant configuration.
* <p/>
* As a dynamic method, the behavior of this class could be represented as:
* <p/>
* <code>
* int bang = name.indexOf('!');
* if (bang != -1) {
* String method = name.substring(bang + 1);
* mapping.setMethod(method);
* name = name.substring(0, bang);
* }
* </code>
* <p/>
* If the action URL is "foo!bar", the the "foo" action is invoked,
* calling "bar" instead of "execute".
* <p/>
* Instead of scanning each request at runtime, the provider creates action mappings
* for each method that could be matched using a dynamic approach.
* Advantages over a dynamic approach are that:
* <p/>
* <ul>
* <ol>The "dynamic" methods are not a special case, but just another action mapping,
* with all the features of a hardcoded mapping.
* <ol>When needed, a manual action can be provided for a method and invoked with the same
* syntax as an automatic action.
* <ol>The ConfigBrowser can display all potential actions.
* </ul>
*/
public class MethodConfigurationProvider implements ConfigurationProvider {
/**
* Stores configuration property.
*/
private Configuration configuration;
/**
* Updates configuration property.
* @param configuration New configuration
*/
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
// See superclass for Javadoc
public void destroy() {
// Override to provide functionality
}
// See superclass for Javadoc
public void init(Configuration configuration) throws ConfigurationException {
setConfiguration(configuration);
configuration.rebuildRuntimeConfiguration();
}
// See superclass for Javadoc
public void register(ContainerBuilder containerBuilder, LocatableProperties locatableProperties) throws ConfigurationException {
// Override to provide functionality
}
// See superclass for Javadoc
public void loadPackages() throws ConfigurationException {
Set namespaces = Collections.EMPTY_SET;
RuntimeConfiguration rc = configuration.getRuntimeConfiguration();
Map allActionConfigs = rc.getActionConfigs();
if (allActionConfigs != null) {
namespaces = allActionConfigs.keySet();
}
if (namespaces.size() == 0) {
throw new ConfigurationException("MethodConfigurationProvider.loadPackages: namespaces.size == 0");
}
boolean added = false;
for (Object namespace : namespaces) {
Map actions = (Map) allActionConfigs.get(namespace);
Set actionNames = actions.keySet();
for (Object actionName : actionNames) {
ActionConfig actionConfig = (ActionConfig) actions.get(actionName);
added = added | addDynamicMethods(actions, (String) actionName, actionConfig);
}
}
reload = added;
}
/**
* Store needsReload property.
*/
boolean reload;
// See superclass for Javadoc
public boolean needsReload() {
return reload;
}
/**
* Stores ObjectFactory property.
*/
ObjectFactory factory;
/**
* Updates ObjectFactory property.
* @param factory
*/
public void setObjectFactory(ObjectFactory factory) {
this.factory = factory;
}
/**
* Provides ObjectFactory property.
* @return
* @throws ConfigurationException if ObjectFactory has not been set.
*/
private ObjectFactory getObjectFactory() throws ConfigurationException {
if (factory == null) {
factory = ObjectFactory.getObjectFactory();
if (factory == null) throw new
ConfigurationException("MethodConfigurationProvider.getObjectFactory: ObjectFactory==null");
}
return factory;
}
/**
* Verifies that character at a String position is upper case.
* @param pos Position to test
* @param string Text containing position
* @return True if character at a String position is upper case
*/
private boolean upperAt(int pos, String string) {
int len = string.length();
if (len < pos) return false;
String ch = string.substring(pos, pos+1);
return ch.equals(ch.toUpperCase());
}
/**
* Scans class for potential Action mehods,
* automatically generating and registering ActionConfigs as needed.
* <p/>
* The system iterates over the set of namespaces and the set of actionNames
* in a Configuration and retrieves each ActionConfig.
* For each ActionConfig that invokes the default "execute" method,
* the provider inspects the className class for other non-void,
* no-argument methods that do not begin with "getX" or "isX".
* For each qualifying method, the provider looks for another actionName in
* the same namespace that equals action.name + "!" + method.name.
* If that actionName is not found, System copies the ActionConfig,
* changes the method property, and adds it to the package configuration
* under the new actionName (action!method).
* <p/>
* The system ignores ActionConfigs with a method property set so as to
* avoid creating alias methods for alias methods.
* The system ignores "getX" and "isX" methods since these would appear to be
* JavaBeans property and would not be intended as action methods.
* (The X represents any upper character or non-letter.)
* @param actions All ActionConfigs in namespace
* @param actionName Name of ActionConfig to analyze
* @param actionConfig ActionConfig corresponding to actionName
*/
protected boolean addDynamicMethods(Map actions, String actionName, ActionConfig actionConfig) throws ConfigurationException {
String configMethod = actionConfig.getMethodName();
boolean hasMethod = (configMethod != null) && (configMethod.length() > 0);
if (hasMethod) return false;
String className = actionConfig.getClassName();
Set actionMethods = new HashSet();
Class actionClass;
ObjectFactory factory = getObjectFactory();
try {
actionClass = factory.getClassInstance(className);
} catch (ClassNotFoundException e) {
throw new ConfigurationException(e);
}
Method[] methods = actionClass.getMethods();
for (Method method : methods) {
String returnString = method.getReturnType().getName();
boolean isString = "java.lang.String".equals(returnString);
if (isString) {
Class[] parameterTypes = method.getParameterTypes();
boolean noParameters = (parameterTypes.length == 0);
String methodString = method.getName();
boolean notGetMethod = !((methodString.startsWith("get")) && upperAt(3, methodString));
boolean notIsMethod = !((methodString.startsWith("is")) && upperAt(2, methodString));
boolean notToString = !("toString".equals(methodString));
boolean notExecute = !("execute".equals(methodString));
boolean qualifies = noParameters && notGetMethod && notIsMethod && notToString && notExecute;
if (qualifies) {
actionMethods.add(methodString);
}
}
}
for (Object actionMethod : actionMethods) {
String methodName = (String) actionMethod;
StringBuilder sb = new StringBuilder();
sb.append(actionName);
sb.append("!"); // TODO: Make "!" a configurable character
sb.append(methodName);
String newActionName = sb.toString();
boolean haveAction = actions.containsKey(newActionName);
if (haveAction) continue;
ActionConfig newActionConfig = new ActionConfig(
newActionName,
actionConfig.getClassName(),
actionConfig.getParams(),
actionConfig.getResults(),
actionConfig.getInterceptors(),
actionConfig.getExceptionMappings());
newActionConfig.setMethodName(methodName);
String packageName = actionConfig.getPackageName();
newActionConfig.setPackageName(packageName);
PackageConfig packageConfig = configuration.getPackageConfig(packageName);
packageConfig.addActionConfig(newActionName, actionConfig);
}
return (actionMethods.size() > 0);
}
}
@@ -135,6 +135,7 @@ public class ServletActionRedirectResult extends ServletRedirectResult {
protected String actionName;
protected String namespace;
protected String method;
protected ActionMapper actionMapper;
private Map<String, String> requestParameters = new HashMap<String, String>();
@@ -157,6 +158,11 @@ public class ServletActionRedirectResult extends ServletRedirectResult {
this.method = method;
}
@Inject
public void setActionMapper(ActionMapper mapper) {
this.actionMapper = mapper;
}
protected List<String> prohibitedResultParam = Arrays.asList(new String[] {
DEFAULT_PARAM, "namespace", "method", "encode", "parse", "location",
"prependServletContext" });
@@ -85,7 +85,7 @@ public class ServletRedirectResult extends StrutsResultSupport {
protected boolean prependServletContext = true;
protected ActionMapper actionMapper;
private ActionMapper actionMapper;
public ServletRedirectResult() {
super();
@@ -25,10 +25,21 @@ import java.security.Principal;
import javax.servlet.http.HttpServletRequest;
/**
* Proxy interface used together with PrincipalAware interface. It allows to get indirect access to
* HttpServletRequest or PortletRequest Principal related methods.
* Proxy class used together with PrincipalAware interface. It allows to get indirect access to
* HttpServletRequest Principal related methods.
*
*/
public interface PrincipalProxy {
public class PrincipalProxy {
private HttpServletRequest request;
/**
* Constructs a proxy
*
* @param request The underlying request
*/
public PrincipalProxy(HttpServletRequest request) {
this.request = request;
}
/**
* True if the user is in the given role
@@ -36,35 +47,43 @@ public interface PrincipalProxy {
* @param role The role
* @return True if the user is in that role
*/
boolean isUserInRole(String role);
public boolean isUserInRole(String role) {
return request.isUserInRole(role);
}
/**
* Gets the user principal
*
* @return The principal
*/
Principal getUserPrincipal();
public Principal getUserPrincipal() {
return request.getUserPrincipal();
}
/**
* Gets the user id
*
* @return The user id
*/
String getRemoteUser();
public String getRemoteUser() {
return request.getRemoteUser();
}
/**
* Is the request using https?
*
* @return True if using https
*/
boolean isRequestSecure();
public boolean isRequestSecure() {
return request.isSecure();
}
/**
* Gets the request.
* Gets the request
*
* @return The request
* @deprecated To obtain the HttpServletRequest in your action, use
* {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
*/
HttpServletRequest getRequest();
public HttpServletRequest getRequest() {
return request;
}
}
@@ -25,12 +25,8 @@ import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.portlet.PortletRequest;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.servlet.interceptor.ServletPrincipalProxy;
import org.apache.struts2.portlet.PortletActionConstants;
import org.apache.struts2.portlet.interceptor.PortletPrincipalProxy;
import org.apache.struts2.util.ServletContextAware;
import com.opensymphony.xwork2.ActionContext;
@@ -154,14 +150,7 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str
if (action instanceof PrincipalAware) {
HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
Object portletRequest = context.get(PortletActionConstants.REQUEST);
if (portletRequest != null) {
// We are in portlet environment, so principal information resides in PortletRequest
((PrincipalAware) action).setPrincipalProxy(new PortletPrincipalProxy((PortletRequest) portletRequest));
} else {
// We are in servtlet environment, so principal information resides in HttpServletRequest
((PrincipalAware) action).setPrincipalProxy(new ServletPrincipalProxy(request));
}
((PrincipalAware) action).setPrincipalProxy(new PrincipalProxy(request));
}
if (action instanceof ServletContextAware) {
ServletContext servletContext = (ServletContext) context.get(SERVLET_CONTEXT);
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: Result.java 490514 2006-12-27 15:25:48Z ddewolf $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: Result.java 490514 2006-12-27 15:25:48Z ddewolf $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: ServletConfigInterceptor.java 471756 2006-11-06 15:01:43Z husted $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: ServletConfigInterceptor.java 471756 2006-11-06 15:01:43Z husted $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,73 +0,0 @@
package org.apache.struts2.portlet.interceptor;
import org.apache.struts2.interceptor.PrincipalProxy;
import javax.portlet.PortletRequest;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
/**
* PrincipalProxy implementation for using PortletRequest Principal related methods.
*/
public class PortletPrincipalProxy implements PrincipalProxy {
private PortletRequest request;
/**
* Constructs a proxy
*
* @param request The underlying request
*/
public PortletPrincipalProxy(PortletRequest request) {
this.request = request;
}
/**
* True if the user is in the given role
*
* @param role The role
* @return True if the user is in that role
*/
public boolean isUserInRole(String role) {
return request.isUserInRole(role);
}
/**
* Gets the user principal
*
* @return The principal
*/
public Principal getUserPrincipal() {
return request.getUserPrincipal();
}
/**
* Gets the user id
*
* @return The user id
*/
public String getRemoteUser() {
return request.getRemoteUser();
}
/**
* Is the request using https?
*
* @return True if using https
*/
public boolean isRequestSecure() {
return request.isSecure();
}
/**
* Gets the request.
*
* @return The request
* @throws UnsupportedOperationException not supported in this implementation.
* @deprecated To obtain the HttpServletRequest in your action, use
* {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
*/
public HttpServletRequest getRequest() {
throw new UnsupportedOperationException("Usage of getRequest() method is deprecadet and not supported for this implementation");
}
}
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: ServletConfigInterceptor.java 471756 2006-11-06 15:01:43Z husted $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: RequestUtils.java 471717 2006-11-06 12:50:18Z husted $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,70 +0,0 @@
package org.apache.struts2.servlet.interceptor;
import org.apache.struts2.interceptor.PrincipalProxy;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
/**
* PrincipalProxy implementation for using HttpServletRequest Principal related methods.
*/
public class ServletPrincipalProxy implements PrincipalProxy {
private HttpServletRequest request;
/**
* Constructs a proxy
*
* @param request The underlying request
*/
public ServletPrincipalProxy(HttpServletRequest request) {
this.request = request;
}
/**
* True if the user is in the given role
*
* @param role The role
* @return True if the user is in that role
*/
public boolean isUserInRole(String role) {
return request.isUserInRole(role);
}
/**
* Gets the user principal
*
* @return The principal
*/
public Principal getUserPrincipal() {
return request.getUserPrincipal();
}
/**
* Gets the user id
*
* @return The user id
*/
public String getRemoteUser() {
return request.getRemoteUser();
}
/**
* Is the request using https?
*
* @return True if using https
*/
public boolean isRequestSecure() {
return request.isSecure();
}
/**
* Gets the request.
*
* @return The request
* @deprecated To obtain the HttpServletRequest in your action, use
* {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
*/
public HttpServletRequest getRequest() {
return request;
}
}
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: StrutsTestCase.java 476696 2006-11-19 03:56:18Z tmjee $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,23 +1,3 @@
/*
* $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.views;
import java.util.Arrays;
@@ -1,23 +1,3 @@
/*
* $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.views;
import java.util.List;
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: ComboBoxModel.java 471756 2006-11-06 15:01:43Z husted $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -242,7 +242,7 @@ public class StrutsModels {
return date;
}
public DateTimePickerModel getDateTimePicker() {
public DateTimePickerModel getDropdownDateTimePicker() {
if (dateTimePicker == null) {
dateTimePicker = new DateTimePickerModel(stack, req, res);
}
@@ -1,23 +1,3 @@
/*
* $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.views.jsp.ui;
import javax.servlet.http.HttpServletRequest;
@@ -1,23 +1,3 @@
/*
* $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.views.jsp.ui;
import org.apache.struts2.components.Component;
@@ -1,46 +1,46 @@
/*
* $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.views.velocity.components;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Autocompleter;
import org.apache.struts2.components.Bean;
import org.apache.struts2.components.Component;
import com.opensymphony.xwork2.util.ValueStack;
/**
* @see Autocompleter
*/
public class AutocompleterDirective extends AbstractDirective {
protected Component getBean(ValueStack stack, HttpServletRequest req,
HttpServletResponse res) {
return new Autocompleter(stack, req, res);
}
public String getBeanName() {
return "autocompleter";
}
}
/*
* $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.views.velocity.components;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Autocompleter;
import org.apache.struts2.components.Bean;
import org.apache.struts2.components.Component;
import com.opensymphony.xwork2.util.ValueStack;
/**
* @see Autocompleter
*/
public class AutocompleterDirective extends AbstractDirective {
protected Component getBean(ValueStack stack, HttpServletRequest req,
HttpServletResponse res) {
return new Autocompleter(stack, req, res);
}
public String getBeanName() {
return "autocompleter";
}
}
@@ -50,7 +50,7 @@
</#list>
</ol>
<#elseif (msgs?size == 1)>
<#if (msgs[0]?is_method)>
<#if (msg?is_method)>
<li>${msgs[0][0]}</li>
<#else>
<li>${msgs[0]}</li>
@@ -44,9 +44,13 @@ dojo.widget.defineWidget(
this.log("Listening to " + this.listenTopics + " to refresh");
var topics = this.listenTopics.split(",");
if(topics) {
dojo.lang.forEach(topics, function(topic){
dojo.event.topic.subscribe(topic, self, "reloadContents");
});
if(topics) {
if(topics) {
dojo.lang.forEach(topics, function(topic){
dojo.event.topic.subscribe(topic, self, "reloadContents");
});
}
}
}
}
@@ -1,6 +1,6 @@
<#if (parameters.customOnsubmitEnabled?default(false))>
<script type="text/javascript">
<script>
<#--
Enable auto-select of optiontransferselect tag's entries upon containing form's
submission.
@@ -1,4 +1 @@
<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
<#include "/${parameters.templateDir}/simple/datetimepicker.ftl" />
<#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />
<#nt/>
<#include "/${parameters.templateDir}/simple/datetimepicker.ftl" />
@@ -1,4 +1,4 @@
<script type="text/javascript">
<script>
function autoPopulate_${parameters.name?html}(targetElement) {
<#if parameters.headerKey?exists && parameters.headerValue?exists>
if (targetElement.options[targetElement.selectedIndex].value == '${parameters.headerKey?html}') {
@@ -38,9 +38,9 @@
</select>
<script type="text/javascript">
<#assign itemCount = startCount/>
var ${parameters.id}Group = new Array(${parameters.listSize} + ${startCount});
var ${parameters.name}Group = new Array(${parameters.listSize} + ${startCount});
for (i = 0; i < (${parameters.listSize} + ${startCount}); i++)
${parameters.id}Group[i] = new Array();
${parameters.name}Group[i] = new Array();
<@s.iterator value="parameters.list">
<#if parameters.listKey?exists>
@@ -66,14 +66,14 @@
<#else>
<#assign doubleItemValue = stack.findString('top')/>
</#if>
${parameters.id}Group[${itemCount}][${doubleItemCount}] = new Option("${doubleItemValue}", "${doubleItemKeyStr}");
${parameters.name}Group[${itemCount}][${doubleItemCount}] = new Option("${doubleItemValue}", "${doubleItemKeyStr}");
<#assign doubleItemCount = doubleItemCount + 1/>
</@s.iterator>
<#assign itemCount = itemCount + 1/>
</@s.iterator>
var ${parameters.id}Temp = document.${parameters.formName}.${parameters.doubleName};
var ${parameters.name}Temp = document.${parameters.formName}.${parameters.doubleName};
<#assign itemCount = startCount/>
<#assign redirectTo = 0/>
<@s.iterator value="parameters.list">
@@ -87,25 +87,25 @@
</#if>
<#assign itemCount = itemCount + 1/>
</@s.iterator>
${parameters.id}Redirect(${redirectTo});
function ${parameters.id}Redirect(x) {
${parameters.name}Redirect(${redirectTo});
function ${parameters.name}Redirect(x) {
var selected = false;
for (m = ${parameters.id}Temp.options.length - 1; m >= 0; m--) {
${parameters.id}Temp.options[m] = null;
for (m = ${parameters.name}Temp.options.length - 1; m >= 0; m--) {
${parameters.name}Temp.options[m] = null;
}
for (i = 0; i < ${parameters.id}Group[x].length; i++) {
${parameters.id}Temp.options[i] = new Option(${parameters.id}Group[x][i].text, ${parameters.id}Group[x][i].value);
for (i = 0; i < ${parameters.name}Group[x].length; i++) {
${parameters.name}Temp.options[i] = new Option(${parameters.name}Group[x][i].text, ${parameters.name}Group[x][i].value);
<#if parameters.doubleNameValue?exists>
if (${parameters.id}Temp.options[i].value == '${parameters.doubleNameValue}') {
${parameters.id}Temp.options[i].selected = true;
if (${parameters.name}Temp.options[i].value == '${parameters.doubleNameValue}') {
${parameters.name}Temp.options[i].selected = true;
selected = true;
}
</#if>
}
if ((${parameters.id}Temp.options.length > 0) && (! selected)) {
${parameters.id}Temp.options[0].selected = true;
if ((${parameters.name}Temp.options.length > 0) && (! selected)) {
${parameters.name}Temp.options[0].selected = true;
}
}
</script>
@@ -1,7 +1,7 @@
</form>
<#if (parameters.customOnsubmitEnabled?if_exists)>
<script type="text/javascript">
<script>
<#--
Enable auto-select of optiontransferselect tag's entries upon containing form's
submission.
@@ -17,10 +17,9 @@
</#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl"/>
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
><#if parameters.body?length gt 0><@s.property value="parameters.body"/><#elseif parameters.label?exists><@s.property value="parameters.label"/><#rt/></#if></button>
><#if parameters.label?exists><@s.property value="parameters.label"/><#rt/></#if></button>
<#else>
<#if parameters.type?exists && parameters.type=="image">
<@s.property value="parameters.body"/>
<input type="image"<#rt/>
<#if parameters.label?exists>
alt="${parameters.label?html}"<#rt/>
@@ -52,4 +51,4 @@
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
/>
</#if>
</#if>
@@ -12,7 +12,7 @@ Only the following validators are supported:
END SNIPPET: supported-validators
-->
<#if ((parameters.validate?default(false) == true) && (parameters.performValidation?default(false) == true))>
<script type="text/javascript">
<script>
function validateForm_${parameters.id}() {
form = document.getElementById("${parameters.id}");
clearErrorMessages(form);
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: StrutsTestCase.java 476696 2006-11-19 03:56:18Z tmjee $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: SettingsTest.java 498215 2007-01-20 23:59:10Z mrdon $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -59,8 +59,7 @@ public class ClasspathConfigurationProviderTest extends TestCase {
Map configs = pkg.getActionConfigs();
assertNotNull(configs);
// assertEquals(1, configs.size());
ActionConfig actionConfig = (ActionConfig) configs.get("customParentPackage");
assertNotNull(actionConfig);
assertNotNull(configs.get("customParentPackage"));
}
public void testParentPackage() {
@@ -77,12 +76,9 @@ public class ClasspathConfigurationProviderTest extends TestCase {
Map configs = pkg.getAllActionConfigs();
// assertEquals(2, configs.size());
ActionConfig config = (ActionConfig) configs.get("customNamespace");
assertEquals(config.getPackageName(), pkg.getName());
assertEquals(1, pkg.getParents().size());
assertNotNull(config);
assertEquals("/mynamespace", pkg.getNamespace());
ActionConfig ac = (ActionConfig) configs.get("customParentPackage");
assertNotNull(ac);
assertNotNull(configs.get("customParentPackage"));
}
public void testResultAnnotations() {
@@ -99,4 +95,14 @@ public class ClasspathConfigurationProviderTest extends TestCase {
ActionConfig acfg = pkg.getActionConfigs().get("actionImpl");
assertNotNull(acfg);
}
public void testDynamicResults() {
PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
ActionConfig config = pkg.getActionConfigs().get("twoResult");
ResultConfig result = config.getResults().get("foobar");
assertNotNull(result);
assertEquals("/cltest/twoResult.jsp", result.getParams().get("location"));
assertEquals(ServletDispatcherResult.class.getName(), result.getClassName());
}
}
@@ -1,241 +1,241 @@
/*
* $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.config;
import org.apache.struts2.dispatcher.ServletDispatcherResult;
import org.apache.struts2.dispatcher.Dispatcher;
import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.entities.*;
import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
import com.opensymphony.xwork2.ActionSupport;
import junit.framework.TestCase;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
/**
* MethodConfigurationProviderTest exercises the MethodConfigurationProvider
* to confirm that only the expected methods are generated.
*/
public class MethodConfigurationProviderTest extends TestCase {
/**
* Object under test.
*/
MethodConfigurationProvider provider;
/**
* Set of packages and ActionConfigs to exercise.
*/
Configuration configuration;
/**
* Mock dispatcher.
*/
Dispatcher dispatcher;
/**
* Creates a mock Dispatcher and seeds Configuration.
*/
public void setUp() {
InternalConfigurationManager configurationManager = new InternalConfigurationManager();
dispatcher = new Dispatcher(new MockServletContext(), new HashMap<String, String>());
dispatcher.setConfigurationManager(configurationManager);
dispatcher.init();
Dispatcher.setInstance(dispatcher);
configuration = new DefaultConfiguration();
// empty package for the "default" namespace of empty String
PackageConfig strutsDefault = new PackageConfig("struts-default");
strutsDefault.addResultTypeConfig(new ResultTypeConfig("dispatcher", ServletDispatcherResult.class.getName(), "location"));
strutsDefault.setDefaultResultType("dispatcher");
configuration.addPackageConfig("struts-default", strutsDefault);
// custom package with various actions
PackageConfig customPackage = new PackageConfig("trick-package");
customPackage.setNamespace("/trick");
// action that specifies ActionSupport (not empty) but with no methods
ActionConfig action = new ActionConfig(null, ActionSupport.class, null, null, null);
customPackage.addActionConfig("action",action);
// action that species a custom Action with a manual method
ActionConfig custom = new ActionConfig(null, Custom.class, null, null, null);
customPackage.addActionConfig("custom",custom);
// action for manual method, with params, to prove it is not overwritten
Map params = new HashMap();
params.put("name","value");
ActionConfig manual = new ActionConfig("manual", Custom.class, params, null, null);
customPackage.addActionConfig("custom!manual",manual);
configuration.addPackageConfig("trick-package", customPackage);
provider = new MethodConfigurationProvider();
provider.init(configuration);
provider.loadPackages();
}
/**
* Provides the "custom-package" configuration.
* @return the "custom-package" configuration.
*/
private PackageConfig getCustom() {
return configuration.getPackageConfig("trick-package");
}
/**
* Confirms baseline setup works as expected.
*/
public void testSetup() {
assertEquals(2, configuration.getPackageConfigs().size());
PackageConfig struts = configuration.getPackageConfig("struts-default");
assertNotNull(struts);
assertTrue("testSetup: Expected struts-default to be empty!", struts.getActionConfigs().size() == 0);
PackageConfig custom = getCustom();
assertNotNull(custom);
assertTrue("testSetup: Expected ActionConfigs to be added!", custom.getActionConfigs().size() > 0);
}
/**
* Confirms that system detects no-argument methods that return Strings
* and generates the appropriate ActionConfigs.
*/
public void testQualifyingMethods() {
PackageConfig config = getCustom();
boolean action = config.getActionConfigs().containsKey("action");
assertTrue("The root action is missing!",action);
boolean custom = config.getActionConfigs().containsKey("custom");
assertTrue("The custom action is missing!",custom);
boolean action_input = getCustom().getActionConfigs().containsKey("action!input");
assertTrue("The Action.input method should have an action mapping!",action_input);
boolean custom_input = getCustom().getActionConfigs().containsKey("custom!input");
assertTrue("The Custom.input method should have an action mapping!",custom_input);
boolean custom_auto = getCustom().getActionConfigs().containsKey("custom!auto");
assertTrue("The Custom.auto method should have an action mapping!",custom_auto);
boolean custom_gettysburg = getCustom().getActionConfigs().containsKey("custom!gettysburg");
assertTrue("The Custom.gettysburg method should have an action mapping!",custom_gettysburg);
}
/**
* Confirms system excludes methods that do not return Strings
* and no-argument or begin with "getx" or "isX".
*/
public void testExcludedMethods() {
PackageConfig custom = getCustom();
boolean action_toString = custom.getActionConfigs().containsKey("action!toString");
assertFalse("The toString has an ActionConfig!",action_toString);
boolean action_execute = custom.getActionConfigs().containsKey("action!execute");
assertFalse("The execute has an ActionConfig!",action_execute);
boolean action_get_method = custom.getActionConfigs().containsKey("action!getLocale");
assertFalse("A 'getX' method has an ActionConfig!",action_get_method);
boolean action_is_method = custom.getActionConfigs().containsKey("custom!isIt");
assertFalse("A 'isX' method has an ActionConfig!",action_is_method);
boolean void_method = custom.getActionConfigs().containsKey("action!validate");
assertFalse("A void method has an ActionConfig!",void_method);
boolean void_with_parameters = custom.getActionConfigs().containsKey("action!addActionMessage");
assertFalse("A void method with parameters has an ActionConfig!",void_with_parameters);
boolean return_method = custom.getActionConfigs().containsKey("action!hasActionErrors");
assertFalse("A method with a return type other than String has an ActionConfig!",return_method);
ActionConfig manual = getCustom().getActionConfigs().get("custom!manual");
Object val = manual.getParams().get("name");
assertTrue("The custom.Manual method was generated!","value".equals(val.toString()));
}
/**
* Custom is a test Action class.
*/
public class Custom extends ActionSupport {
/**
* Tests ordinary methods.
* @return SUCCESS
*/
public String custom() {
return SUCCESS;
}
/**
* Tests JavaBean property.
* @return SUCCESS
*/
public boolean isIt() {
return true;
}
/**
* Tests manual override.
* @return SUCCESS
*/
public String manual() {
return SUCCESS;
}
/**
* Tests dynamic configuration.
* @return SUCCESS
*/
public String auto() {
return SUCCESS;
}
/**
* Tests method that looks like a JavaBean property.
* @return SUCCESS
*/
public String gettysburg() {
return SUCCESS;
}
}
/**
* InternalConfigurationManager is a mock ConfigurationManager.
*/
class InternalConfigurationManager extends ConfigurationManager {
public boolean destroyConfiguration = false;
@Override
public synchronized void destroyConfiguration() {
super.destroyConfiguration();
destroyConfiguration = true;
}
}
}
/*
* $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.config;
import org.apache.struts2.dispatcher.ServletDispatcherResult;
import org.apache.struts2.dispatcher.Dispatcher;
import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.entities.*;
import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
import com.opensymphony.xwork2.ActionSupport;
import junit.framework.TestCase;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
/**
* MethodConfigurationProviderTest exercises the MethodConfigurationProvider
* to confirm that only the expected methods are generated.
*/
public class MethodConfigurationProviderTest extends TestCase {
/**
* Object under test.
*/
MethodConfigurationProvider provider;
/**
* Set of packages and ActionConfigs to exercise.
*/
Configuration configuration;
/**
* Mock dispatcher.
*/
Dispatcher dispatcher;
/**
* Creates a mock Dispatcher and seeds Configuration.
*/
public void setUp() {
InternalConfigurationManager configurationManager = new InternalConfigurationManager();
dispatcher = new Dispatcher(new MockServletContext(), new HashMap<String, String>());
dispatcher.setConfigurationManager(configurationManager);
dispatcher.init();
Dispatcher.setInstance(dispatcher);
configuration = new DefaultConfiguration();
// empty package for the "default" namespace of empty String
PackageConfig strutsDefault = new PackageConfig("struts-default");
strutsDefault.addResultTypeConfig(new ResultTypeConfig("dispatcher", ServletDispatcherResult.class.getName(), "location"));
strutsDefault.setDefaultResultType("dispatcher");
configuration.addPackageConfig("struts-default", strutsDefault);
// custom package with various actions
PackageConfig customPackage = new PackageConfig("trick-package");
customPackage.setNamespace("/trick");
// action that specifies ActionSupport (not empty) but with no methods
ActionConfig action = new ActionConfig(null, ActionSupport.class, null, null, null);
customPackage.addActionConfig("action",action);
// action that species a custom Action with a manual method
ActionConfig custom = new ActionConfig(null, Custom.class, null, null, null);
customPackage.addActionConfig("custom",custom);
// action for manual method, with params, to prove it is not overwritten
Map params = new HashMap();
params.put("name","value");
ActionConfig manual = new ActionConfig("manual", Custom.class, params, null, null);
customPackage.addActionConfig("custom!manual",manual);
configuration.addPackageConfig("trick-package", customPackage);
provider = new MethodConfigurationProvider();
provider.init(configuration);
provider.loadPackages();
}
/**
* Provides the "custom-package" configuration.
* @return the "custom-package" configuration.
*/
private PackageConfig getCustom() {
return configuration.getPackageConfig("trick-package");
}
/**
* Confirms baseline setup works as expected.
*/
public void testSetup() {
assertEquals(2, configuration.getPackageConfigs().size());
PackageConfig struts = configuration.getPackageConfig("struts-default");
assertNotNull(struts);
assertTrue("testSetup: Expected struts-default to be empty!", struts.getActionConfigs().size() == 0);
PackageConfig custom = getCustom();
assertNotNull(custom);
assertTrue("testSetup: Expected ActionConfigs to be added!", custom.getActionConfigs().size() > 0);
}
/**
* Confirms that system detects no-argument methods that return Strings
* and generates the appropriate ActionConfigs.
*/
public void testQualifyingMethods() {
PackageConfig config = getCustom();
boolean action = config.getActionConfigs().containsKey("action");
assertTrue("The root action is missing!",action);
boolean custom = config.getActionConfigs().containsKey("custom");
assertTrue("The custom action is missing!",custom);
boolean action_input = getCustom().getActionConfigs().containsKey("action!input");
assertTrue("The Action.input method should have an action mapping!",action_input);
boolean custom_input = getCustom().getActionConfigs().containsKey("custom!input");
assertTrue("The Custom.input method should have an action mapping!",custom_input);
boolean custom_auto = getCustom().getActionConfigs().containsKey("custom!auto");
assertTrue("The Custom.auto method should have an action mapping!",custom_auto);
boolean custom_gettysburg = getCustom().getActionConfigs().containsKey("custom!gettysburg");
assertTrue("The Custom.gettysburg method should have an action mapping!",custom_gettysburg);
}
/**
* Confirms system excludes methods that do not return Strings
* and no-argument or begin with "getx" or "isX".
*/
public void testExcludedMethods() {
PackageConfig custom = getCustom();
boolean action_toString = custom.getActionConfigs().containsKey("action!toString");
assertFalse("The toString has an ActionConfig!",action_toString);
boolean action_execute = custom.getActionConfigs().containsKey("action!execute");
assertFalse("The execute has an ActionConfig!",action_execute);
boolean action_get_method = custom.getActionConfigs().containsKey("action!getLocale");
assertFalse("A 'getX' method has an ActionConfig!",action_get_method);
boolean action_is_method = custom.getActionConfigs().containsKey("custom!isIt");
assertFalse("A 'isX' method has an ActionConfig!",action_is_method);
boolean void_method = custom.getActionConfigs().containsKey("action!validate");
assertFalse("A void method has an ActionConfig!",void_method);
boolean void_with_parameters = custom.getActionConfigs().containsKey("action!addActionMessage");
assertFalse("A void method with parameters has an ActionConfig!",void_with_parameters);
boolean return_method = custom.getActionConfigs().containsKey("action!hasActionErrors");
assertFalse("A method with a return type other than String has an ActionConfig!",return_method);
ActionConfig manual = getCustom().getActionConfigs().get("custom!manual");
Object val = manual.getParams().get("name");
assertTrue("The custom.Manual method was generated!","value".equals(val.toString()));
}
/**
* Custom is a test Action class.
*/
public class Custom extends ActionSupport {
/**
* Tests ordinary methods.
* @return SUCCESS
*/
public String custom() {
return SUCCESS;
}
/**
* Tests JavaBean property.
* @return SUCCESS
*/
public boolean isIt() {
return true;
}
/**
* Tests manual override.
* @return SUCCESS
*/
public String manual() {
return SUCCESS;
}
/**
* Tests dynamic configuration.
* @return SUCCESS
*/
public String auto() {
return SUCCESS;
}
/**
* Tests method that looks like a JavaBean property.
* @return SUCCESS
*/
public String gettysburg() {
return SUCCESS;
}
}
/**
* InternalConfigurationManager is a mock ConfigurationManager.
*/
class InternalConfigurationManager extends ConfigurationManager {
public boolean destroyConfiguration = false;
@Override
public synchronized void destroyConfiguration() {
super.destroyConfiguration();
destroyConfiguration = true;
}
}
}
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id: AnnotationValidationInterceptorTest.java 478625 2006-11-23 17:31:52Z wsmoak $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,76 +1,56 @@
/*
* $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.views.jsp.ui;
import org.apache.struts2.views.jsp.AbstractUITagTest;
/**
* @see org.apache.struts2.components.Autocompleter
*/
public class AutocompleterTest extends AbstractUITagTest {
public void testAjax() throws Exception {
AutocompleterTag tag = new AutocompleterTag();
tag.setPageContext(pageContext);
tag.setTheme("ajax");
tag.setAutoComplete("true");
tag.setDisabled("false");
tag.setForceValidOption("false");
tag.setHref("a");
tag.setDropdownWidth("10");
tag.setDropdownHeight("10");
tag.setDelay("100");
tag.setSearchType("b");
tag.setDisabled("c");
tag.setName("f");
tag.setValue("g");
tag.setIndicator("h");
tag.setLoadOnTextChange("true");
tag.setLoadMinimumCount("3");
tag.setShowDownArrow("false");
tag.doStartTag();
tag.doEndTag();
verify(AutocompleterTest.class.getResource("Autocompleter-1.txt"));
}
public void testSimple() throws Exception {
AutocompleterTag tag = new AutocompleterTag();
tag.setPageContext(pageContext);
tag.setTheme("simple");
tag.setAutoComplete("true");
tag.setDisabled("false");
tag.setForceValidOption("false");
tag.setList("{'d','e'}");
tag.setHref("a");
tag.setDropdownWidth("10");
tag.setDropdownHeight("10");
tag.setDelay("100");
tag.setSearchType("b");
tag.setDisabled("c");
tag.setName("f");
tag.doStartTag();
tag.doEndTag();
verify(AutocompleterTest.class.getResource("Autocompleter-2.txt"));
}
}
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.views.jsp.AbstractUITagTest;
/**
* @see org.apache.struts2.components.Autocompleter
*/
public class AutocompleterTest extends AbstractUITagTest {
public void testAjax() throws Exception {
AutocompleterTag tag = new AutocompleterTag();
tag.setPageContext(pageContext);
tag.setTheme("ajax");
tag.setAutoComplete("true");
tag.setDisabled("false");
tag.setForceValidOption("false");
tag.setHref("a");
tag.setDropdownWidth("10");
tag.setDropdownHeight("10");
tag.setDelay("100");
tag.setSearchType("b");
tag.setDisabled("c");
tag.setName("f");
tag.setValue("g");
tag.setIndicator("h");
tag.setLoadOnTextChange("true");
tag.setLoadMinimumCount("3");
tag.setShowDownArrow("false");
tag.doStartTag();
tag.doEndTag();
verify(AutocompleterTest.class.getResource("Autocompleter-1.txt"));
}
public void testSimple() throws Exception {
AutocompleterTag tag = new AutocompleterTag();
tag.setPageContext(pageContext);
tag.setTheme("simple");
tag.setAutoComplete("true");
tag.setDisabled("false");
tag.setForceValidOption("false");
tag.setList("{'d','e'}");
tag.setHref("a");
tag.setDropdownWidth("10");
tag.setDropdownHeight("10");
tag.setDelay("100");
tag.setSearchType("b");
tag.setDisabled("c");
tag.setName("f");
tag.doStartTag();
tag.doEndTag();
verify(AutocompleterTest.class.getResource("Autocompleter-2.txt"));
}
}
@@ -153,63 +153,7 @@ public class DoubleSelectTest extends AbstractUITagTest {
}
public void testDoubleWithDotName() throws Exception {
TestAction testAction = (TestAction) action;
Region antwerp = new Region("Antwerp", "AN");
Region gent = new Region("Gent", "GN");
Region brugge = new Region("Brugge", "BRG");
ArrayList belgiumRegions = new ArrayList();
belgiumRegions.add(antwerp);
belgiumRegions.add(gent);
belgiumRegions.add(brugge);
Country belgium = new Country("Belgium", "BE", belgiumRegions);
Region paris = new Region("Paris", "PA");
Region bordeaux = new Region("Bordeaux", "BOR");
ArrayList franceRegions = new ArrayList();
franceRegions.add(paris);
franceRegions.add(bordeaux);
Country france = new Country("France", "FR", franceRegions);
Collection collection = new ArrayList(2);
collection.add("AN");
testAction.setCollection(collection);
List countries = new ArrayList();
countries.add(belgium);
countries.add(france);
testAction.setList2(countries);
DoubleSelectTag tag = new DoubleSelectTag();
tag.setPageContext(pageContext);
tag.setLabel("mylabel");
tag.setName("foo.bar");
tag.setDoubleName("region");
tag.setList("list2");
tag.setDoubleList("regions");
tag.setListKey("iso");
tag.setDoubleListKey("key");
tag.setListValue("name");
tag.setDoubleListValue("name");
tag.setFormName("inputForm");
tag.setOnmousedown("window.status='onmousedown';");
tag.setOnmousemove("window.status='onmousemove';");
tag.setOnmouseout("window.status='onmouseout';");
tag.setOnmouseover("window.status='onmouseover';");
tag.setOnmouseup("window.status='onmouseup';");
tag.doStartTag();
tag.doEndTag();
verify(SelectTag.class.getResource("DoubleSelect-3.txt"));
}
public void testGenericSimple() throws Exception {
DoubleSelectTag tag = new DoubleSelectTag();
@@ -23,13 +23,9 @@ package org.apache.struts2.views.jsp.ui;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.jsp.tagext.BodyContent;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.jsp.AbstractUITagTest;
import com.mockobjects.servlet.MockBodyContent;
/**
* Unit test for {@link SubmitTag}.
@@ -85,25 +81,6 @@ public class SubmitTest extends AbstractUITagTest {
verify(TextFieldTag.class.getResource("Submit-3.txt"));
}
public void testButtonSimpleWithBody() throws Exception {
TestAction testAction = (TestAction) action;
testAction.setFoo("bar");
SubmitTag tag = new SubmitTag();
tag.setPageContext(pageContext);
tag.setType("button");
tag.setName("myname");
tag.setValue("%{foo}");
tag.doStartTag();
StrutsBodyContent body = new StrutsBodyContent(null);
body.append("foo");
tag.setBodyContent(body);
tag.doEndTag();
verify(TextFieldTag.class.getResource("Submit-7.txt"));
}
public void testButtonWithLabel() throws Exception {
TestAction testAction = (TestAction) action;
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"><label for="foo" class="label">mylabel:</label></td>
<td>
<script type="text/javascript">
<script>
function autoPopulate_foo(targetElement) {
targetElement.form.elements['foo'].value=targetElement.options[targetElement.selectedIndex].value;
}
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"><label for="myFavouriteFruit" class="label">My Favourite Fruit:</label></td>
<td>
<script type="text/javascript">
<script>
function autoPopulate_myFavouriteFruit(targetElement) {
if (targetElement.options[targetElement.selectedIndex].value == '-1') {
return;
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"><label for="myFavouriteFruit" class="label">My Favourite Fruit:</label></td>
<td>
<script type="text/javascript">
<script>
function autoPopulate_myFavouriteFruit(targetElement) {
if (targetElement.options[targetElement.selectedIndex].value == '-1') {
return;
@@ -1,41 +0,0 @@
<tr>
<td class="tdLabel"><label for="foo_bar" class="label">mylabel:</label></td>
<td>
<select name="foo.bar" id="foo_bar" onmousedown="window.status='onmousedown';" onmouseup="window.status='onmouseup';" onmouseover="window.status='onmouseover';" onmousemove="window.status='onmousemove';" onmouseout="window.status='onmouseout';" onchange="foo_barRedirect(this.options.selectedIndex)">
<option value="BE">Belgium</option>
<option value="FR">France</option>
</select>
<br/>
<select name="region">
</select>
<script type="text/javascript">
var foo_barGroup = new Array(2 + 0);
for (i = 0; i < (2 + 0); i++)
foo_barGroup[i] = new Array();
foo_barGroup[0][0] = new Option("Antwerp", "AN");
foo_barGroup[0][1] = new Option("Gent", "GN");
foo_barGroup[0][2] = new Option("Brugge", "BRG");
foo_barGroup[1][0] = new Option("Paris", "PA");
foo_barGroup[1][1] = new Option("Bordeaux", "BOR");
var foo_barTemp = document.inputForm.region;
foo_barRedirect(0);
function foo_barRedirect(x) {
var selected = false;
for (m = foo_barTemp.options.length - 1; m >= 0; m--) {
foo_barTemp.options[m] = null;
}
for (i = 0; i < foo_barGroup[x].length; i++) {
foo_barTemp.options[i] = new Option(foo_barGroup[x][i].text, foo_barGroup[x][i].value);
}
if ((foo_barTemp.options.length > 0) && (! selected)) {
foo_barTemp.options[0].selected = true;
}
}
</script>
</td>
</tr>
@@ -19,7 +19,7 @@
</form>
<script type="text/javascript">
<script>
dojo.require("dojo.event.*");
var containingForm = document.getElementById("myAction");
dojo.event.connect(containingForm, "onsubmit",
@@ -19,7 +19,7 @@
</form>
<script type="text/javascript">
<script>
dojo.require("dojo.event.*");
var containingForm = document.getElementById("myAction");
dojo.event.connect(containingForm, "onsubmit",
@@ -29,7 +29,7 @@
});
</script>
<script type="text/javascript">
<script>
function validateForm_myAction() {
form = document.getElementById("myAction");
clearErrorMessages(form);
@@ -18,7 +18,7 @@
</form>
<script type="text/javascript">
<script>
dojo.require("dojo.event.*");
var containingForm = document.getElementById("myAction");
dojo.event.connect(containingForm, "onsubmit",
@@ -1,3 +0,0 @@
<tr>
<td colspan="2"><div align="right"><button type="submit" id="myname" name="myname" value="bar">foo</button></div></td>
</tr>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-codebehind-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-continuations-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jasperreports-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jfreechart-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jsf-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-pell-multipart-plugin</artifactId>
@@ -5,5 +5,5 @@
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="pell" class="org.apache.struts2.dispatcher.multipart.PellMultiPartRequest" />
<bean type="org.apache.struts2.dispatcher.MultiPartRequest" name="pell" class="org.apache.struts2.dispatcher.PellMultiPartRequest" />
</struts>
+2 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plexus-plugin</artifactId>
@@ -23,6 +23,7 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>1.0-alpha-10-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitegraph-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-struts1-plugin</artifactId>
+3 -3
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
@@ -20,9 +20,9 @@
<dependencies>
<dependency>
<groupId>org.apache.tiles</groupId>
<groupId>org.apache.struts.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.0-SNAPSHOT</version>
<version>2.0-r488734-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
+1 -1
View File
@@ -32,7 +32,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.5</version>
<version>2.0.4</version>
<packaging>pom</packaging>
<name>Struts 2</name>
<url>http://struts.apache.org/struts2</url>
+1 -1
View File
@@ -49,7 +49,7 @@
<item
name="Release Notes"
href="docs/release-notes-205.html"
href="docs/release-notes-204.html"
/>
</menu>