mirror of
https://github.com/apache/struts.git
synced 2026-08-10 09:06:55 +00:00
Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe62eb0347 | |||
| 611f7cf2c4 | |||
| f13243a2bf | |||
| b2496a566c | |||
| 756c2f58d5 | |||
| cac778c170 | |||
| 66479bc36e | |||
| fbd8a0a328 | |||
| 554a1b5ffc | |||
| e023f033af | |||
| 0c3c873c0f | |||
| 8199b1a3b7 | |||
| d40fcd2641 | |||
| d078084107 | |||
| 697a3b3a1e | |||
| c990786a59 | |||
| 6a5e493a45 | |||
| 3f7dd2ef82 | |||
| 0a388b18e4 | |||
| 7d8dfff8a1 | |||
| 9a80c9b381 | |||
| 129e4559ce | |||
| 18f41aab19 | |||
| ff9bfe3bd4 | |||
| 87c3af3654 | |||
| e163098224 | |||
| 8f9f1fbd42 | |||
| dd200c173c | |||
| d8ea187a2a | |||
| d7189a6648 | |||
| 0534ae35d8 | |||
| 2cab82fafc | |||
| bfa0d22c8c | |||
| 1472a49a0f | |||
| 5e3464d467 | |||
| 63be3b2a41 | |||
| d60e674046 | |||
| da3e4b0280 | |||
| fba1a707d7 | |||
| 6e81a692b7 | |||
| fbedbdedbe | |||
| 84863ffaae | |||
| 8b32755ba1 | |||
| 1a2bd58e65 | |||
| 9872cc64db | |||
| 421ff8d068 | |||
| 40ed474347 | |||
| 0e7dbe0b62 | |||
| ae4e489d9e | |||
| dcc79d485d | |||
| 75b379d5d4 | |||
| 5ae4898a5d | |||
| 522961d993 | |||
| 02249e0558 | |||
| a5f3306e9b | |||
| 1432b02048 | |||
| 017537f20a | |||
| 80d3f05fe7 |
-54
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Struts 2 API</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/api/</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/api/</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/api/</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
<!-- has to be compile for StrutsTestCase, which is part of the base package so others can write unit tests -->
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<configuration>
|
||||
<showPackage>false</showPackage>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Default action interface. Provided purely for user convenience. Struts does not require actions to implement any
|
||||
* interfaces. Actions need only implement a public, no argument method which returns {@code String}. If a user does
|
||||
* not specify a method name, Struts defaults to {@code execute()}.
|
||||
*
|
||||
* <p>For example:
|
||||
*
|
||||
* <pre>
|
||||
* static import ResultNames.*;
|
||||
*
|
||||
* public class MyAction <b>implements Action</b> {
|
||||
*
|
||||
* public String execute() {
|
||||
* return SUCCESS;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>is equivalent to:
|
||||
*
|
||||
* <pre>
|
||||
* static import ResultNames.*;
|
||||
*
|
||||
* public class MyAction {
|
||||
*
|
||||
* public String execute() {
|
||||
* return SUCCESS;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface Action {
|
||||
|
||||
/**
|
||||
* Executes this action.
|
||||
*
|
||||
* @return result name which matches a result name from the action mapping in the configuration file. See {@link
|
||||
* ResultNames} for common suggestions.
|
||||
*/
|
||||
String execute();
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Implemented by actions which may need to record errors or messages.
|
||||
*
|
||||
* <pre>
|
||||
* static import ResultNames.*;
|
||||
*
|
||||
* public class SetName implements MessageAware {
|
||||
*
|
||||
* Messages messages;
|
||||
* String name;
|
||||
*
|
||||
* public String execute() {
|
||||
* return SUCCESS;
|
||||
* }
|
||||
*
|
||||
* public void setName(String name) {
|
||||
* if ("".equals(name))
|
||||
* messages.forField("name").addError("name.required");
|
||||
*
|
||||
* this.name = name;
|
||||
* }
|
||||
*
|
||||
* public void setMessages(Messages messages) {
|
||||
* this.messages = messages;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface MessageAware {
|
||||
|
||||
/**
|
||||
* Sets messages.
|
||||
*
|
||||
* @param messages messages
|
||||
*/
|
||||
void setMessages(Messages messages);
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Collection of messages. Supports nesting messages by field name.
|
||||
*
|
||||
* <p>Uses keys when adding instead of actual messages to decouple code from messages.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface Messages {
|
||||
|
||||
// TODO: Use Object[] for args instead of String[].
|
||||
|
||||
/**
|
||||
* Message severity.
|
||||
*/
|
||||
public enum Severity {
|
||||
|
||||
/**
|
||||
* Informational messages.
|
||||
*/
|
||||
INFO,
|
||||
|
||||
/**
|
||||
* Warning messages.
|
||||
*/
|
||||
WARN,
|
||||
|
||||
/**
|
||||
* Error messages.
|
||||
*/
|
||||
ERROR,
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets nested messages for the given field.
|
||||
*
|
||||
* <p>Supports dot notation to represent nesting. For example:
|
||||
*
|
||||
* <pre>
|
||||
* messages.forField("foo").forField("bar") == messages.forField("foo.bar")
|
||||
* </pre>
|
||||
*
|
||||
* @param fieldName name of the field
|
||||
* @return nested {@code Messages} for given field name
|
||||
*/
|
||||
Messages forField(String fieldName);
|
||||
|
||||
/**
|
||||
* Gets map of field name to messages for that field.
|
||||
*
|
||||
* @return map of field name to {@code Messages}
|
||||
*/
|
||||
Map<String, Messages> forFields();
|
||||
|
||||
/**
|
||||
* Adds informational message.
|
||||
*
|
||||
* @param key message key
|
||||
* @see Severity.INFO
|
||||
*/
|
||||
void addInformation(String key);
|
||||
|
||||
/**
|
||||
* Adds informational message.
|
||||
*
|
||||
* @param key message key
|
||||
* @param arguments message arguments
|
||||
* @see Severity.INFO
|
||||
*/
|
||||
void addInformation(String key, String... arguments);
|
||||
|
||||
/**
|
||||
* Adds warning message.
|
||||
*
|
||||
* @param key message key
|
||||
* @see Severity.WARN
|
||||
*/
|
||||
void addWarning(String key);
|
||||
|
||||
/**
|
||||
* Adds warning message.
|
||||
*
|
||||
* @param key message key
|
||||
* @param arguments message arguments
|
||||
* @see Severity.WARN
|
||||
*/
|
||||
void addWarning(String key, String... arguments);
|
||||
|
||||
/**
|
||||
* Adds error message.
|
||||
*
|
||||
* @param key message key
|
||||
* @see Severity.ERROR
|
||||
*/
|
||||
void addError(String key);
|
||||
|
||||
/**
|
||||
* Adds error message.
|
||||
*
|
||||
* @param key message key
|
||||
* @param arguments message arguments
|
||||
* @see Severity.ERROR
|
||||
*/
|
||||
void addError(String key, String... arguments);
|
||||
|
||||
/**
|
||||
* Adds message.
|
||||
*
|
||||
* @param severity message severity
|
||||
* @param key message key
|
||||
*/
|
||||
void add(Severity severity, String key);
|
||||
|
||||
/**
|
||||
* Adds request-scoped message.
|
||||
*
|
||||
* @param severity message severity
|
||||
* @param key message key
|
||||
* @param arguments message arguments
|
||||
*/
|
||||
void add(Severity severity, String key, String... arguments);
|
||||
|
||||
/**
|
||||
* Gets set of severities for which this {@code Messages} instance has messages. Not recursive.
|
||||
*
|
||||
* @return unmodifiable set of {@link Severity} sorted from least to most severe
|
||||
*/
|
||||
Set<Severity> getSeverities();
|
||||
|
||||
/**
|
||||
* Gets message strings for the given severity. Not recursive.
|
||||
*
|
||||
* @param severity message severity
|
||||
* @return unmodifiable list of messages
|
||||
*/
|
||||
List<String> forSeverity(Severity severity);
|
||||
|
||||
/**
|
||||
* Gets error message strings for this {@code Messages} instance. Not recursive.
|
||||
*
|
||||
* @return unmodifiable list of messages
|
||||
*/
|
||||
List<String> getErrors();
|
||||
|
||||
/**
|
||||
* Gets error message strings for this {@code Messages} instance. Not recursive.
|
||||
*
|
||||
* @return unmodifiable list of messages
|
||||
*/
|
||||
List<String> getWarnings();
|
||||
|
||||
/**
|
||||
* Gets informational message strings for this {@code Messages} instance. Not recursive.
|
||||
*
|
||||
* @return unmodifiable list of messages
|
||||
*/
|
||||
List<String> getInformation();
|
||||
|
||||
/**
|
||||
* Returns true if this or a nested {@code Messages} instance has error messages.
|
||||
*
|
||||
* @see Severity.ERROR
|
||||
*/
|
||||
boolean hasErrors();
|
||||
|
||||
/**
|
||||
* Returns true if this or a nested {@code Messages} instance has warning messages.
|
||||
*
|
||||
* @see Severity.WARN
|
||||
*/
|
||||
boolean hasWarnings();
|
||||
|
||||
/**
|
||||
* Returns true if this or a nested {@code Messages} instance has informational messages.
|
||||
*
|
||||
* @see Severity.INFO
|
||||
*/
|
||||
boolean hasInformation();
|
||||
|
||||
/**
|
||||
* Returns true if this and all nested {@code Messages} instances have no messages.
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Returns true if this and all nested {@code Messages} instances have no messages for the given severity.
|
||||
*
|
||||
* @param severity message severity
|
||||
*/
|
||||
boolean isEmpty(Severity severity);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Commonly used result names returned by action methods.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public final class ResultNames {
|
||||
|
||||
private ResultNames() {}
|
||||
|
||||
/**
|
||||
* The action executed successfully.
|
||||
*/
|
||||
public static final String SUCCESS = "success";
|
||||
|
||||
/**
|
||||
* The action requires more input, i.e. a validation error occurred.
|
||||
*/
|
||||
public static final String INPUT = "input";
|
||||
|
||||
/**
|
||||
* The action requires the user to log in before executing.
|
||||
*/
|
||||
public static final String LOGIN = "login";
|
||||
|
||||
/**
|
||||
* The action execution failed irrecoverably.
|
||||
*/
|
||||
public static final String ERROR = "error";
|
||||
|
||||
/**
|
||||
* The action executed successfully, but do not execute a result.
|
||||
*/
|
||||
public static final String NONE = "none";
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Implemented by actions which wish to execute some validation logic before their action method. Useful for
|
||||
* cross-field validations.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface Validatable extends MessageAware {
|
||||
|
||||
/**
|
||||
* Validates input. Executes before action method.
|
||||
*/
|
||||
public void validate();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Implemented by actions which need direct access to the request parameters.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface ParameterAware {
|
||||
|
||||
/**
|
||||
* Sets parameters.
|
||||
*
|
||||
* @param parameters map of parameter name to parameter values
|
||||
*/
|
||||
void setParameters(Map<String, String[]> parameters);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Implemented by actions which need direct access to the servlet request.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface ServletRequestAware {
|
||||
|
||||
/**
|
||||
* Sets the servlet request.
|
||||
*
|
||||
* @param request servlet request.
|
||||
*/
|
||||
void setServletRequest(HttpServletRequest request);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Implemented by actions which need direct access to the servlet response.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface ServletResponseAware {
|
||||
|
||||
/**
|
||||
* Sets the servlet response.
|
||||
*
|
||||
* @param response servlet response
|
||||
*/
|
||||
void setServletResponse(HttpServletResponse response);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Context of an action execution.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface ActionContext {
|
||||
|
||||
/**
|
||||
* Gets action instance.
|
||||
*/
|
||||
Object getAction();
|
||||
|
||||
/**
|
||||
* Gets action method.
|
||||
*/
|
||||
Method getMethod();
|
||||
|
||||
/**
|
||||
* Gets action name.
|
||||
*/
|
||||
String getActionName();
|
||||
|
||||
/**
|
||||
* Gets the path for the action's namespace.
|
||||
*/
|
||||
String getNamespacePath();
|
||||
|
||||
/**
|
||||
* Gets the {@link Result} instance for the action.
|
||||
*
|
||||
* @return {@link Result} instance or {@code null} if we don't have a result yet.
|
||||
*/
|
||||
Result getResult();
|
||||
|
||||
/**
|
||||
* Adds a result interceptor for the action. Enables executing code before and after a result, executing an
|
||||
* alternate result, etc.
|
||||
*/
|
||||
void addResultInterceptor(Result interceptor);
|
||||
|
||||
/**
|
||||
* Gets context of action which chained to us.
|
||||
*
|
||||
* @return context of previous action or {@code null} if this is the first action in the chain
|
||||
*/
|
||||
ActionContext getPrevious();
|
||||
|
||||
/**
|
||||
* Gets context of action which this action chained to.
|
||||
*
|
||||
* @return context of next action or {@code null} if we haven't chained to another action yet or this is the last
|
||||
* action in the chain.
|
||||
*/
|
||||
ActionContext getNext();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Intercepts an action request.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface Interceptor {
|
||||
|
||||
/**
|
||||
* Intercepts an action request.
|
||||
*
|
||||
* @param requestContext current request context
|
||||
*/
|
||||
String intercept(RequestContext requestContext) throws Exception;
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Request context. A single request may span multiple actions with action chaining.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface RequestContext {
|
||||
|
||||
/**
|
||||
* Gets context of the currently executing action.
|
||||
*
|
||||
* @return current action context
|
||||
*/
|
||||
ActionContext getActionContext();
|
||||
|
||||
/**
|
||||
* Convenience method. Equivalent to {@code getActionContext().getAction()}.
|
||||
*
|
||||
* @return currently executing action
|
||||
*/
|
||||
Object getAction();
|
||||
|
||||
/**
|
||||
* Gets map of request parameters.
|
||||
*/
|
||||
Map<String, String[]> getParameterMap();
|
||||
|
||||
/**
|
||||
* Gets map of request attributes.
|
||||
*/
|
||||
Map<String, Object> getAttributeMap();
|
||||
|
||||
/**
|
||||
* Gets map of session attributes.
|
||||
*/
|
||||
Map<String, Object> getSessionMap();
|
||||
|
||||
/**
|
||||
* Gets map of application (servlet context) attributes.
|
||||
*/
|
||||
Map<String, Object> getApplicationMap();
|
||||
|
||||
/**
|
||||
* Finds cookies with the given name,
|
||||
*/
|
||||
List<Cookie> findCookiesForName(String name);
|
||||
|
||||
/**
|
||||
* Gets locale.
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Sets locale. Stores the locale in the session for future requests.
|
||||
*/
|
||||
void setLocale(Locale locale);
|
||||
|
||||
/**
|
||||
* Gets messages.
|
||||
*/
|
||||
Messages getMessages();
|
||||
|
||||
/**
|
||||
* Gets the servlet request.
|
||||
*/
|
||||
HttpServletRequest getServletRequest();
|
||||
|
||||
/**
|
||||
* Gets the servlet response.
|
||||
*/
|
||||
HttpServletResponse getServletResponse();
|
||||
|
||||
/**
|
||||
* Gets the servlet context.
|
||||
*/
|
||||
ServletContext getServletContext();
|
||||
|
||||
/**
|
||||
* Gets the value stack.
|
||||
*/
|
||||
ValueStack getValueStack();
|
||||
|
||||
/**
|
||||
* Invokes the next interceptor or the action method if no more interceptors remain.
|
||||
*
|
||||
* @return result name
|
||||
* @throws IllegalStateException if already invoked or called from the action
|
||||
*/
|
||||
String proceed() throws Exception;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* Implemented by actions that need access to the current {@link org.apache.struts2.spi.RequestContext}. Use
|
||||
* judiciously.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface RequestContextAware {
|
||||
|
||||
/**
|
||||
* Sets {@link org.apache.struts2.spi.RequestContext}.
|
||||
*
|
||||
* @param requestContext
|
||||
*/
|
||||
void setRequestContext(RequestContext requestContext);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* The result of an action request. Struts creates a new {@code Result} instance for each request.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface Result {
|
||||
|
||||
/**
|
||||
* Executes result.
|
||||
*
|
||||
* @param requestContext
|
||||
*/
|
||||
void execute(RequestContext requestContext) throws Exception;
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
/**
|
||||
* A central fixture of the Struts framework, the {@code ValueStack} is a stack which contains the actions
|
||||
* which have executed in addition to other objects. Users can get and set values on the stack using expressions. The
|
||||
* {@code ValueStack} will search down the stack starting with the most recent objects until it finds an object to
|
||||
* which the expression can apply.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public interface ValueStack extends Iterable<Object> {
|
||||
|
||||
/**
|
||||
* Gets the top, most recent object from the stack without changing the stack.
|
||||
*
|
||||
* @return the top object
|
||||
*/
|
||||
Object peek();
|
||||
|
||||
/**
|
||||
* Removes the top, most recent object from the stack.
|
||||
*
|
||||
* @return the top object
|
||||
*/
|
||||
Object pop();
|
||||
|
||||
/**
|
||||
* Pushes an object onto the stack.
|
||||
*
|
||||
* @param o
|
||||
*/
|
||||
void push(Object o);
|
||||
|
||||
/**
|
||||
* Creates a shallow copy of this stack.
|
||||
*
|
||||
* @return a new stack which contains the same objects as this one
|
||||
*/
|
||||
ValueStack clone();
|
||||
|
||||
/**
|
||||
* Queries the stack. Starts with the top, most recent object. If the expression can apply to the object, this
|
||||
* method returns the result of evaluating the expression. If the expression does not apply, this method moves
|
||||
* down the stack to the next object and repeats. Returns {@code null} if the expression doesn't apply to any
|
||||
* objects.
|
||||
*
|
||||
* @param expression
|
||||
* @return the evaluation of the expression against the first applicable object in the stack
|
||||
*/
|
||||
Object get(String expression);
|
||||
|
||||
/**
|
||||
* Queries the stack and converts the result to the specified type. Starts with the top, most recent object. If
|
||||
* the expression can apply to the object, this method returns the result of evaluating the expression converted
|
||||
* to the specified type. If the expression does not apply, this method moves down the stack to the next object
|
||||
* and repeats. Returns {@code null} if the expression doesn't apply to any objects.
|
||||
*
|
||||
* @param expression
|
||||
* @param asType the type to convert the result to
|
||||
* @return the evaluation of the expression against the first applicable object in the stack converted to the
|
||||
* specified type
|
||||
*/
|
||||
<T> T get(String expression, Class<T> asType);
|
||||
|
||||
/**
|
||||
* Queries the stack and converts the result to a {@code String}. Starts with the top, most recent object. If the
|
||||
* expression can apply to the object, this method returns the result of evaluating the expression converted to a
|
||||
* {@code String}. If the expression does not apply, this method moves down the stack to the next object and
|
||||
* repeats. Returns {@code null} if the expression doesn't apply to any objects.
|
||||
*
|
||||
* @param expression
|
||||
* @return the evaluation of the expression against the first applicable object in the stack converted to a {@code
|
||||
* String}
|
||||
*/
|
||||
String getString(String expression);
|
||||
|
||||
/**
|
||||
* Sets a value on an object from the stack. This method starts at the top, most recent object. If the expression
|
||||
* applies to that object, this methods sets the given value on that object using the expression and converting
|
||||
* the type as necessary. If the expression does not apply, this method moves to the next object and repeats.
|
||||
*
|
||||
* @param expression
|
||||
* @param value
|
||||
*/
|
||||
void set(String expression, Object value);
|
||||
|
||||
/**
|
||||
* Returns the number of object on the stack.
|
||||
*
|
||||
* @return size of stack
|
||||
*/
|
||||
int size();
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
@@ -1,5 +0,0 @@
|
||||
Apache Struts
|
||||
Copyright 2000-2007 The Apache Software Foundation
|
||||
|
||||
This product includes software developed by
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-blank</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-mailreader</artifactId>
|
||||
@@ -19,7 +19,7 @@
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
@@ -38,7 +38,7 @@
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
|
||||
+10
-10
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
/*
|
||||
* Copyright 2005-2006 The Apache Software Foundation.
|
||||
*
|
||||
*
|
||||
* Licensed 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.
|
||||
@@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
@@ -37,7 +37,7 @@
|
||||
<module>portlet</module>
|
||||
<module>showcase</module>
|
||||
</modules>
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/</developerConnection>
|
||||
@@ -50,7 +50,7 @@
|
||||
<url>scp://people.apache.org/www/struts.apache.org/struts2/apps</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>hostedqa</id>
|
||||
@@ -173,9 +173,9 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
<finalName>${pom.artifactId}</finalName>
|
||||
|
||||
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
@@ -193,5 +193,5 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-portlet</artifactId>
|
||||
@@ -29,7 +29,7 @@
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-spring-plugin</artifactId>
|
||||
<version>${pom.version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
|
||||
+8
-14
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-showcase</artifactId>
|
||||
@@ -17,7 +17,7 @@
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/showcase/</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/showcase/</url>
|
||||
</scm>
|
||||
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
@@ -31,7 +31,7 @@
|
||||
</profile>
|
||||
</profiles>
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-struts1-plugin</artifactId>
|
||||
@@ -55,16 +55,10 @@
|
||||
<artifactId>struts2-sitemesh-plugin</artifactId>
|
||||
<version>${pom.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-tiles-plugin</artifactId>
|
||||
<version>${pom.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-continuations-plugin</artifactId>
|
||||
<artifactId>struts2-tiles-plugin</artifactId>
|
||||
<version>${pom.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -79,14 +73,14 @@
|
||||
<artifactId>struts2-spring-plugin</artifactId>
|
||||
<version>${pom.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Velocity -->
|
||||
<dependency>
|
||||
<groupId>velocity</groupId>
|
||||
@@ -137,9 +131,9 @@
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* $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;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import com.uwyn.rife.continuations.ContinuableObject;
|
||||
|
||||
// START SNIPPET: example
|
||||
public class Guess extends ActionSupport implements Preparable, ContinuableObject {
|
||||
int guess;
|
||||
|
||||
public void prepare() throws Exception {
|
||||
// We clear the error message state before the action.
|
||||
// That is because with continuations, the original (or cloned) action is being
|
||||
// executed, which will still have the old errors and potentially cause problems,
|
||||
// such as with the workflow interceptor
|
||||
clearErrorsAndMessages();
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
int answer = new Random().nextInt(100) + 1;
|
||||
int tries = 5;
|
||||
|
||||
while (answer != guess && tries > 0) {
|
||||
pause(Action.SUCCESS);
|
||||
|
||||
if (guess > answer) {
|
||||
addFieldError("guess", "Too high!");
|
||||
} else if (guess < answer) {
|
||||
addFieldError("guess", "Too low!");
|
||||
}
|
||||
|
||||
tries--;
|
||||
}
|
||||
|
||||
if (answer == guess) {
|
||||
addActionMessage("You got it!");
|
||||
} else {
|
||||
addActionMessage("You ran out of tries, the answer was " + answer);
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
public void setGuess(int guess) {
|
||||
this.guess = guess;
|
||||
}
|
||||
}
|
||||
// END SNIPPET: example
|
||||
@@ -1,10 +0,0 @@
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
<struts>
|
||||
<package name="continuations" extends="struts-default" namespace="/continuations">
|
||||
<action name="guess" class="org.apache.struts2.showcase.Guess">
|
||||
<result type="freemarker">guess.ftl</result>
|
||||
</action>
|
||||
</package>
|
||||
</struts>
|
||||
@@ -8,15 +8,13 @@
|
||||
<struts>
|
||||
|
||||
<include file="struts-chat.xml" />
|
||||
|
||||
|
||||
<include file="struts-hangman.xml" />
|
||||
|
||||
<include file="struts-continuations.xml"/>
|
||||
|
||||
<include file="struts-tags.xml"/>
|
||||
|
||||
|
||||
<include file="struts-validation.xml" />
|
||||
|
||||
|
||||
<include file="struts-actionchaining.xml" />
|
||||
|
||||
<include file="struts-ajax.xml" />
|
||||
@@ -26,19 +24,19 @@
|
||||
<include file="struts-person.xml" />
|
||||
|
||||
<include file="struts-wait.xml" />
|
||||
|
||||
|
||||
<include file="struts-jsf.xml" />
|
||||
|
||||
<include file="struts-token.xml" />
|
||||
|
||||
|
||||
<include file="struts-model-driven.xml" />
|
||||
|
||||
|
||||
<include file="struts-integration.xml" />
|
||||
|
||||
|
||||
<include file="struts-filedownload.xml" />
|
||||
|
||||
|
||||
<include file="struts-conversion.xml" />
|
||||
|
||||
|
||||
<include file="struts-freemarker.xml" />
|
||||
|
||||
<include file="struts-tiles.xml" />
|
||||
@@ -48,17 +46,17 @@
|
||||
<package name="default" extends="struts-default">
|
||||
<interceptors>
|
||||
<interceptor-stack name="crudStack">
|
||||
<interceptor-ref name="checkbox" />
|
||||
<interceptor-ref name="checkbox" />
|
||||
<interceptor-ref name="params" />
|
||||
<interceptor-ref name="static-params" />
|
||||
<interceptor-ref name="static-params" />
|
||||
<interceptor-ref name="defaultStack" />
|
||||
</interceptor-stack>
|
||||
</interceptors>
|
||||
|
||||
|
||||
<action name="showcase">
|
||||
<result>showcase.jsp</result>
|
||||
</action>
|
||||
|
||||
|
||||
<action name="viewSource" class="org.apache.struts2.showcase.source.ViewSourceAction">
|
||||
<result>viewSource.jsp</result>
|
||||
</action>
|
||||
@@ -99,7 +97,7 @@
|
||||
<interceptor-ref name="basicStack"/>
|
||||
</action>
|
||||
<action name="edit-*" class="org.apache.struts2.showcase.action.EmployeeAction">
|
||||
<param name="empId">{1}</param>
|
||||
<param name="empId">{1}</param>
|
||||
<result>/empmanager/editEmployee.jsp</result>
|
||||
<interceptor-ref name="crudStack"><param name="validation.excludeMethods">execute</param></interceptor-ref>
|
||||
</action>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
|
||||
|
||||
// Calculate the view sources url
|
||||
String sourceUrl = request.getContextPath()+"/viewSource.action";
|
||||
com.opensymphony.xwork2.ActionInvocation inv = com.opensymphony.xwork2.ActionContext.getContext().getActionInvocation();
|
||||
@@ -14,9 +14,9 @@
|
||||
com.opensymphony.xwork2.util.location.Location loc = inv.getProxy().getConfig().getLocation();
|
||||
sourceUrl += "?config="+(loc != null ? loc.getURI()+":"+loc.getLineNumber() : "");
|
||||
sourceUrl += "&className="+inv.getProxy().getConfig().getClassName();
|
||||
|
||||
|
||||
if (inv.getResult() != null && inv.getResult() instanceof org.apache.struts2.dispatcher.StrutsResultSupport) {
|
||||
sourceUrl += "&page="+mapping.getNamespace()+"/"+((org.apache.struts2.dispatcher.StrutsResultSupport)inv.getResult()).getLastFinalLocation();
|
||||
sourceUrl += "&page="+mapping.getNamespace()+"/"+((org.apache.struts2.dispatcher.StrutsResultSupport)inv.getResult()).getLastFinalLocation();
|
||||
}
|
||||
} else {
|
||||
sourceUrl += "?page="+request.getServletPath();
|
||||
@@ -104,11 +104,11 @@
|
||||
|
||||
</div><!-- end content -->
|
||||
|
||||
<div>
|
||||
<p>
|
||||
<a href="<%=sourceUrl %>">View Sources</a>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p>
|
||||
<a href="<%=sourceUrl %>">View Sources</a>
|
||||
</p>
|
||||
</div>
|
||||
<div id="footer" class="clearfix">
|
||||
<p>Copyright © 2003-<s:property value="#dateAction.now.year + 1900" /> The Apache Software Foundation.</p>
|
||||
</div><!-- end footer -->
|
||||
|
||||
@@ -15,9 +15,9 @@ Note: The Ajax tags are experimental. These examples have only been tested under
|
||||
<li><a href="remotediv">Remote div tag</a></li>
|
||||
<li><a href="remotelink">Remote link tag</a></li>
|
||||
<li><a href="tabbedpanel">Tabbed panel</a></li>
|
||||
<li><a href="widgets">Widgets </a> (may not work in all browsers!)
|
||||
<li><a href="widgets">Widgets </a> (may not work in all browsers!)
|
||||
see the <a href="http://www.dojotoolkit.org">dojo website</a> for more information</li>
|
||||
<li>(broken) <a href="remoteforms">Remote forms</a></li>
|
||||
<li><a href="remoteforms">Remote forms</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<!-- START SNIPPET: example -->
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<#list actionMessages as msg>
|
||||
${msg}
|
||||
</#list>
|
||||
|
||||
<@s.form action="guess" method="post">
|
||||
<@s.textfield label="Guess" name="guess"/>
|
||||
<@s.submit value="Guess"/>
|
||||
</@s.form>
|
||||
</body>
|
||||
</html>
|
||||
<!-- END SNIPPET: example -->
|
||||
@@ -11,7 +11,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<@s.url id="url" action="hangmanAjax" namespace="/hangman" />
|
||||
<@s.a href="%{#url}">Hangman (Ajax - Experimental)</@s.a>
|
||||
(broken) <@s.a href="%{#url}">Hangman (Ajax - Experimental)</@s.a>
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<%--
|
||||
<%--
|
||||
showcase.jsp
|
||||
|
||||
|
||||
@version $Date$ $Id$
|
||||
--%>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<p>
|
||||
<%-- THIS LIST IS MAINTAINED IN WEB-INF/decorators/main.jsp TO CREATE THE MENU BAR -- EDIT THERE AND COPY HERE --%>
|
||||
<ul>
|
||||
<li><a href="<s:url value="/showcase.jsp"/>">Home</a></li>
|
||||
<li><a href="<s:url value="/showcase.jsp"/>">Home</a></li>
|
||||
<li><a href="<s:url value="/ajax/index.jsp" />">Ajax Theme for Struts Tags</a></li>
|
||||
<li><a href="<s:url value="/chat/index.jsp"/>">Ajax Chat</a>
|
||||
<li><a href="<s:url action="actionChain1!input" namespace="/actionchaining" includeParams="none" />">Action Chaining</a></li>
|
||||
@@ -52,15 +52,6 @@
|
||||
<li><a href="<s:url value="/validation/index.jsp"/>">Validation</a></li>
|
||||
<li class="last"><a href="<s:url value="/help.jsp"/>">Help</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Sandbox</h2>
|
||||
<p>
|
||||
These examples are under development and may not be fully operational.
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="<s:url action="guess" namespace="/continuations" />">Continuations</a></li>
|
||||
</ul>
|
||||
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
|
||||
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<%-- Show usage; Used in Header --%>
|
||||
@@ -6,10 +6,10 @@
|
||||
<html>
|
||||
<head><title><tiles:getAsString name="title"/></title></head>
|
||||
<body>
|
||||
<tiles:attribute name="header"/>
|
||||
<tiles:insertAttribute name="header"/>
|
||||
|
||||
<p id="body">
|
||||
<tiles:attribute name="body"/>
|
||||
<tiles:insertAttribute name="body"/>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+21
-21
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
/*
|
||||
* Copyright 2005-2006 The Apache Software Foundation.
|
||||
*
|
||||
*
|
||||
* Licensed 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.
|
||||
@@ -33,7 +33,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
|
||||
<scm>
|
||||
@@ -155,12 +155,13 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-api</artifactId>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
<artifactId>struts2-codebehind-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -192,37 +193,43 @@
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-pell-multipart-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plexus-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-spring-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-sitegraph-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-sitemesh-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-struts1-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-tiles-plugin</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Include optional dependencies -->
|
||||
@@ -416,7 +423,7 @@
|
||||
<version>1.2.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>myfaces</groupId>
|
||||
@@ -425,13 +432,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.rifers</groupId>
|
||||
<artifactId>rife-continuations</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Exclude transitive dependencies -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
|
||||
+80
-86
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.0-alpha-1-SNAPSHOT</version>
|
||||
<executions>
|
||||
@@ -31,25 +31,25 @@
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>opensymphony</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<classifier>sources</classifier>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${project.build.directory}/xwork-sources</outputDirectory>
|
||||
</configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>opensymphony</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<classifier>sources</classifier>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${project.build.directory}/xwork-sources</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.myfaces.tobago</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<configuration>
|
||||
<A>uri=/struts-tags,tlibVersion=2.2.3,jspVersion=1.2,shortName=s,displayName="Struts Tags",
|
||||
outFile=${basedir}/src/main/resources/META-INF/struts-tags.tld,
|
||||
outFile=${basedir}/target/classes/META-INF/struts-tags.tld,
|
||||
description="To make it easier to access dynamic data;
|
||||
the Apache Struts framework includes a library of custom tags.
|
||||
The tags interact with the framework's validation and internationalization features;
|
||||
@@ -75,14 +75,14 @@
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
@@ -111,68 +111,68 @@
|
||||
</reporting>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<!--
|
||||
Run the translator for Java 1.4 compatiblity
|
||||
<profile>
|
||||
<!--
|
||||
Run the translator for Java 1.4 compatiblity
|
||||
|
||||
Sample:
|
||||
$ cd struts/struts2/
|
||||
$ mvn clean install -Papps,j4 -Djava14.jar=$JAVA_HOME/../Classes/classes.jar
|
||||
Sample:
|
||||
$ cd struts/struts2/
|
||||
$ mvn clean install -Papps,j4 -Djava14.jar=$JAVA_HOME/../Classes/classes.jar
|
||||
|
||||
-->
|
||||
<id>j4</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>retrotranslator-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>retrotranslate</id>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-j4-jar</id>
|
||||
<goals><goal>jar</goal></goals>
|
||||
<configuration>
|
||||
<classesDirectory>${project.build.directory}/classes-retro</classesDirectory>
|
||||
<classifier>j4</classifier>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Extension-Name>${project.artifactId}-j4</Extension-Name>
|
||||
<Specification-Vendor>${project.organization.name}</Specification-Vendor>
|
||||
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
|
||||
<Implementation-Title>${project.description}</Implementation-Title>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Revision>${scm.revision}</Revision>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>sun.jdk</groupId>
|
||||
<artifactId>rt</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<scope>system</scope>
|
||||
<!-- path to rt.jar (on OSX, it's classes.jar) -->
|
||||
<systemPath>${java14.jar}</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.retrotranslator</groupId>
|
||||
<artifactId>retrotranslator-runtime</artifactId>
|
||||
<version>1.0.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
-->
|
||||
<id>j4</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>retrotranslator-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>retrotranslate</id>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-j4-jar</id>
|
||||
<goals><goal>jar</goal></goals>
|
||||
<configuration>
|
||||
<classesDirectory>${project.build.directory}/classes-retro</classesDirectory>
|
||||
<classifier>j4</classifier>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Extension-Name>${project.artifactId}-j4</Extension-Name>
|
||||
<Specification-Vendor>${project.organization.name}</Specification-Vendor>
|
||||
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
|
||||
<Implementation-Title>${project.description}</Implementation-Title>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Revision>${scm.revision}</Revision>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>sun.jdk</groupId>
|
||||
<artifactId>rt</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<scope>system</scope>
|
||||
<!-- path to rt.jar (on OSX, it's classes.jar) -->
|
||||
<systemPath>${java14.jar}</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.retrotranslator</groupId>
|
||||
<artifactId>retrotranslator-runtime</artifactId>
|
||||
<version>1.0.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>alljars</id>
|
||||
@@ -252,13 +252,7 @@
|
||||
<dependency>
|
||||
<groupId>opensymphony</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-api</artifactId>
|
||||
<version>${pom.version}</version>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -282,9 +276,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ognl</groupId>
|
||||
<groupId>opensymphony</groupId>
|
||||
<artifactId>ognl</artifactId>
|
||||
<version>2.6.9</version>
|
||||
<version>2.6.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -471,6 +465,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -49,6 +49,7 @@ public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements
|
||||
protected String notifyTopics;
|
||||
protected String showErrorTransportText;
|
||||
protected String indicator;
|
||||
protected String showLoadingText;
|
||||
|
||||
public AbstractRemoteCallUIBean(ValueStack stack, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
@@ -86,6 +87,8 @@ public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements
|
||||
addParameter("showErrorTransportText", findValue(showErrorTransportText, Boolean.class));
|
||||
else
|
||||
addParameter("showErrorTransportText", true);
|
||||
if (showLoadingText != null)
|
||||
addParameter("showLoadingText", findString(showLoadingText));
|
||||
}
|
||||
|
||||
|
||||
@@ -165,4 +168,8 @@ public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements
|
||||
this.indicator = indicator;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Show loading text on targets", type="Boolean", defaultValue="true")
|
||||
public void setShowLoadingText(String showLoadingText) {
|
||||
this.showLoadingText = showLoadingText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* 'listenTopics' comma separated list of topics names, that will trigger a request
|
||||
* 'indicator' element to be shown while the request executing
|
||||
* 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
|
||||
* 'showLoadingText' show loading text on targets</p>
|
||||
* 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/>
|
||||
* <ul>
|
||||
* <li>data: html or json object when type='load' or type='error'</li>
|
||||
|
||||
@@ -72,6 +72,9 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* 'loadMinimumCount' minimum number of characters that will force the content to be loaded<p/>
|
||||
* 'showDownError' show or hide the down arrow button
|
||||
* 'searchType' how the search must be performed, options are: "startstring", "startword" and "substring"<p/>
|
||||
* 'keyName' name of the field to which the selected key will be assigned<p/>
|
||||
* 'iconPath' path of icon used for the dropdown
|
||||
* 'templateCssPath' path to css file used to customize Dojo's widget
|
||||
* 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/>
|
||||
* <ul>
|
||||
* <li>data: selected value when type='valuechanged'</li>
|
||||
@@ -101,7 +104,10 @@ public class Autocompleter extends ComboBox {
|
||||
protected String loadOnTextChange;
|
||||
protected String loadMinimumCount;
|
||||
protected String showDownArrow;
|
||||
|
||||
protected String templateCssPath;
|
||||
protected String iconPath;
|
||||
protected String keyName;
|
||||
|
||||
public Autocompleter(ValueStack stack, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
@@ -159,11 +165,19 @@ public class Autocompleter extends ComboBox {
|
||||
addParameter("showDownArrow", findValue(showDownArrow, Boolean.class));
|
||||
else
|
||||
addParameter("showDownArrow", Boolean.TRUE);
|
||||
//get the key value
|
||||
if(name != null) {
|
||||
String keyNameExpr = "%{" + name + "Key}";
|
||||
addParameter("key", findString(keyNameExpr));
|
||||
if(templateCssPath != null)
|
||||
addParameter("templateCssPath", findString(templateCssPath));
|
||||
if(iconPath != null)
|
||||
addParameter("iconPath", findString(iconPath));
|
||||
if(keyName != null)
|
||||
addParameter("keyName", findString(keyName));
|
||||
else {
|
||||
keyName = name + "Key";
|
||||
addParameter("keyName", findString(keyName));
|
||||
}
|
||||
|
||||
String keyNameExpr = "%{" + keyName + "}";
|
||||
addParameter("key", findString(keyNameExpr));
|
||||
}
|
||||
|
||||
protected Object findListValue() {
|
||||
@@ -256,4 +270,19 @@ public class Autocompleter extends ComboBox {
|
||||
public void setList(String list) {
|
||||
super.setList(list);
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Template css path")
|
||||
public void setTemplateCssPath(String templateCssPath) {
|
||||
this.templateCssPath = templateCssPath;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Path to icon used for the dropdown")
|
||||
public void setIconPath(String iconPath) {
|
||||
this.iconPath = iconPath;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Name of the field to which the selected key will be assigned")
|
||||
public void setKeyName(String keyName) {
|
||||
this.keyName = keyName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
public class DateTimePicker extends UIBean {
|
||||
|
||||
final public static String TEMPLATE = "datetimepicker";
|
||||
final private static SimpleDateFormat RFC3399_FORMAT = new SimpleDateFormat(
|
||||
final private static SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss");
|
||||
final protected static Log LOG = LogFactory.getLog(DateTimePicker.class);
|
||||
|
||||
@@ -146,6 +146,7 @@ public class DateTimePicker extends UIBean {
|
||||
protected String staticDisplay;
|
||||
protected String dayWidth;
|
||||
protected String language;
|
||||
protected String templateCssPath;
|
||||
|
||||
public DateTimePicker(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
@@ -177,7 +178,7 @@ public class DateTimePicker extends UIBean {
|
||||
if(value != null)
|
||||
addParameter("value", findString(value));
|
||||
if(iconPath != null)
|
||||
addParameter("iconPath", iconPath);
|
||||
addParameter("iconPath", findString(iconPath));
|
||||
if(formatLength != null)
|
||||
addParameter("formatLength", findString(formatLength));
|
||||
if(displayFormat != null)
|
||||
@@ -191,7 +192,9 @@ public class DateTimePicker extends UIBean {
|
||||
addParameter("type", findString(type));
|
||||
else
|
||||
addParameter("type", "date");
|
||||
|
||||
if(templateCssPath != null)
|
||||
addParameter("templateCssPath", findString(templateCssPath));
|
||||
|
||||
// format the value to RFC 3399
|
||||
if(parameters.containsKey("value")) {
|
||||
parameters.put("nameValue", format(parameters.get("value")));
|
||||
@@ -258,7 +261,7 @@ public class DateTimePicker extends UIBean {
|
||||
this.formatLength = formatLength;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description=" Path to icon used for the dropdown")
|
||||
@StrutsTagAttribute(description="Path to icon used for the dropdown")
|
||||
public void setIconPath(String iconPath) {
|
||||
this.iconPath = iconPath;
|
||||
}
|
||||
@@ -279,17 +282,22 @@ public class DateTimePicker extends UIBean {
|
||||
this.toggleType = toggleType;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Template css path")
|
||||
public void setTemplateCssPath(String templateCssPath) {
|
||||
this.templateCssPath = templateCssPath;
|
||||
}
|
||||
|
||||
private String format(Object obj) {
|
||||
if(obj == null)
|
||||
return null;
|
||||
|
||||
if(obj instanceof Date) {
|
||||
return RFC3399_FORMAT.format((Date) obj);
|
||||
return RFC3339_FORMAT.format((Date) obj);
|
||||
} else {
|
||||
// try to parse a date
|
||||
String dateStr = obj.toString();
|
||||
if(dateStr.equalsIgnoreCase("today"))
|
||||
return RFC3399_FORMAT.format(new Date());
|
||||
return RFC3339_FORMAT.format(new Date());
|
||||
|
||||
try {
|
||||
Date date = null;
|
||||
@@ -297,7 +305,7 @@ public class DateTimePicker extends UIBean {
|
||||
SimpleDateFormat format = new SimpleDateFormat(
|
||||
this.displayFormat);
|
||||
date = format.parse(dateStr);
|
||||
return RFC3399_FORMAT.format(date);
|
||||
return RFC3339_FORMAT.format(date);
|
||||
} else {
|
||||
// last resource to assume already in correct/default format
|
||||
return dateStr;
|
||||
|
||||
@@ -76,6 +76,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* 'listenTopics' comma separated list of topics names, that will trigger a request
|
||||
* 'indicator' element to be shown while the request executing
|
||||
* 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
|
||||
* 'showLoadingText' show loading text on targets</p>
|
||||
* 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:
|
||||
* <ul>
|
||||
* <li>data: html or json object when type='load' or type='error'</li>
|
||||
|
||||
@@ -514,7 +514,6 @@ public abstract class DoubleListUIBean extends ListUIBean {
|
||||
return doubleList;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Set the list key of the second attribute")
|
||||
public String getDoubleListKey() {
|
||||
return doubleListKey;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ public interface RemoteUICallBean {
|
||||
|
||||
void setShowErrorTransportText(String showError);
|
||||
|
||||
void setShowLoadingText(String showLoadingText);
|
||||
|
||||
void setIndicator(String indicator);
|
||||
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* 'listenTopics' comma separated list of topics names, that will trigger a request
|
||||
* 'indicator' element to be shown while the request executing
|
||||
* 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
|
||||
* 'showLoadingText' show loading text on targets</p>
|
||||
* 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/>
|
||||
* <ul>
|
||||
* <li>data: html or json object when type='load' or type='error'</li>
|
||||
@@ -154,7 +155,7 @@ public class Submit extends FormButton implements RemoteUICallBean{
|
||||
protected String notifyTopics;
|
||||
protected String showErrorTransportText;
|
||||
protected String indicator;
|
||||
|
||||
protected String showLoadingText;
|
||||
//these two are called "preInvokeJS" and "onLoadJS" on the tld
|
||||
//Names changed here to keep some consistency
|
||||
protected String beforeLoading;
|
||||
@@ -214,6 +215,8 @@ public class Submit extends FormButton implements RemoteUICallBean{
|
||||
addParameter("indicator", findString(indicator));
|
||||
if (targets != null)
|
||||
addParameter("targets", findString(targets));
|
||||
if (showLoadingText != null)
|
||||
addParameter("showLoadingText", findString(showLoadingText));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,4 +330,9 @@ public class Submit extends FormButton implements RemoteUICallBean{
|
||||
public void setIndicator(String indicator) {
|
||||
this.indicator = indicator;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Show loading text on targets", type="Boolean", defaultValue="true")
|
||||
public void setShowLoadingText(String showLoadingText) {
|
||||
this.showLoadingText = showLoadingText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class TabbedPanel extends ClosingUIBean {
|
||||
protected String selectedTab;
|
||||
protected String closeButton;
|
||||
protected String doLayout ;
|
||||
protected String templateCssPath;
|
||||
|
||||
public TabbedPanel(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
@@ -89,6 +90,8 @@ public class TabbedPanel extends ClosingUIBean {
|
||||
addParameter("labelPosition", null);
|
||||
addParameter("labelPosition", labelPosition);
|
||||
}
|
||||
if(templateCssPath != null)
|
||||
addParameter("templateCssPath", findString(templateCssPath));
|
||||
}
|
||||
|
||||
public String getDefaultOpenTemplate() {
|
||||
@@ -124,4 +127,9 @@ public class TabbedPanel extends ClosingUIBean {
|
||||
public void setDoLayout(String doLayout) {
|
||||
this.doLayout = doLayout;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Template css path")
|
||||
public void setTemplateCssPath(String templateCssPath) {
|
||||
this.templateCssPath = templateCssPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,8 +515,7 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
LOG.error("Could not find action or result", e);
|
||||
sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not execute action", e);
|
||||
sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
|
||||
throw new ServletException(e);
|
||||
} finally {
|
||||
UtilTimerStack.pop(timerKey);
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.struts2.spi.ActionContext;
|
||||
import org.apache.struts2.spi.Result;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
|
||||
public class ActionContextImpl implements ActionContext {
|
||||
|
||||
final ActionInvocation invocation;
|
||||
|
||||
public ActionContextImpl(ActionInvocation invocation) {
|
||||
this.invocation = invocation;
|
||||
}
|
||||
|
||||
public Object getAction() {
|
||||
return invocation.getAction();
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
String methodName = invocation.getProxy().getMethod();
|
||||
try {
|
||||
return getAction().getClass().getMethod(methodName);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getActionName() {
|
||||
return invocation.getProxy().getActionName();
|
||||
}
|
||||
|
||||
public String getNamespacePath() {
|
||||
return invocation.getProxy().getNamespace();
|
||||
}
|
||||
|
||||
// TODO: Do something with these.
|
||||
List<Result> resultInterceptors = new ArrayList<Result>();
|
||||
|
||||
public void addResultInterceptor(Result interceptor) {
|
||||
resultInterceptors.add(interceptor);
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ActionContext getPrevious() {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ActionContext getNext() {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import static org.apache.struts2.impl.RequestContextImpl.ILLEGAL_PROCEED;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
|
||||
public class InterceptorAdapter implements Interceptor {
|
||||
|
||||
private static final long serialVersionUID = 8020658947818231684L;
|
||||
final org.apache.struts2.spi.Interceptor delegate;
|
||||
|
||||
public InterceptorAdapter(org.apache.struts2.spi.Interceptor delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public String intercept(final ActionInvocation invocation) throws Exception {
|
||||
final RequestContextImpl requestContext = RequestContextImpl.get();
|
||||
|
||||
// Save the existing proceed implementation so we can restore it later.
|
||||
Callable<String> previous = requestContext.getProceed();
|
||||
|
||||
requestContext.setProceed(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
// This proceed implementation is no longer valid past this point.
|
||||
requestContext.setProceed(ILLEGAL_PROCEED);
|
||||
try {
|
||||
return invocation.invoke();
|
||||
} finally {
|
||||
// We're valid again.
|
||||
requestContext.setProceed(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
return delegate.intercept(requestContext);
|
||||
} finally {
|
||||
requestContext.setProceed(previous);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {}
|
||||
public void init() {}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.struts2.Messages;
|
||||
|
||||
import com.opensymphony.xwork2.DefaultTextProvider;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
|
||||
public class MessagesImpl implements Messages {
|
||||
|
||||
final TextProvider textProvider = DefaultTextProvider.INSTANCE;
|
||||
Map<String, Messages> fieldMap = new HashMap<String, Messages>();
|
||||
Map<Severity, List<String>> severityMap = new EnumMap<Severity, List<String>>(Severity.class);
|
||||
|
||||
public Messages forField(String fieldName) {
|
||||
Messages forField = fieldMap.get(fieldName);
|
||||
if (forField == null) {
|
||||
forField = new MessagesImpl();
|
||||
fieldMap.put(fieldName, forField);
|
||||
}
|
||||
return forField;
|
||||
}
|
||||
|
||||
public Map<String, Messages> forFields() {
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
public void addInformation(String key) {
|
||||
forSeverity(Severity.INFO).add(textProvider.getText(key));
|
||||
}
|
||||
|
||||
public void addInformation(String key, String... arguments) {
|
||||
forSeverity(Severity.INFO).add(textProvider.getText(key, arguments));
|
||||
}
|
||||
|
||||
public void addWarning(String key) {
|
||||
forSeverity(Severity.WARN).add(textProvider.getText(key));
|
||||
}
|
||||
|
||||
public void addWarning(String key, String... arguments) {
|
||||
forSeverity(Severity.WARN).add(textProvider.getText(key, arguments));
|
||||
}
|
||||
|
||||
public void addError(String key) {
|
||||
forSeverity(Severity.ERROR).add(textProvider.getText(key));
|
||||
}
|
||||
|
||||
public void addError(String key, String... arguments) {
|
||||
forSeverity(Severity.ERROR).add(textProvider.getText(key, arguments));
|
||||
}
|
||||
|
||||
public void add(Severity severity, String key) {
|
||||
forSeverity(severity).add(textProvider.getText(key));
|
||||
}
|
||||
|
||||
public void add(Severity severity, String key, String... arguments) {
|
||||
forSeverity(severity).add(textProvider.getText(key, arguments));
|
||||
}
|
||||
|
||||
public Set<Severity> getSeverities() {
|
||||
Set<Severity> severities = EnumSet.noneOf(Severity.class);
|
||||
for (Severity severity : Severity.values()) {
|
||||
List<String> messages = severityMap.get(severity);
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
severities.add(severity);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(severities);
|
||||
}
|
||||
|
||||
public List<String> forSeverity(Severity severity) {
|
||||
List<String> messages = severityMap.get(severity);
|
||||
if (messages == null) {
|
||||
messages = new ArrayList<String>();
|
||||
severityMap.put(severity, messages);
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
public List<String> getErrors() {
|
||||
return forSeverity(Severity.ERROR);
|
||||
}
|
||||
|
||||
public List<String> getWarnings() {
|
||||
return forSeverity(Severity.WARN);
|
||||
}
|
||||
|
||||
public List<String> getInformation() {
|
||||
return forSeverity(Severity.INFO);
|
||||
}
|
||||
|
||||
public boolean hasErrors() {
|
||||
return !isEmpty(Severity.ERROR);
|
||||
}
|
||||
|
||||
public boolean hasWarnings() {
|
||||
return !isEmpty(Severity.WARN);
|
||||
}
|
||||
|
||||
public boolean hasInformation() {
|
||||
return !isEmpty(Severity.INFO);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
for (Severity severity : Severity.values())
|
||||
if (!isEmpty(severity))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty(Severity severity) {
|
||||
List<String> messages = severityMap.get(severity);
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Messages fieldMessages : fieldMap.values())
|
||||
if (!fieldMessages.isEmpty(severity))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import static org.apache.struts2.StrutsStatics.HTTP_REQUEST;
|
||||
import static org.apache.struts2.StrutsStatics.HTTP_RESPONSE;
|
||||
import static org.apache.struts2.StrutsStatics.SERVLET_CONTEXT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.Messages;
|
||||
import org.apache.struts2.dispatcher.RequestMap;
|
||||
import org.apache.struts2.spi.ActionContext;
|
||||
import org.apache.struts2.spi.RequestContext;
|
||||
import org.apache.struts2.spi.ValueStack;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
|
||||
public class RequestContextImpl implements RequestContext {
|
||||
|
||||
com.opensymphony.xwork2.ActionContext xworkContext;
|
||||
ActionContext actionContext;
|
||||
Messages messages = new MessagesImpl();
|
||||
|
||||
public static final Callable<String> ILLEGAL_PROCEED = new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
};
|
||||
|
||||
public RequestContextImpl(com.opensymphony.xwork2.ActionContext xworkContext) {
|
||||
this.xworkContext = xworkContext;
|
||||
}
|
||||
|
||||
public ActionContext getActionContext() {
|
||||
return actionContext;
|
||||
}
|
||||
|
||||
public Object getAction() {
|
||||
return getActionContext().getAction();
|
||||
}
|
||||
|
||||
void setActionContext(ActionContext actionContext) {
|
||||
this.actionContext = actionContext;
|
||||
}
|
||||
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return xworkContext.getParameters();
|
||||
}
|
||||
|
||||
Map<String, Object> attributeMap;
|
||||
|
||||
public Map<String, Object> getAttributeMap() {
|
||||
if (attributeMap == null) {
|
||||
attributeMap = new RequestMap(getServletRequest());
|
||||
}
|
||||
return attributeMap;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSessionMap() {
|
||||
return xworkContext.getSession();
|
||||
}
|
||||
|
||||
public Map<String, Object> getApplicationMap() {
|
||||
return xworkContext.getApplication();
|
||||
}
|
||||
|
||||
public List<Cookie> findCookiesForName(String name) {
|
||||
List<Cookie> cookies = new ArrayList<Cookie>();
|
||||
for (Cookie cookie : getServletRequest().getCookies())
|
||||
if (name.equals(cookie.getName()))
|
||||
cookies.add(cookie);
|
||||
|
||||
return cookies;
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return xworkContext.getLocale();
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
xworkContext.setLocale(locale);
|
||||
}
|
||||
|
||||
public Messages getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public HttpServletRequest getServletRequest() {
|
||||
return (HttpServletRequest) xworkContext.get(HTTP_REQUEST);
|
||||
}
|
||||
|
||||
public HttpServletResponse getServletResponse() {
|
||||
return (HttpServletResponse) xworkContext.get(HTTP_RESPONSE);
|
||||
}
|
||||
|
||||
public ServletContext getServletContext() {
|
||||
return (ServletContext) xworkContext.get(SERVLET_CONTEXT);
|
||||
}
|
||||
|
||||
ValueStack valueStack;
|
||||
|
||||
public ValueStack getValueStack() {
|
||||
if (valueStack == null) {
|
||||
valueStack = new ValueStackAdapter(xworkContext.getValueStack());
|
||||
}
|
||||
return valueStack;
|
||||
}
|
||||
|
||||
Callable<String> proceed = ILLEGAL_PROCEED;
|
||||
|
||||
public String proceed() throws Exception {
|
||||
return proceed.call();
|
||||
}
|
||||
|
||||
public void setProceed(Callable<String> proceed) {
|
||||
this.proceed = proceed;
|
||||
}
|
||||
|
||||
public Callable<String> getProceed() {
|
||||
return proceed;
|
||||
}
|
||||
|
||||
static ThreadLocal<Object[]> threadLocalRequestContext = new ThreadLocal<Object[]>() {
|
||||
protected RequestContextImpl[] initialValue() {
|
||||
return new RequestContextImpl[1];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates RequestContext if necessary. Always creates a new ActionContext and restores an existing ActionContext
|
||||
* when finished.
|
||||
*/
|
||||
public static String callInContext(ActionInvocation invocation, Callable<String> callable)
|
||||
throws Exception {
|
||||
RequestContextImpl[] reference = (RequestContextImpl[])threadLocalRequestContext.get();
|
||||
|
||||
if (reference[0] == null) {
|
||||
// Initial invocation.
|
||||
reference[0] = new RequestContextImpl(invocation.getInvocationContext());
|
||||
reference[0].setActionContext(new ActionContextImpl(invocation));
|
||||
try {
|
||||
return callable.call();
|
||||
} finally {
|
||||
reference[0] = null;
|
||||
}
|
||||
} else {
|
||||
// Nested invocation.
|
||||
RequestContextImpl requestContext = reference[0];
|
||||
ActionContext previous = requestContext.getActionContext();
|
||||
requestContext.setActionContext(new ActionContextImpl(invocation));
|
||||
try {
|
||||
return callable.call();
|
||||
} finally {
|
||||
requestContext.setActionContext(previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static RequestContextImpl get() {
|
||||
RequestContextImpl requestContext = ((RequestContextImpl[])threadLocalRequestContext.get())[0];
|
||||
|
||||
if (requestContext == null)
|
||||
throw new IllegalStateException("RequestContext has not been created.");
|
||||
|
||||
return requestContext;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
|
||||
public class ResultAdapter implements Result {
|
||||
|
||||
private static final long serialVersionUID = -5107033078266553554L;
|
||||
final org.apache.struts2.spi.Result delegate;
|
||||
|
||||
public ResultAdapter(org.apache.struts2.spi.Result delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public void execute(ActionInvocation invocation) throws Exception {
|
||||
delegate.execute(RequestContextImpl.get());
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,11 @@
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.DefaultActionProxy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class StrutsActionProxy extends DefaultActionProxy {
|
||||
|
||||
private static final long serialVersionUID = -2434901249671934080L;
|
||||
@@ -41,11 +40,14 @@ public class StrutsActionProxy extends DefaultActionProxy {
|
||||
ActionContext previous = ActionContext.getContext();
|
||||
ActionContext.setContext(invocation.getInvocationContext());
|
||||
try {
|
||||
return RequestContextImpl.callInContext(invocation, new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return invocation.invoke();
|
||||
}
|
||||
});
|
||||
// This is for the new API:
|
||||
// return RequestContextImpl.callInContext(invocation, new Callable<String>() {
|
||||
// public String call() throws Exception {
|
||||
// return invocation.invoke();
|
||||
// }
|
||||
// });
|
||||
|
||||
return invocation.invoke();
|
||||
} finally {
|
||||
if (cleanupContext)
|
||||
ActionContext.setContext(previous);
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
@@ -33,6 +30,9 @@ import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.OgnlUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StrutsObjectFactory extends ObjectFactory {
|
||||
|
||||
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map refParams)
|
||||
@@ -59,8 +59,9 @@ public class StrutsObjectFactory extends ObjectFactory {
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
if (o instanceof org.apache.struts2.spi.Interceptor)
|
||||
return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o);
|
||||
// This is for the new API:
|
||||
// if (o instanceof org.apache.struts2.spi.Interceptor)
|
||||
// return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o);
|
||||
|
||||
throw new ConfigurationException(
|
||||
"Class [" + className + "] does not implement Interceptor", interceptorConfig);
|
||||
@@ -96,8 +97,9 @@ public class StrutsObjectFactory extends ObjectFactory {
|
||||
if (result instanceof Result)
|
||||
return (Result) result;
|
||||
|
||||
if (result instanceof org.apache.struts2.spi.Result)
|
||||
return new ResultAdapter((org.apache.struts2.spi.Result) result);
|
||||
// This is for the new API:
|
||||
// if (result instanceof org.apache.struts2.spi.Result)
|
||||
// return new ResultAdapter((org.apache.struts2.spi.Result) result);
|
||||
|
||||
throw new ConfigurationException(result.getClass().getName() + " does not implement Result.");
|
||||
}
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.struts2.spi.ValueStack;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
|
||||
public class ValueStackAdapter implements ValueStack {
|
||||
|
||||
final com.opensymphony.xwork2.util.ValueStack delegate;
|
||||
|
||||
public ValueStackAdapter(com.opensymphony.xwork2.util.ValueStack delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public Object peek() {
|
||||
return delegate.peek();
|
||||
}
|
||||
|
||||
public Object pop() {
|
||||
return delegate.pop();
|
||||
}
|
||||
|
||||
public void push(Object o) {
|
||||
delegate.push(o);
|
||||
}
|
||||
|
||||
public ValueStack clone() {
|
||||
return new ValueStackAdapter(ValueStackFactory.getFactory().createValueStack(delegate));
|
||||
}
|
||||
|
||||
public Object get(String expr) {
|
||||
return delegate.findValue(expr);
|
||||
}
|
||||
|
||||
public <T> T get(String expr, Class<T> requiredType) {
|
||||
return (T) delegate.findValue(expr, requiredType);
|
||||
}
|
||||
|
||||
public String getString(String expr) {
|
||||
return delegate.findString(expr);
|
||||
}
|
||||
|
||||
public void set(String expr, Object o) {
|
||||
delegate.set(expr, o);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return delegate.size();
|
||||
}
|
||||
|
||||
public Iterator<Object> iterator() {
|
||||
return delegate.getRoot().iterator();
|
||||
}
|
||||
}
|
||||
@@ -193,12 +193,23 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
|
||||
return new BackgroundProcess(name + "BackgroundThread", actionInvocation, threadPriority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name to associate the background process. Override to change the way background processes
|
||||
* are mapped to requests.
|
||||
*
|
||||
* @param actionInvocation The action invocation
|
||||
* @return the name of the background thread
|
||||
*/
|
||||
protected String getBackgroundProcessName(ActionProxy proxy) {
|
||||
return proxy.getActionName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.opensymphony.xwork2.interceptor.MethodFilterInterceptor#doIntercept(com.opensymphony.xwork2.ActionInvocation)
|
||||
*/
|
||||
protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
|
||||
ActionProxy proxy = actionInvocation.getProxy();
|
||||
String name = proxy.getActionName();
|
||||
String name = getBackgroundProcessName(proxy);
|
||||
ActionContext context = actionInvocation.getInvocationContext();
|
||||
Map session = context.getSession();
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public abstract class AbstractRemoteCallUITag extends AbstractClosingTag {
|
||||
protected String formFilter;
|
||||
protected String showErrorTransportText;
|
||||
protected String indicator;
|
||||
protected String showLoadingText;
|
||||
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
@@ -52,6 +53,7 @@ public abstract class AbstractRemoteCallUITag extends AbstractClosingTag {
|
||||
remote.setNotifyTopics(notifyTopics);
|
||||
remote.setShowErrorTransportText(showErrorTransportText);
|
||||
remote.setIndicator(indicator);
|
||||
remote.setShowLoadingText(showLoadingText);
|
||||
}
|
||||
|
||||
public void setHref(String href) {
|
||||
@@ -108,4 +110,8 @@ public abstract class AbstractRemoteCallUITag extends AbstractClosingTag {
|
||||
public void setIndicator(String indicator) {
|
||||
this.indicator = indicator;
|
||||
}
|
||||
|
||||
public void setShowLoadingText(String showLoadingText) {
|
||||
this.showLoadingText = showLoadingText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,10 @@ public class AutocompleterTag extends ComboBoxTag {
|
||||
protected String loadOnTextChange;
|
||||
protected String loadMinimumCount;
|
||||
protected String showDownArrow;
|
||||
|
||||
protected String templateCssPath;
|
||||
protected String iconPath;
|
||||
protected String keyName;
|
||||
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Autocompleter(stack, req, res);
|
||||
}
|
||||
@@ -75,6 +78,9 @@ public class AutocompleterTag extends ComboBoxTag {
|
||||
autocompleter.setLoadMinimumCount(loadMinimumCount);
|
||||
autocompleter.setLoadOnTextChange(loadOnTextChange);
|
||||
autocompleter.setShowDownArrow(showDownArrow);
|
||||
autocompleter.setTemplateCssPath(templateCssPath);
|
||||
autocompleter.setIconPath(iconPath);
|
||||
autocompleter.setKeyName(keyName);
|
||||
}
|
||||
|
||||
public void setAutoComplete(String autoComplete) {
|
||||
@@ -145,4 +151,15 @@ public class AutocompleterTag extends ComboBoxTag {
|
||||
this.showDownArrow = showDownArrow;
|
||||
}
|
||||
|
||||
public void setTemplateCssPath(String templateCssPath) {
|
||||
this.templateCssPath = templateCssPath;
|
||||
}
|
||||
|
||||
public void setIconPath(String iconPath) {
|
||||
this.iconPath = iconPath;
|
||||
}
|
||||
|
||||
public void setKeyName(String keyName) {
|
||||
this.keyName = keyName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class DateTimePickerTag extends AbstractUITag {
|
||||
protected String toggleType;
|
||||
protected String toggleDuration;
|
||||
protected String type;
|
||||
protected String templateCssPath;
|
||||
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new DateTimePicker(stack, req, res);
|
||||
@@ -73,6 +74,7 @@ public class DateTimePickerTag extends AbstractUITag {
|
||||
dateTimePicker.setToggleType(toggleType);
|
||||
dateTimePicker.setToggleDuration(toggleDuration);
|
||||
dateTimePicker.setType(type);
|
||||
dateTimePicker.setTemplateCssPath(templateCssPath);
|
||||
}
|
||||
|
||||
public void setAdjustWeeks(String adjustWeeks) {
|
||||
@@ -130,4 +132,8 @@ public class DateTimePickerTag extends AbstractUITag {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setTemplateCssPath(String templateCssPath) {
|
||||
this.templateCssPath = templateCssPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public class SubmitTag extends AbstractUITag {
|
||||
protected String src;
|
||||
protected String showErrorTransportText;
|
||||
protected String indicator;
|
||||
protected String showLoadingText;
|
||||
|
||||
//these two are called "preInvokeJS" and "onLoadJS" on the tld
|
||||
//Names changed here to keep some consistency
|
||||
@@ -87,6 +88,7 @@ public class SubmitTag extends AbstractUITag {
|
||||
submit.setNotifyTopics(notifyTopics);
|
||||
submit.setShowErrorTransportText(showErrorTransportText);
|
||||
submit.setIndicator(indicator);
|
||||
submit.setShowLoadingText(showLoadingText);
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
@@ -175,4 +177,8 @@ public class SubmitTag extends AbstractUITag {
|
||||
public void setIndicator(String indicator) {
|
||||
this.indicator = indicator;
|
||||
}
|
||||
|
||||
public void setShowLoadingText(String showLoadingText) {
|
||||
this.showLoadingText = showLoadingText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TabbedPanelTag extends AbstractClosingTag {
|
||||
private String selectedTab;
|
||||
private String closeButton;
|
||||
private String doLayout;
|
||||
private String templateCssPath;
|
||||
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new TabbedPanel(stack, req, res);
|
||||
@@ -50,6 +51,7 @@ public class TabbedPanelTag extends AbstractClosingTag {
|
||||
tabbedPanel.setCloseButton(closeButton);
|
||||
tabbedPanel.setDoLayout(doLayout);
|
||||
tabbedPanel.setLabelposition(labelPosition);
|
||||
tabbedPanel.setTemplateCssPath(templateCssPath);
|
||||
}
|
||||
|
||||
public void setSelectedTab(String selectedTab) {
|
||||
@@ -63,4 +65,8 @@ public class TabbedPanelTag extends AbstractClosingTag {
|
||||
public void setDoLayout(String doLayout) {
|
||||
this.doLayout = doLayout;
|
||||
}
|
||||
|
||||
public void setTemplateCssPath(String templateCssPath) {
|
||||
this.templateCssPath = templateCssPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +103,12 @@ public class UrlHelper {
|
||||
link.append("://");
|
||||
link.append(request.getServerName());
|
||||
|
||||
if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT))
|
||||
{
|
||||
link.append(":");
|
||||
link.append(scheme.equals("http") ? httpPort : httpsPort);
|
||||
if (scheme != null) {
|
||||
if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT))
|
||||
{
|
||||
link.append(":");
|
||||
link.append(scheme.equals("http") ? httpPort : httpsPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
TLD file is generated inside META-INF after compilation.
|
||||
If META-INF is empty, Maven will not copy it to the "target/classes" folder.
|
||||
Please do not remove META-INF, or this file.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -205,6 +205,7 @@ dojo.widget.defineWidget(
|
||||
//dojo has "stringstart" which is invalid
|
||||
searchType: "STARTSTRING",
|
||||
|
||||
keyName: "",
|
||||
templateCssPath: dojo.uri.dojoUri("struts/ComboBox.css"),
|
||||
//from Dojo's ComboBox
|
||||
showResultList: function() {
|
||||
@@ -315,7 +316,7 @@ dojo.widget.defineWidget(
|
||||
}
|
||||
|
||||
//better name
|
||||
this.comboBoxSelectionValue.name = this.name + "Key";
|
||||
this.comboBoxSelectionValue.name = dojo.string.isBlank(this.keyName) ? this.name + "Key" : this.keyName;
|
||||
|
||||
//init values
|
||||
this.comboBoxValue.value = this.initialValue;
|
||||
|
||||
@@ -61,3 +61,6 @@
|
||||
<#if parameters.showErrorTransportText?exists>
|
||||
showError="${parameters.showErrorTransportText?string?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.showLoadingText?exists>
|
||||
showLoading="${parameters.showLoadingText?string?html}"<#rt/>
|
||||
</#if>
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
<#if parameters.get("size")?exists>
|
||||
size="${parameters.get("size")?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.keyName?if_exists != "">
|
||||
keyName="${parameters.keyName?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.maxlength?exists>
|
||||
maxlength="${parameters.maxlength?string?html}"<#rt/>
|
||||
</#if>
|
||||
@@ -77,6 +80,12 @@
|
||||
<#if parameters.showDownArrow?exists>
|
||||
visibleDownArrow="${parameters.showDownArrow?string?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.iconPath?if_exists != "">
|
||||
buttonSrc="<@s.url value='${parameters.iconPath}' encode="false" includeParams='none'/>"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.templateCssPath?if_exists != "">
|
||||
templateCssPath="<@s.url value='${parameters.templateCssPath}' encode="false" includeParams='none'/>"
|
||||
</#if>
|
||||
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
|
||||
>
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<#if parameters.stopTimerListenTopics?if_exists != "">
|
||||
stopTimerListenTopics="${parameters.stopTimerListenTopics?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.refreshOnShow?exists>
|
||||
refreshOnShow="${parameters.refreshOnShow?string?html}"<#rt/>
|
||||
</#if>
|
||||
<#include "/${parameters.templateDir}/ajax/ajax-common.ftl" />
|
||||
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
|
||||
>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<#include "/${parameters.templateDir}/simple/dropdowndatetimepicker.ftl" />
|
||||
@@ -35,6 +35,9 @@
|
||||
<#if parameters.name?if_exists != "">
|
||||
name="${parameters.name?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.keyName?if_exists != "">
|
||||
keyName="${parameters.keyName?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.get("size")?exists>
|
||||
size="${parameters.get("size")?html}"<#rt/>
|
||||
</#if>
|
||||
@@ -65,6 +68,12 @@
|
||||
<#if parameters.notifyTopics?if_exists != "">
|
||||
notifyTopics="${parameters.notifyTopics?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.iconPath?if_exists != "">
|
||||
buttonSrc="<@s.url value='${parameters.iconPath}' encode="false" includeParams='none'/>"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.templateCssPath?if_exists != "">
|
||||
templateCssPath="<@s.url value='${parameters.templateCssPath}' encode="false" includeParams='none'/>"
|
||||
</#if>
|
||||
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
|
||||
>
|
||||
<#if parameters.list?exists>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
style="${parameters.cssStyle?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.iconPath?if_exists != "">
|
||||
iconURL="${parameters.iconPath}"<#rt/>
|
||||
iconURL="<@s.url value='${parameters.iconPath}' encode="false" includeParams='none'/>"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.formatLength?if_exists != "">
|
||||
formatLength="${parameters.formatLength?html}"<#rt/>
|
||||
@@ -65,6 +65,9 @@
|
||||
<#if parameters.toggleDuration?exists>
|
||||
containerToggleDuration="${parameters.toggleDuration?string?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.templateCssPath?exists>
|
||||
templateCssPath="<@s.url value='${parameters.templateCssPath}' encode="false" includeParams='none'/>"
|
||||
</#if>
|
||||
saveFormat="rfc"<#rt/>
|
||||
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
|
||||
></div>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<#assign itemValue = stack.findString('top')/>
|
||||
</#if>
|
||||
<option value="${itemKey?html}"<#rt/>
|
||||
<#if tag.contains(parameters.nameValue, itemKey) == true>
|
||||
<#if tag.contains(parameters.nameValue, itemKey) == true || (parameters.nameValue?exists && parameters.nameValue?string == itemKey)>
|
||||
selected="selected"<#rt/>
|
||||
</#if>
|
||||
>${itemValue?html}</option><#lt/>
|
||||
|
||||
@@ -26,4 +26,7 @@
|
||||
<#if parameters.doLayout?exists>
|
||||
doLayout="${parameters.doLayout?string?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.templateCssPath?exists>
|
||||
templateCssPath="<@s.url value='${parameters.templateCssPath}' encode="false" includeParams='none'/>"
|
||||
</#if>
|
||||
>
|
||||
|
||||
@@ -339,6 +339,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">Boolean</td>
|
||||
<td align="left" valign="top">Set whether errors will be shown or not</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">showLoadingText</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">Boolean</td>
|
||||
<td align="left" valign="top">Show loading text on targets</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">tabindex</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
|
||||
@@ -147,6 +147,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">The URL used to load the options</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">iconPath</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Path to icon used for the dropdown</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">id</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
@@ -171,6 +179,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Set the key (name, value, label) for this particular component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">keyName</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Name of the field to which the selected key will be assigned</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">label</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
@@ -443,6 +459,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">The template (other than default) to use for rendering the element</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">templateCssPath</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Template css path</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">templateDir</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
|
||||
@@ -113,7 +113,7 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top"> Path to icon used for the dropdown</td>
|
||||
<td align="left" valign="top">Path to icon used for the dropdown</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">id</td>
|
||||
@@ -323,6 +323,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">The template (other than default) to use for rendering the element</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">templateCssPath</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Template css path</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">templateDir</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
|
||||
@@ -355,6 +355,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">Boolean</td>
|
||||
<td align="left" valign="top">Set whether errors will be shown or not</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">showLoadingText</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">Boolean</td>
|
||||
<td align="left" valign="top">Show loading text on targets</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">startTimerListenTopics</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
|
||||
@@ -137,7 +137,7 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Set the list key of the second attribute</td>
|
||||
<td align="left" valign="top">The key expression to use for second list</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">doubleListValue</td>
|
||||
|
||||
@@ -241,7 +241,7 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Set the list key of the second attribute</td>
|
||||
<td align="left" valign="top">The key expression to use for second list</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">doubleListValue</td>
|
||||
|
||||
@@ -355,6 +355,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">Boolean</td>
|
||||
<td align="left" valign="top">Set whether errors will be shown or not</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">showLoadingText</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">Boolean</td>
|
||||
<td align="left" valign="top">Show loading text on targets</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">src</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
|
||||
@@ -275,6 +275,14 @@ Please do not edit it directly.
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">The template (other than default) to use for rendering the element</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">templateCssPath</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
<td align="left" valign="top"></td>
|
||||
<td align="left" valign="top">true</td>
|
||||
<td align="left" valign="top">String</td>
|
||||
<td align="left" valign="top">Template css path</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top">templateDir</td>
|
||||
<td align="left" valign="top">false</td>
|
||||
|
||||
@@ -40,6 +40,7 @@ public class TestAction extends ActionSupport {
|
||||
private Collection collection2;
|
||||
private Map map;
|
||||
private String foo;
|
||||
|
||||
private String result;
|
||||
private User user;
|
||||
private String[] array;
|
||||
@@ -61,7 +62,7 @@ public class TestAction extends ActionSupport {
|
||||
|
||||
public void setMap(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
}private Integer fooInt;
|
||||
|
||||
public String getFoo() {
|
||||
return foo;
|
||||
@@ -127,6 +128,14 @@ public class TestAction extends ActionSupport {
|
||||
this.collection2 = collection;
|
||||
}
|
||||
|
||||
public Integer getFooInt() {
|
||||
return fooInt;
|
||||
}
|
||||
|
||||
public void setFooInt(Integer fooInt) {
|
||||
this.fooInt = fooInt;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
if (result == null) {
|
||||
result = Action.SUCCESS;
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.struts2.Messages;
|
||||
|
||||
public class MessagesTest extends TestCase {
|
||||
|
||||
public void testForField() {
|
||||
Messages messages = new MessagesImpl();
|
||||
Messages fieldMessages = messages.forField("foo");
|
||||
fieldMessages.addError("foo");
|
||||
assertFalse(fieldMessages.getErrors().isEmpty());
|
||||
assertTrue(messages.hasErrors());
|
||||
}
|
||||
|
||||
public void testHasMessagesForSeverity() {
|
||||
for (Messages.Severity severity : Messages.Severity.values()) {
|
||||
Messages messages = new MessagesImpl();
|
||||
messages.add(severity, "foo");
|
||||
|
||||
assertFalse(messages.isEmpty(severity));
|
||||
|
||||
for (Messages.Severity other : Messages.Severity.values())
|
||||
if (other != severity)
|
||||
assertTrue(messages.isEmpty(other));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* $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.
|
||||
*/
|
||||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.apache.struts2.impl;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
|
||||
public class RequestContextTest extends TestCase {
|
||||
|
||||
public void testFindCookiesForName() {
|
||||
final HttpServletRequest servletRequest = createMock(HttpServletRequest.class);
|
||||
Cookie one = new Cookie("foo", "one");
|
||||
Cookie two = new Cookie("foo", "two");
|
||||
Cookie three = new Cookie("bar", "three");
|
||||
Cookie[] cookies = { one, two, three };
|
||||
expect(servletRequest.getCookies()).andReturn(cookies);
|
||||
|
||||
replay(servletRequest);
|
||||
|
||||
RequestContextImpl requestContext = new RequestContextImpl(null) {
|
||||
public HttpServletRequest getServletRequest() {
|
||||
return servletRequest;
|
||||
}
|
||||
};
|
||||
|
||||
List<Cookie> fooCookies = Arrays.asList(one, two);
|
||||
assertEquals(fooCookies, requestContext.findCookiesForName("foo"));
|
||||
}
|
||||
|
||||
public void testInitialCallInContext() throws Exception {
|
||||
final ActionInvocation invocation = createMock(ActionInvocation.class);
|
||||
final ActionContext actionContext = new ActionContext(new HashMap());
|
||||
expect(invocation.getInvocationContext()).andReturn(actionContext);
|
||||
|
||||
final boolean[] called = new boolean[1];
|
||||
Callable<String> callable = new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
RequestContextImpl requestContext = RequestContextImpl.get();
|
||||
assertSame(actionContext, requestContext.xworkContext);
|
||||
assertSame(invocation,
|
||||
((ActionContextImpl) requestContext.getActionContext()).invocation);
|
||||
called[0] = true;
|
||||
return "foo";
|
||||
}
|
||||
};
|
||||
|
||||
replay(invocation);
|
||||
|
||||
assertEquals("foo", RequestContextImpl.callInContext(invocation, callable));
|
||||
assertTrue(called[0]);
|
||||
assertNull(RequestContextImpl.threadLocalRequestContext.get()[0]);
|
||||
}
|
||||
|
||||
public void testNestedCallInContext() throws Exception {
|
||||
// TODO: After we implement ActionContext.getNext(), getPrevious().
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -48,6 +48,7 @@ public class AnnotationValidationInterceptorTest extends StrutsTestCase {
|
||||
public void testShouldNotSkip() throws Exception {
|
||||
mockActionProxy.expectAndReturn("getMethod", "execute");
|
||||
mockActionProxy.expectAndReturn("getActionName", "foo");
|
||||
mockActionProxy.expectAndReturn("getMethod", "execute");
|
||||
interceptor.doIntercept((ActionInvocation)mockActionInvocation.proxy());
|
||||
mockActionProxy.verify();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class StrutsMockServletContext implements ServletContext {
|
||||
|
||||
String realPath;
|
||||
String servletInfo;
|
||||
String contextPath;
|
||||
Map initParams = new HashMap();
|
||||
Map attributes = new HashMap();
|
||||
InputStream resourceAsStream;
|
||||
@@ -158,4 +159,12 @@ public class StrutsMockServletContext implements ServletContext {
|
||||
public void setServletInfo(String servletInfo) {
|
||||
this.servletInfo = servletInfo;
|
||||
}
|
||||
|
||||
public String getContextPath() {
|
||||
return contextPath;
|
||||
}
|
||||
|
||||
public void setContextPath(String contextPath) {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public class AnchorTest extends AbstractUITagTest {
|
||||
tag.setNotifyTopics("j");
|
||||
tag.setIndicator("k");
|
||||
tag.setShowErrorTransportText("true");
|
||||
tag.setShowLoadingText("true");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
|
||||
@@ -43,9 +43,12 @@ public class AutocompleterTest extends AbstractUITagTest {
|
||||
tag.setName("f");
|
||||
tag.setValue("g");
|
||||
tag.setIndicator("h");
|
||||
tag.setKeyName("i");
|
||||
tag.setLoadOnTextChange("true");
|
||||
tag.setLoadMinimumCount("3");
|
||||
tag.setShowDownArrow("false");
|
||||
tag.setIconPath("i");
|
||||
tag.setTemplateCssPath("j");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
@@ -67,6 +70,8 @@ public class AutocompleterTest extends AbstractUITagTest {
|
||||
tag.setSearchType("b");
|
||||
tag.setDisabled("c");
|
||||
tag.setName("f");
|
||||
tag.setIconPath("i");
|
||||
tag.setTemplateCssPath("j");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ public class DateTimePickerTagTest extends AbstractUITagTest {
|
||||
tag.setWeekStartsOn("g");
|
||||
tag.setName("h");
|
||||
tag.setLanguage("i");
|
||||
tag.setTemplateCssPath("j");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class DivTest extends AbstractUITagTest {
|
||||
tag.setRefreshOnShow("true");
|
||||
tag.setHandler("l");
|
||||
tag.setIndicator("m");
|
||||
tag.setShowLoadingText("true");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
|
||||
@@ -379,6 +379,93 @@ public class SelectTest extends AbstractUITagTest {
|
||||
verify(SelectTag.class.getResource("Select-6.txt"));
|
||||
}
|
||||
|
||||
public void testSimpleInteger() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
IdName hello = new IdName(new Integer(1), "hello");
|
||||
IdName world = new IdName(new Integer(2), "world");
|
||||
List list2 = new ArrayList();
|
||||
list2.add(hello);
|
||||
list2.add(world);
|
||||
testAction.setList2(list2);
|
||||
|
||||
testAction.setFooInt(new Integer(1));
|
||||
|
||||
SelectTag tag = new SelectTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setEmptyOption("true");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("fooInt");
|
||||
tag.setList("list2");
|
||||
tag.setListKey("id");
|
||||
tag.setListValue("name");
|
||||
|
||||
// header stuff
|
||||
tag.setHeaderKey("headerKey");
|
||||
tag.setHeaderValue("headerValue");
|
||||
|
||||
// empty option
|
||||
tag.setEmptyOption("true");
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("Select-11.txt"));
|
||||
}
|
||||
|
||||
public void testSimpleIntegerWithValueWorkaround() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
IdName hello = new IdName(new Integer(1), "hello");
|
||||
IdName world = new IdName(new Integer(2), "world");
|
||||
List list2 = new ArrayList();
|
||||
list2.add(hello);
|
||||
list2.add(world);
|
||||
testAction.setList2(list2);
|
||||
|
||||
testAction.setFooInt(new Integer(1));
|
||||
|
||||
SelectTag tag = new SelectTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setEmptyOption("true");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("fooInt");
|
||||
tag.setList("list2");
|
||||
tag.setListKey("id");
|
||||
tag.setListValue("name");
|
||||
tag.setValue("fooInt.toString()");
|
||||
|
||||
// header stuff
|
||||
tag.setHeaderKey("headerKey");
|
||||
tag.setHeaderValue("headerValue");
|
||||
|
||||
// empty option
|
||||
tag.setEmptyOption("true");
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("Select-11.txt"));
|
||||
}
|
||||
|
||||
public class IdName {
|
||||
private String name;
|
||||
private Integer id;
|
||||
|
||||
public IdName(Integer id, String name) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareTagGeneric(SelectTag tag) {
|
||||
TestAction testAction = (TestAction) action;
|
||||
ArrayList collection = new ArrayList();
|
||||
|
||||
@@ -60,10 +60,11 @@ public class SubmitAjaxTest extends AbstractUITagTest {
|
||||
tag.setLabel("i");
|
||||
tag.setNotifyTopics("k");
|
||||
tag.setIndicator("l");
|
||||
tag.setShowLoadingText("true");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(DivTest.class.getResource("submit-ajax-1.txt"));
|
||||
verify(SubmitAjaxTest.class.getResource("submit-ajax-1.txt"));
|
||||
}
|
||||
|
||||
public void testButton() throws Exception {
|
||||
@@ -89,7 +90,7 @@ public class SubmitAjaxTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(DivTest.class.getResource("submit-ajax-2.txt"));
|
||||
verify(SubmitAjaxTest.class.getResource("submit-ajax-2.txt"));
|
||||
}
|
||||
|
||||
public void testImage() throws Exception {
|
||||
@@ -116,6 +117,6 @@ public class SubmitAjaxTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(DivTest.class.getResource("submit-ajax-3.txt"));
|
||||
verify(SubmitAjaxTest.class.getResource("submit-ajax-3.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,26 @@ public class UrlHelperTest extends StrutsTestCase {
|
||||
assertEquals(expectedUrl, result);
|
||||
}
|
||||
|
||||
public void testForceAddNullSchemeHostAndPort() throws Exception {
|
||||
String expectedUrl = "http://localhost/contextPath/path1/path2/myAction.action";
|
||||
|
||||
Mock mockHttpServletRequest = new Mock(HttpServletRequest.class);
|
||||
mockHttpServletRequest.expectAndReturn("getScheme", "http");
|
||||
mockHttpServletRequest.expectAndReturn("getServerName", "localhost");
|
||||
mockHttpServletRequest.expectAndReturn("getContextPath",
|
||||
"/contextPath");
|
||||
|
||||
Mock mockHttpServletResponse = new Mock(HttpServletResponse.class);
|
||||
mockHttpServletResponse.expectAndReturn("encodeURL", expectedUrl,
|
||||
expectedUrl);
|
||||
|
||||
String result = UrlHelper.buildUrl("/path1/path2/myAction.action",
|
||||
(HttpServletRequest) mockHttpServletRequest.proxy(),
|
||||
(HttpServletResponse) mockHttpServletResponse.proxy(), null,
|
||||
null, true, true, true);
|
||||
assertEquals(expectedUrl, result);
|
||||
mockHttpServletRequest.verify();
|
||||
}
|
||||
|
||||
public void testBuildParametersStringWithUrlHavingSomeExistingParameters() throws Exception {
|
||||
String expectedUrl = "http://localhost:8080/myContext/myPage.jsp?initParam=initValue&param1=value1&param2=value2";
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
dropdownWidth="10"
|
||||
dropdownHeight="10"
|
||||
name="f"
|
||||
keyName="i"
|
||||
initialValue="g"
|
||||
indicator="h"
|
||||
loadOnType="true"
|
||||
loadMinimum="3"
|
||||
visibleDownArrow="false">
|
||||
visibleDownArrow="false"
|
||||
buttonSrc="i"
|
||||
templateCssPath="j">
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
dropdownWidth="10"
|
||||
dropdownHeight="10"
|
||||
name="f"
|
||||
keyName="fKey"
|
||||
buttonSrc="i"
|
||||
templateCssPath="j"
|
||||
>
|
||||
<option value="d">d</option>
|
||||
<option value="e">e</option>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
endDate="d"
|
||||
weekStartsOn="g"
|
||||
staticDisplay="false"
|
||||
templateCssPath="j"
|
||||
saveFormat="rfc">
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<tr>
|
||||
<td class="tdLabel"><label for="fooInt" class="label">mylabel:</label></td>
|
||||
<td><select name="fooInt" id="fooInt">
|
||||
<option value="headerKey">headerValue</option>
|
||||
<option value=""></option>
|
||||
<option value="1" selected="selected">hello</option>
|
||||
<option value="2">world</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
@@ -5,6 +5,7 @@
|
||||
autoStart="true"
|
||||
startTimerListenTopics="h"
|
||||
stopTimerListenTopics="i"
|
||||
refreshOnShow="true"
|
||||
id="mylabel"
|
||||
href="a"
|
||||
loadingText="b"
|
||||
@@ -14,5 +15,6 @@
|
||||
afterLoading="k"
|
||||
handler="l"
|
||||
indicator="m"
|
||||
showError="true">
|
||||
showError="true"
|
||||
showLoading="true">
|
||||
</div>
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
targets="h"
|
||||
handler="i"
|
||||
indicator="k"
|
||||
showError="true">
|
||||
showError="true"
|
||||
showLoading="true">
|
||||
</a>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
afterLoading="g"
|
||||
handler="h"
|
||||
indicator="l"
|
||||
showLoading="true"
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-codebehind-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Struts 2 Codebehind Plugin</name>
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/codebehind/</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/codebehind/</developerConnection>
|
||||
@@ -57,9 +57,9 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.0.6</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-config-browser-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Struts 2 Configuration Browser Plugin</name>
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/config-browser/</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/config-browser/</developerConnection>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-plugins</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-continuations-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Struts 2 Continuations Plugin</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/continuations/</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/continuations/</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/plugins/continuations/</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.rifers</groupId>
|
||||
<artifactId>rife-continuations</artifactId>
|
||||
<version>0.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* $Id: Dispatcher.java 484733 2006-12-08 20:16:16Z mrdon $
|
||||
*
|
||||
* 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.continuations;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionEventListener;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.uwyn.rife.continuations.ContinuableObject;
|
||||
import com.uwyn.rife.continuations.ContinuationConfig;
|
||||
import com.uwyn.rife.continuations.ContinuationContext;
|
||||
import com.uwyn.rife.continuations.ContinuationManager;
|
||||
import com.uwyn.rife.continuations.exceptions.PauseException;
|
||||
|
||||
/**
|
||||
* Hooks Rife continuations into key events in the Action instance lifecycle
|
||||
*/
|
||||
public class ContinuationsActionEventListener implements ActionEventListener {
|
||||
ContinuationManager cm;
|
||||
|
||||
public ContinuationsActionEventListener() {
|
||||
if (ContinuationConfig.getInstance() != null) {
|
||||
cm = new ContinuationManager();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the continuation context and loads the proper continuation action
|
||||
*/
|
||||
public Object prepare(Object action, ValueStack stack) {
|
||||
Map params = ActionContext.getContext().getParameters();
|
||||
String contId = (String) params.get(StrutsContinuationConfig.CONTINUE_PARAM);
|
||||
if (contId != null) {
|
||||
// remove the continue key from the params - we don't want to bother setting
|
||||
// on the value stack since we know it won't work. Besides, this breaks devMode!
|
||||
params.remove(StrutsContinuationConfig.CONTINUE_PARAM);
|
||||
}
|
||||
|
||||
|
||||
if (action instanceof ContinuableObject) {
|
||||
ContinuationContext ctx = ContinuationContext.createInstance((ContinuableObject) action);
|
||||
if (action instanceof NonCloningContinuableObject) {
|
||||
ctx.setShouldClone(false);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (contId != null) {
|
||||
ContinuationContext context = cm.getContext(contId);
|
||||
if (context != null) {
|
||||
ContinuationContext.setContext(context);
|
||||
// use the original action instead
|
||||
Object original = context.getContinuable();
|
||||
action = original;
|
||||
}
|
||||
}
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the normal continuation exception
|
||||
*/
|
||||
public String handleException(Throwable t, ValueStack stack) {
|
||||
if (t instanceof PauseException) {
|
||||
// continuations in effect!
|
||||
PauseException pe = ((PauseException) t);
|
||||
ContinuationContext context = pe.getContext();
|
||||
String result = (String) pe.getParameters();
|
||||
stack.getContext().put(StrutsContinuationConfig.CONTINUE_KEY, context.getId());
|
||||
cm.addContext(context);
|
||||
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user