mirror of
https://github.com/apache/struts.git
synced 2026-08-05 22:56:59 +00:00
Moved static instance out of ConfigurationManager into new XWorkStatic and started doing 1.5 updates with generics and enhanced for-loops.
git-svn-id: https://svn.apache.org/repos/asf/struts/action2/trunk@409001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+8
-9
@@ -17,29 +17,28 @@
|
||||
*/
|
||||
package org.apache.struts.action2.showcase.action;
|
||||
|
||||
import com.opensymphony.xwork.Preparable;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.struts.action2.showcase.application.TestDataProvider;
|
||||
import org.apache.struts.action2.showcase.dao.Dao;
|
||||
import org.apache.struts.action2.showcase.dao.EmployeeDao;
|
||||
import org.apache.struts.action2.showcase.model.Employee;
|
||||
import org.apache.struts.action2.showcase.model.Skill;
|
||||
import org.apache.struts.action2.showcase.application.TestDataProvider;
|
||||
import com.opensymphony.xwork.Preparable;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* EmployeeAction.
|
||||
*
|
||||
*/
|
||||
|
||||
public class EmployeeAction extends AbstractCRUDAction implements Preparable {
|
||||
|
||||
private static final long serialVersionUID = 7047317819789938957L;
|
||||
private static final long serialVersionUID = 7047317819789938957L;
|
||||
|
||||
private static final Logger log = Logger.getLogger(EmployeeAction.class);
|
||||
private static final Logger log = Logger.getLogger(EmployeeAction.class);
|
||||
|
||||
private Long empId;
|
||||
protected EmployeeDao employeeDao;
|
||||
@@ -102,7 +101,7 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills()!=null) {
|
||||
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
|
||||
setSelectedSkills(new ArrayList());
|
||||
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
|
||||
while (it.hasNext()) {
|
||||
|
||||
@@ -17,80 +17,73 @@
|
||||
*/
|
||||
package org.apache.struts.action2.components;
|
||||
|
||||
import org.apache.struts.action2.dispatcher.mapper.ActionMapperFactory;
|
||||
import org.apache.struts.action2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts.action2.dispatcher.DispatcherUtils;
|
||||
import org.apache.struts.action2.portlet.context.PortletActionContext;
|
||||
import org.apache.struts.action2.portlet.util.PortletUrlHelper;
|
||||
import org.apache.struts.action2.views.util.UrlHelper;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork.util.OgnlValueStack;
|
||||
import com.opensymphony.xwork.ActionContext;
|
||||
import com.opensymphony.xwork.ActionInvocation;
|
||||
import com.opensymphony.xwork.ObjectFactory;
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork.interceptor.MethodFilterInterceptorUtil;
|
||||
import com.opensymphony.xwork.util.OgnlValueStack;
|
||||
import com.opensymphony.xwork.validator.ActionValidatorManagerFactory;
|
||||
import com.opensymphony.xwork.validator.FieldValidator;
|
||||
import com.opensymphony.xwork.validator.ValidationInterceptor;
|
||||
import com.opensymphony.xwork.validator.Validator;
|
||||
import com.opensymphony.xwork.validator.FieldValidator;
|
||||
import com.opensymphony.xwork.validator.ActionValidatorManagerFactory;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.struts.action2.dispatcher.DispatcherUtils;
|
||||
import org.apache.struts.action2.dispatcher.mapper.ActionMapperFactory;
|
||||
import org.apache.struts.action2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts.action2.portlet.context.PortletActionContext;
|
||||
import org.apache.struts.action2.portlet.util.PortletUrlHelper;
|
||||
import org.apache.struts.action2.views.util.UrlHelper;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.opensymphony.xwork.interceptor.MethodFilterInterceptorUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
*
|
||||
* <p/>
|
||||
* Renders HTML an input form.<p/>
|
||||
*
|
||||
* <p/>
|
||||
* The remote form allows the form to be submitted without the page being refreshed. The results from the form
|
||||
* can be inserted into any HTML element on the page.<p/>
|
||||
*
|
||||
* <p/>
|
||||
* NOTE:<p/>
|
||||
* The order / logic in determining the posting url of the generated HTML form is as follows:-
|
||||
* <ol>
|
||||
* <li>
|
||||
* If the action attribute is not specified, then the current request will be used to
|
||||
* determine the posting url
|
||||
* </li>
|
||||
* <li>
|
||||
* If the action is given, SAF will try to obtain an ActionConfig. This will be
|
||||
* successfull if the action attribute is a valid action alias defined xwork.xml.
|
||||
* </li>
|
||||
* <li>
|
||||
* If the action is given and is not an action alias defined in xwork.xmlm SAF
|
||||
* will used the action attribute as if it is the posting url, separting the namespace
|
||||
* from it and using UrlHelper to generate the final url.
|
||||
* </li>
|
||||
* <li>
|
||||
* If the action attribute is not specified, then the current request will be used to
|
||||
* determine the posting url
|
||||
* </li>
|
||||
* <li>
|
||||
* If the action is given, SAF will try to obtain an ActionConfig. This will be
|
||||
* successfull if the action attribute is a valid action alias defined xwork.xml.
|
||||
* </li>
|
||||
* <li>
|
||||
* If the action is given and is not an action alias defined in xwork.xmlm SAF
|
||||
* will used the action attribute as if it is the posting url, separting the namespace
|
||||
* from it and using UrlHelper to generate the final url.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* <p/>
|
||||
* <!-- END SNIPPET: javadoc -->
|
||||
*
|
||||
* <p/>
|
||||
* <p/> <b>Examples</b>
|
||||
*
|
||||
* <p/>
|
||||
* <pre>
|
||||
* <!-- START SNIPPET: example -->
|
||||
*
|
||||
* <p/>
|
||||
* <a:form ... />
|
||||
*
|
||||
* <p/>
|
||||
* <!-- END SNIPPET: example -->
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @a2.tag name="form" tld-body-content="JSP" tld-tag-class="org.apache.struts.action2.views.jsp.ui.FormTag"
|
||||
* description="Renders an input form"
|
||||
*/
|
||||
*/
|
||||
public class Form extends ClosingUIBean {
|
||||
public static final String OPEN_TEMPLATE = "form";
|
||||
public static final String TEMPLATE = "form-close";
|
||||
@@ -135,7 +128,7 @@ public class Form extends ClosingUIBean {
|
||||
if (validate != null) {
|
||||
addParameter("validate", findValue(validate, Boolean.class));
|
||||
}
|
||||
|
||||
|
||||
// calculate the action and namespace
|
||||
String action = null;
|
||||
if (this.action != null) {
|
||||
@@ -197,15 +190,15 @@ public class Form extends ClosingUIBean {
|
||||
action = uri.substring(uri.lastIndexOf('/'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String actionMethod = "";
|
||||
if (action.indexOf("!") != -1) {
|
||||
int endIdx = action.lastIndexOf("!");
|
||||
actionMethod = action.substring(endIdx+1, action.length());
|
||||
action = action.substring(0, endIdx);
|
||||
int endIdx = action.lastIndexOf("!");
|
||||
actionMethod = action.substring(endIdx + 1, action.length());
|
||||
action = action.substring(0, endIdx);
|
||||
}
|
||||
|
||||
final ActionConfig actionConfig = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfig(namespace, action);
|
||||
final ActionConfig actionConfig = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfig(namespace, action);
|
||||
String actionName = action;
|
||||
if (actionConfig != null) {
|
||||
|
||||
@@ -235,10 +228,10 @@ public class Form extends ClosingUIBean {
|
||||
addParameter("id", action);
|
||||
}
|
||||
} else if (action != null) {
|
||||
// Since we can't find an action alias in the configuration, we just assume
|
||||
// the action attribute supplied is the path to be used as the uri this
|
||||
// form is submitting to.
|
||||
|
||||
// Since we can't find an action alias in the configuration, we just assume
|
||||
// the action attribute supplied is the path to be used as the uri this
|
||||
// form is submitting to.
|
||||
|
||||
String result = UrlHelper.buildUrl(action, request, response, null);
|
||||
addParameter("action", result);
|
||||
|
||||
@@ -262,46 +255,47 @@ public class Form extends ClosingUIBean {
|
||||
addParameter("id", escape(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// WW-1284
|
||||
// evaluate if client-side js is to be enabled. (if validation interceptor
|
||||
// does allow validation eg. method is not filtered out)
|
||||
evaluateClientSideJsEnablement(actionName, namespace, actionMethod);
|
||||
}
|
||||
|
||||
private void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod) {
|
||||
|
||||
// Only evaluate if Client-Side js is to be enable when validate=true
|
||||
Boolean validate = (Boolean) getParameters().get("validate");
|
||||
if (validate != null && validate.booleanValue()) {
|
||||
|
||||
addParameter("performValidation", Boolean.FALSE);
|
||||
|
||||
RuntimeConfiguration runtimeConfiguration = ConfigurationManager.getConfiguration().getRuntimeConfiguration();
|
||||
ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
|
||||
|
||||
if (actionConfig != null) {
|
||||
List interceptors = actionConfig.getInterceptors();
|
||||
for (Iterator i = interceptors.iterator(); i.hasNext(); ) {
|
||||
InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
|
||||
if (ValidationInterceptor.class.isInstance(interceptorMapping.getInterceptor())) {
|
||||
ValidationInterceptor validationInterceptor = (ValidationInterceptor) interceptorMapping.getInterceptor();
|
||||
|
||||
Set excludeMethods = validationInterceptor.getExcludeMethodsSet();
|
||||
Set includeMethods = validationInterceptor.getIncludeMethodsSet();
|
||||
|
||||
if (MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, actionMethod)) {
|
||||
addParameter("performValidation", Boolean.TRUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod) {
|
||||
|
||||
// Only evaluate if Client-Side js is to be enable when validate=true
|
||||
Boolean validate = (Boolean) getParameters().get("validate");
|
||||
if (validate != null && validate.booleanValue()) {
|
||||
|
||||
addParameter("performValidation", Boolean.FALSE);
|
||||
|
||||
RuntimeConfiguration runtimeConfiguration = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration();
|
||||
ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
|
||||
|
||||
if (actionConfig != null) {
|
||||
List interceptors = actionConfig.getInterceptors();
|
||||
for (Iterator i = interceptors.iterator(); i.hasNext();) {
|
||||
InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
|
||||
if (ValidationInterceptor.class.isInstance(interceptorMapping.getInterceptor())) {
|
||||
ValidationInterceptor validationInterceptor = (ValidationInterceptor) interceptorMapping.getInterceptor();
|
||||
|
||||
Set excludeMethods = validationInterceptor.getExcludeMethodsSet();
|
||||
Set includeMethods = validationInterceptor.getIncludeMethodsSet();
|
||||
|
||||
if (MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, actionMethod)) {
|
||||
addParameter("performValidation", Boolean.TRUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the action url adapted to a portal environment.
|
||||
*
|
||||
* @param action The action to create the URL for.
|
||||
*/
|
||||
private void evaluateExtraParamsPortletRequest(String namespace, String action) {
|
||||
@@ -359,7 +353,7 @@ public class Form extends ClosingUIBean {
|
||||
if (validator instanceof FieldValidator) {
|
||||
FieldValidator fieldValidator = (FieldValidator) validator;
|
||||
if (fieldValidator.getFieldName().equals(name)) {
|
||||
validators.add(fieldValidator);
|
||||
validators.add(fieldValidator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,6 +364,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* HTML onsubmit attribute
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setOnsubmit(String onsubmit) {
|
||||
@@ -378,6 +373,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* Set action nane to submit to, without .action suffix
|
||||
*
|
||||
* @a2.tagattribute required="false" default="current action"
|
||||
*/
|
||||
public void setAction(String action) {
|
||||
@@ -386,6 +382,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* HTML form target attribute
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setTarget(String target) {
|
||||
@@ -394,6 +391,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* HTML form enctype attribute
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setEnctype(String enctype) {
|
||||
@@ -402,6 +400,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* HTML form method attribute
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setMethod(String method) {
|
||||
@@ -410,6 +409,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* namespace for action to submit to
|
||||
*
|
||||
* @a2.tagattribute required="false" default="current namespace"
|
||||
*/
|
||||
public void setNamespace(String namespace) {
|
||||
@@ -418,6 +418,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* Whether client side/remote validation should be performed. Only useful with theme xhtml/ajax
|
||||
*
|
||||
* @a2.tagattribute required="false" type="Boolean" default="false"
|
||||
*/
|
||||
public void setValidate(String validate) {
|
||||
@@ -426,6 +427,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* The portlet mode to display after the form submit
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setPortletMode(String portletMode) {
|
||||
@@ -434,6 +436,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* The window state to display after the form submit
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setWindowState(String windowState) {
|
||||
@@ -442,6 +445,7 @@ public class Form extends ClosingUIBean {
|
||||
|
||||
/**
|
||||
* The accepted charsets for this form. The values may be comma or blank delimited.
|
||||
*
|
||||
* @a2.tagattribute required="false"
|
||||
*/
|
||||
public void setAcceptcharset(String acceptcharset) {
|
||||
|
||||
+4
-5
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
package org.apache.struts.action2.config_browser;
|
||||
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -26,13 +26,12 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* ConfigurationHelper
|
||||
*
|
||||
*/
|
||||
public class ConfigurationHelper {
|
||||
|
||||
public static Set getNamespaces() {
|
||||
Set namespaces = Collections.EMPTY_SET;
|
||||
Map allActionConfigs = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
Map allActionConfigs = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
if (allActionConfigs != null) {
|
||||
namespaces = allActionConfigs.keySet();
|
||||
}
|
||||
@@ -41,7 +40,7 @@ public class ConfigurationHelper {
|
||||
|
||||
public static Set getActionNames(String namespace) {
|
||||
Set actionNames = Collections.EMPTY_SET;
|
||||
Map allActionConfigs = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
Map allActionConfigs = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
if (allActionConfigs != null) {
|
||||
Map actionMappings = (Map) allActionConfigs.get(namespace);
|
||||
if (actionMappings != null) {
|
||||
@@ -53,7 +52,7 @@ public class ConfigurationHelper {
|
||||
|
||||
public static ActionConfig getActionConfig(String namespace, String actionName) {
|
||||
ActionConfig config = null;
|
||||
Map allActionConfigs = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
Map allActionConfigs = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
if (allActionConfigs != null) {
|
||||
Map actionMappings = (Map) allActionConfigs.get(namespace);
|
||||
if (actionMappings != null) {
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
*/
|
||||
package org.apache.struts.action2.sitegraph;
|
||||
|
||||
import org.apache.struts.action2.sitegraph.collectors.ArbitraryXMLConfigurationProvider;
|
||||
import org.apache.struts.action2.sitegraph.entities.FreeMarkerView;
|
||||
import org.apache.struts.action2.sitegraph.entities.JspView;
|
||||
import org.apache.struts.action2.sitegraph.entities.VelocityView;
|
||||
import org.apache.struts.action2.sitegraph.entities.View;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork.config.entities.ResultConfig;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts.action2.sitegraph.collectors.ArbitraryXMLConfigurationProvider;
|
||||
import org.apache.struts.action2.sitegraph.entities.FreeMarkerView;
|
||||
import org.apache.struts.action2.sitegraph.entities.JspView;
|
||||
import org.apache.struts.action2.sitegraph.entities.VelocityView;
|
||||
import org.apache.struts.action2.sitegraph.entities.View;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Initializes and retrieves XWork config elements
|
||||
@@ -38,7 +41,7 @@ public class XWorkConfigRetriever {
|
||||
public static Map getActionConfigs() {
|
||||
if (!isXWorkStarted)
|
||||
initXWork();
|
||||
return ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
return XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
|
||||
}
|
||||
|
||||
private static void initXWork() {
|
||||
@@ -46,7 +49,7 @@ public class XWorkConfigRetriever {
|
||||
File configFile = new File(configFilePath);
|
||||
try {
|
||||
ConfigurationProvider configProvider = new ArbitraryXMLConfigurationProvider(configFile.getCanonicalPath());
|
||||
ConfigurationManager.addConfigurationProvider(configProvider);
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(configProvider);
|
||||
isXWorkStarted = true;
|
||||
} catch (IOException e) {
|
||||
LOG.error("IOException", e);
|
||||
|
||||
+3
-4
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
package org.apache.struts.action2.spring.lifecycle;
|
||||
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.Configuration;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.config.ExternalReferenceResolver;
|
||||
import com.opensymphony.xwork.config.entities.PackageConfig;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -36,7 +36,6 @@ import java.util.Map;
|
||||
* framework. Relies on Spring's
|
||||
* {@link org.springframework.web.context.ContextLoaderListener}having been
|
||||
* called first.
|
||||
*
|
||||
*/
|
||||
public class SpringExternalReferenceResolverSetupListener implements
|
||||
ServletContextListener {
|
||||
@@ -44,7 +43,7 @@ public class SpringExternalReferenceResolverSetupListener implements
|
||||
ApplicationContext appContext = WebApplicationContextUtils
|
||||
.getWebApplicationContext(event.getServletContext());
|
||||
|
||||
Configuration xworkConfig = ConfigurationManager.getConfiguration();
|
||||
Configuration xworkConfig = XWorkStatic.getConfigurationManager().getConfiguration();
|
||||
Map packageConfigs = xworkConfig.getPackageConfigs();
|
||||
Iterator i = packageConfigs.values().iterator();
|
||||
|
||||
@@ -52,7 +51,7 @@ public class SpringExternalReferenceResolverSetupListener implements
|
||||
PackageConfig packageConfig = (PackageConfig) i.next();
|
||||
ExternalReferenceResolver resolver = packageConfig.getExternalRefResolver();
|
||||
if (resolver == null || !(resolver instanceof ApplicationContextAware))
|
||||
continue;
|
||||
continue;
|
||||
ApplicationContextAware contextAware = (ApplicationContextAware) resolver;
|
||||
contextAware.setApplicationContext(appContext);
|
||||
}
|
||||
|
||||
+3
-4
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
package org.apache.struts.action2.util;
|
||||
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.Configuration;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.config.entities.PackageConfig;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
@@ -33,7 +33,6 @@ import java.util.Iterator;
|
||||
* Spring framework uses a ContextServletListener to initialise it's IoC container, storing it's
|
||||
* container context (ApplicationContext in Spring terms) in the Servlet context, the External
|
||||
* Reference Resolver can get a reference to the container context from the servlet context.
|
||||
*
|
||||
*/
|
||||
public class ResolverSetupServletContextListener implements ServletContextListener {
|
||||
|
||||
@@ -41,7 +40,7 @@ public class ResolverSetupServletContextListener implements ServletContextListen
|
||||
}
|
||||
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
Configuration config = ConfigurationManager.getConfiguration();
|
||||
Configuration config = XWorkStatic.getConfigurationManager().getConfiguration();
|
||||
String key;
|
||||
PackageConfig packageConfig;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class ResolverSetupServletContextListener implements ServletContextListen
|
||||
key = (String) iter.next();
|
||||
packageConfig = config.getPackageConfig(key);
|
||||
|
||||
if (packageConfig.getExternalRefResolver() instanceof ServletContextAware) {
|
||||
if (packageConfig.getExternalRefResolver()instanceof ServletContextAware) {
|
||||
((ServletContextAware) packageConfig.getExternalRefResolver()).setServletContext(event.getServletContext());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -23,11 +23,11 @@ import com.mockobjects.servlet.MockHttpServletResponse;
|
||||
import com.mockobjects.servlet.MockHttpSession;
|
||||
import com.mockobjects.servlet.MockServletConfig;
|
||||
import com.mockobjects.servlet.MockServletOutputStream;
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
|
||||
import org.apache.struts.action2.StrutsTestCase;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletResponse;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletContext;
|
||||
@@ -66,14 +66,14 @@ public abstract class AbstractServletDispatcherTestCase extends StrutsTestCase {
|
||||
|
||||
protected void loadConfig() {
|
||||
XmlConfigurationProvider c = new XmlConfigurationProvider(getConfigFilename());
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.destroyConfiguration();
|
||||
ConfigurationManager.addConfigurationProvider(c);
|
||||
ConfigurationManager.getConfiguration();
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().destroyConfiguration();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(c);
|
||||
XWorkStatic.getConfigurationManager().getConfiguration();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ConfigurationManager.destroyConfiguration();
|
||||
XWorkStatic.getConfigurationManager().destroyConfiguration();
|
||||
}
|
||||
|
||||
private void service(HttpServlet servlet) throws ServletException, IOException {
|
||||
|
||||
+15
-17
@@ -17,21 +17,20 @@
|
||||
*/
|
||||
package org.apache.struts.action2.interceptor;
|
||||
|
||||
import com.opensymphony.xwork.*;
|
||||
import com.opensymphony.xwork.config.Configuration;
|
||||
import com.opensymphony.xwork.config.ConfigurationException;
|
||||
import com.opensymphony.xwork.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork.interceptor.ParametersInterceptor;
|
||||
import com.opensymphony.xwork.mock.MockResult;
|
||||
import org.apache.struts.action2.ServletActionContext;
|
||||
import org.apache.struts.action2.StrutsTestCase;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockHttpSession;
|
||||
import com.opensymphony.xwork.*;
|
||||
import com.opensymphony.xwork.mock.MockResult;
|
||||
import com.opensymphony.xwork.config.Configuration;
|
||||
import com.opensymphony.xwork.config.ConfigurationException;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork.interceptor.ParametersInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,7 +40,6 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Test case for ExecuteAndWaitInterceptor.
|
||||
*
|
||||
*/
|
||||
public class ExecuteAndWaitInterceptorTest extends StrutsTestCase {
|
||||
|
||||
@@ -162,9 +160,9 @@ public class ExecuteAndWaitInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new WaitConfigurationProvider());
|
||||
ConfigurationManager.getConfiguration().reload();
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new WaitConfigurationProvider());
|
||||
XWorkStatic.getConfigurationManager().getConfiguration().reload();
|
||||
|
||||
session = new HashMap();
|
||||
params = new HashMap();
|
||||
@@ -180,8 +178,8 @@ public class ExecuteAndWaitInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.destroyConfiguration();
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().destroyConfiguration();
|
||||
ActionContext.setContext(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,19 +17,14 @@
|
||||
*/
|
||||
package org.apache.struts.action2.interceptor;
|
||||
|
||||
import com.opensymphony.xwork.*;
|
||||
import com.opensymphony.xwork.util.OgnlValueStack;
|
||||
import org.apache.struts.action2.ServletActionContext;
|
||||
import org.apache.struts.action2.TestConfigurationProvider;
|
||||
import org.apache.struts.action2.StrutsTestCase;
|
||||
import org.apache.struts.action2.TestConfigurationProvider;
|
||||
import org.apache.struts.action2.util.TokenHelper;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockHttpSession;
|
||||
import com.opensymphony.xwork.Action;
|
||||
import com.opensymphony.xwork.ActionContext;
|
||||
import com.opensymphony.xwork.ActionProxy;
|
||||
import com.opensymphony.xwork.ActionProxyFactory;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.util.OgnlValueStack;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
@@ -39,7 +34,6 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* TokenInterceptorTest
|
||||
*
|
||||
*/
|
||||
public class TokenInterceptorTest extends StrutsTestCase {
|
||||
|
||||
@@ -103,9 +97,9 @@ public class TokenInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
ConfigurationManager.getConfiguration().reload();
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
XWorkStatic.getConfigurationManager().getConfiguration().reload();
|
||||
|
||||
session = new HashMap();
|
||||
params = new HashMap();
|
||||
@@ -130,7 +124,7 @@ public class TokenInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ConfigurationManager.destroyConfiguration();
|
||||
XWorkStatic.getConfigurationManager().destroyConfiguration();
|
||||
ActionContext.setContext(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,13 @@
|
||||
*/
|
||||
package org.apache.struts.action2.views.jsp;
|
||||
|
||||
import com.opensymphony.xwork.*;
|
||||
import com.opensymphony.xwork.util.OgnlValueStack;
|
||||
import org.apache.struts.action2.ServletActionContext;
|
||||
import org.apache.struts.action2.TestAction;
|
||||
import org.apache.struts.action2.TestActionTagResult;
|
||||
import org.apache.struts.action2.TestConfigurationProvider;
|
||||
import org.apache.struts.action2.components.ActionComponent;
|
||||
import com.opensymphony.xwork.Action;
|
||||
import com.opensymphony.xwork.ActionContext;
|
||||
import com.opensymphony.xwork.ActionProxy;
|
||||
import com.opensymphony.xwork.ActionInvocation;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.util.OgnlValueStack;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
@@ -35,7 +31,6 @@ import javax.servlet.jsp.PageContext;
|
||||
|
||||
/**
|
||||
* Unit test for {@link ActionTag}.
|
||||
*
|
||||
*/
|
||||
public class ActionTagTest extends AbstractTagTest {
|
||||
|
||||
@@ -115,7 +110,7 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
|
||||
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
|
||||
assertTrue(result.isExecuted());
|
||||
}
|
||||
|
||||
@@ -136,7 +131,7 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
|
||||
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
|
||||
assertNull(result); // result is never executed, hence never set into invocation
|
||||
}
|
||||
|
||||
@@ -229,16 +224,16 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
|
||||
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
|
||||
assertTrue(result.isExecuted());
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
ConfigurationManager.getConfiguration().reload();
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
XWorkStatic.getConfigurationManager().getConfiguration().reload();
|
||||
|
||||
ActionContext actionContext = new ActionContext(context);
|
||||
actionContext.setValueStack(stack);
|
||||
@@ -246,7 +241,7 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ConfigurationManager.destroyConfiguration();
|
||||
XWorkStatic.getConfigurationManager().destroyConfiguration();
|
||||
|
||||
OgnlValueStack stack = new OgnlValueStack();
|
||||
ActionContext.setContext(new ActionContext(stack.getContext()));
|
||||
|
||||
@@ -17,79 +17,75 @@
|
||||
*/
|
||||
package org.apache.struts.action2.views.jsp.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts.action2.TestAction;
|
||||
import org.apache.struts.action2.TestConfigurationProvider;
|
||||
import org.apache.struts.action2.StrutsConstants;
|
||||
import org.apache.struts.action2.config.Configuration;
|
||||
import org.apache.struts.action2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts.action2.dispatcher.mapper.ActionMapperFactory;
|
||||
import org.apache.struts.action2.dispatcher.mapper.DefaultActionMapper;
|
||||
import org.apache.struts.action2.views.jsp.AbstractUITagTest;
|
||||
import org.apache.struts.action2.views.jsp.ActionTag;
|
||||
|
||||
import com.opensymphony.xwork.ActionContext;
|
||||
import com.opensymphony.xwork.ActionSupport;
|
||||
import com.opensymphony.xwork.ObjectFactory;
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import com.opensymphony.xwork.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork.validator.ValidationInterceptor;
|
||||
import org.apache.struts.action2.StrutsConstants;
|
||||
import org.apache.struts.action2.TestAction;
|
||||
import org.apache.struts.action2.TestConfigurationProvider;
|
||||
import org.apache.struts.action2.config.Configuration;
|
||||
import org.apache.struts.action2.dispatcher.mapper.DefaultActionMapper;
|
||||
import org.apache.struts.action2.views.jsp.AbstractUITagTest;
|
||||
import org.apache.struts.action2.views.jsp.ActionTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* FormTagTest
|
||||
*
|
||||
*/
|
||||
public class FormTagTest extends AbstractUITagTest {
|
||||
|
||||
public void testFormWithActionAttributeContainingBothActionAndMethod() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
public void testFormWithActionAttributeContainingBothActionAndMethod() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
tag.setAction("testAction!myLittleMethod");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-9.txt"));
|
||||
}
|
||||
|
||||
|
||||
public void testFormWithActionAttributeContainingBothActionAndMethodAndNamespace() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setNamespace("/testNamespace");
|
||||
tag.setMethod("POST");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
}
|
||||
|
||||
|
||||
public void testFormWithActionAttributeContainingBothActionAndMethodAndNamespace() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setNamespace("/testNamespace");
|
||||
tag.setMethod("POST");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
tag.setAction("testNamespaceAction!myLittleMethod");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-10.txt"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testForm() throws Exception {
|
||||
|
||||
|
||||
request.setupGetServletPath("/testAction");
|
||||
|
||||
TestAction testAction = (TestAction) action;
|
||||
@@ -110,201 +106,199 @@ public class FormTagTest extends AbstractUITagTest {
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-1.txt"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This test with form tag validation enabled. Js validation script will appear
|
||||
* cause action submited by the form is intercepted by validation interceptor which
|
||||
* "include" all methods.
|
||||
*/
|
||||
public void testFormWithCustomOnsubmitEnabledWithValidateEnabled1() throws Exception {
|
||||
|
||||
com.opensymphony.xwork.config.Configuration originalConfiguration = ConfigurationManager.getConfiguration();
|
||||
ObjectFactory originalObjectFactory = ObjectFactory.getObjectFactory();
|
||||
|
||||
try {
|
||||
// used to determined if the form action needs js validation
|
||||
ConfigurationManager.setConfiguration(new com.opensymphony.xwork.config.impl.DefaultConfiguration() {
|
||||
public RuntimeConfiguration getRuntimeConfiguration() {
|
||||
return new RuntimeConfiguration() {
|
||||
public ActionConfig getActionConfig(String namespace, String name) {
|
||||
ActionConfig actionConfig = new ActionConfig() {
|
||||
public List getInterceptors() {
|
||||
List interceptors = new ArrayList();
|
||||
|
||||
ValidationInterceptor validationInterceptor = new ValidationInterceptor();
|
||||
validationInterceptor.setIncludeMethods("*");
|
||||
|
||||
InterceptorMapping interceptorMapping = new InterceptorMapping();
|
||||
interceptorMapping.setName("validation");
|
||||
interceptorMapping.setInterceptor(validationInterceptor);
|
||||
interceptors.add(interceptorMapping);
|
||||
|
||||
return interceptors;
|
||||
}
|
||||
};
|
||||
return actionConfig;
|
||||
}
|
||||
public Map getActionConfigs() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// used by form tag to get "actionClass" parameter
|
||||
ObjectFactory.setObjectFactory(new ObjectFactory() {
|
||||
public Class getClassInstance(String className) throws ClassNotFoundException {
|
||||
if (DefaultActionMapper.class.getName().equals(className)) {
|
||||
return DefaultActionMapper.class;
|
||||
}
|
||||
return ActionSupport.class;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAction("myAction");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
tag.setValidate("true");
|
||||
tag.setNamespace("");
|
||||
|
||||
UpDownSelectTag t = new UpDownSelectTag();
|
||||
t.setPageContext(pageContext);
|
||||
t.setName("myUpDownSelectTag");
|
||||
t.setList("{}");
|
||||
|
||||
tag.doStartTag();
|
||||
t.doStartTag();
|
||||
t.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-2.txt"));
|
||||
}
|
||||
finally {
|
||||
ConfigurationManager.setConfiguration(originalConfiguration);
|
||||
ObjectFactory.setObjectFactory(originalObjectFactory);
|
||||
}
|
||||
|
||||
com.opensymphony.xwork.config.Configuration originalConfiguration = XWorkStatic.getConfigurationManager().getConfiguration();
|
||||
ObjectFactory originalObjectFactory = ObjectFactory.getObjectFactory();
|
||||
|
||||
try {
|
||||
// used to determined if the form action needs js validation
|
||||
XWorkStatic.getConfigurationManager().setConfiguration(new com.opensymphony.xwork.config.impl.DefaultConfiguration() {
|
||||
public RuntimeConfiguration getRuntimeConfiguration() {
|
||||
return new RuntimeConfiguration() {
|
||||
public ActionConfig getActionConfig(String namespace, String name) {
|
||||
ActionConfig actionConfig = new ActionConfig() {
|
||||
public List getInterceptors() {
|
||||
List interceptors = new ArrayList();
|
||||
|
||||
ValidationInterceptor validationInterceptor = new ValidationInterceptor();
|
||||
validationInterceptor.setIncludeMethods("*");
|
||||
|
||||
InterceptorMapping interceptorMapping = new InterceptorMapping();
|
||||
interceptorMapping.setName("validation");
|
||||
interceptorMapping.setInterceptor(validationInterceptor);
|
||||
interceptors.add(interceptorMapping);
|
||||
|
||||
return interceptors;
|
||||
}
|
||||
};
|
||||
return actionConfig;
|
||||
}
|
||||
|
||||
public Map getActionConfigs() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// used by form tag to get "actionClass" parameter
|
||||
ObjectFactory.setObjectFactory(new ObjectFactory() {
|
||||
public Class getClassInstance(String className) throws ClassNotFoundException {
|
||||
if (DefaultActionMapper.class.getName().equals(className)) {
|
||||
return DefaultActionMapper.class;
|
||||
}
|
||||
return ActionSupport.class;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAction("myAction");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
tag.setValidate("true");
|
||||
tag.setNamespace("");
|
||||
|
||||
UpDownSelectTag t = new UpDownSelectTag();
|
||||
t.setPageContext(pageContext);
|
||||
t.setName("myUpDownSelectTag");
|
||||
t.setList("{}");
|
||||
|
||||
tag.doStartTag();
|
||||
t.doStartTag();
|
||||
t.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-2.txt"));
|
||||
}
|
||||
finally {
|
||||
XWorkStatic.getConfigurationManager().setConfiguration(originalConfiguration);
|
||||
ObjectFactory.setObjectFactory(originalObjectFactory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This test with form tag validation enabled. Js validation script will not appear
|
||||
* cause action submited by the form is intercepted by validation interceptor which
|
||||
* "excludes" all methods.
|
||||
*/
|
||||
public void testFormWithCustomOnsubmitEnabledWithValidateEnabled2() throws Exception {
|
||||
|
||||
com.opensymphony.xwork.config.Configuration originalConfiguration = ConfigurationManager.getConfiguration();
|
||||
ObjectFactory originalObjectFactory = ObjectFactory.getObjectFactory();
|
||||
|
||||
try {
|
||||
// used to determined if the form action needs js validation
|
||||
ConfigurationManager.setConfiguration(new com.opensymphony.xwork.config.impl.DefaultConfiguration() {
|
||||
public RuntimeConfiguration getRuntimeConfiguration() {
|
||||
return new RuntimeConfiguration() {
|
||||
public ActionConfig getActionConfig(String namespace, String name) {
|
||||
ActionConfig actionConfig = new ActionConfig() {
|
||||
public List getInterceptors() {
|
||||
List interceptors = new ArrayList();
|
||||
|
||||
ValidationInterceptor validationInterceptor = new ValidationInterceptor();
|
||||
validationInterceptor.setExcludeMethods("*");
|
||||
|
||||
InterceptorMapping interceptorMapping = new InterceptorMapping();
|
||||
interceptorMapping.setName("validation");
|
||||
interceptorMapping.setInterceptor(validationInterceptor);
|
||||
interceptors.add(interceptorMapping);
|
||||
|
||||
return interceptors;
|
||||
}
|
||||
};
|
||||
return actionConfig;
|
||||
}
|
||||
public Map getActionConfigs() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// used by form tag to get "actionClass" parameter
|
||||
ObjectFactory.setObjectFactory(new ObjectFactory() {
|
||||
public Class getClassInstance(String className) throws ClassNotFoundException {
|
||||
if (DefaultActionMapper.class.getName().equals(className)) {
|
||||
return DefaultActionMapper.class;
|
||||
}
|
||||
return ActionSupport.class;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAction("myAction");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
tag.setValidate("true");
|
||||
tag.setNamespace("");
|
||||
|
||||
UpDownSelectTag t = new UpDownSelectTag();
|
||||
t.setPageContext(pageContext);
|
||||
t.setName("myUpDownSelectTag");
|
||||
t.setList("{}");
|
||||
|
||||
tag.doStartTag();
|
||||
t.doStartTag();
|
||||
t.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-11.txt"));
|
||||
}
|
||||
finally {
|
||||
ConfigurationManager.setConfiguration(originalConfiguration);
|
||||
ObjectFactory.setObjectFactory(originalObjectFactory);
|
||||
}
|
||||
|
||||
com.opensymphony.xwork.config.Configuration originalConfiguration = XWorkStatic.getConfigurationManager().getConfiguration();
|
||||
ObjectFactory originalObjectFactory = ObjectFactory.getObjectFactory();
|
||||
|
||||
try {
|
||||
// used to determined if the form action needs js validation
|
||||
XWorkStatic.getConfigurationManager().setConfiguration(new com.opensymphony.xwork.config.impl.DefaultConfiguration() {
|
||||
public RuntimeConfiguration getRuntimeConfiguration() {
|
||||
return new RuntimeConfiguration() {
|
||||
public ActionConfig getActionConfig(String namespace, String name) {
|
||||
ActionConfig actionConfig = new ActionConfig() {
|
||||
public List getInterceptors() {
|
||||
List interceptors = new ArrayList();
|
||||
|
||||
ValidationInterceptor validationInterceptor = new ValidationInterceptor();
|
||||
validationInterceptor.setExcludeMethods("*");
|
||||
|
||||
InterceptorMapping interceptorMapping = new InterceptorMapping();
|
||||
interceptorMapping.setName("validation");
|
||||
interceptorMapping.setInterceptor(validationInterceptor);
|
||||
interceptors.add(interceptorMapping);
|
||||
|
||||
return interceptors;
|
||||
}
|
||||
};
|
||||
return actionConfig;
|
||||
}
|
||||
|
||||
public Map getActionConfigs() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// used by form tag to get "actionClass" parameter
|
||||
ObjectFactory.setObjectFactory(new ObjectFactory() {
|
||||
public Class getClassInstance(String className) throws ClassNotFoundException {
|
||||
if (DefaultActionMapper.class.getName().equals(className)) {
|
||||
return DefaultActionMapper.class;
|
||||
}
|
||||
return ActionSupport.class;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAction("myAction");
|
||||
tag.setAcceptcharset("UTF-8");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
tag.setValidate("true");
|
||||
tag.setNamespace("");
|
||||
|
||||
UpDownSelectTag t = new UpDownSelectTag();
|
||||
t.setPageContext(pageContext);
|
||||
t.setName("myUpDownSelectTag");
|
||||
t.setList("{}");
|
||||
|
||||
tag.doStartTag();
|
||||
t.doStartTag();
|
||||
t.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-11.txt"));
|
||||
}
|
||||
finally {
|
||||
XWorkStatic.getConfigurationManager().setConfiguration(originalConfiguration);
|
||||
ObjectFactory.setObjectFactory(originalObjectFactory);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test with form tag validation disabled.
|
||||
*/
|
||||
public void testFormWithCustomOnsubmitEnabledWithValidateDisabled() throws Exception {
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myForm");
|
||||
tag.setMethod("POST");
|
||||
tag.setAction("myAction");
|
||||
tag.setEnctype("myEncType");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setOnsubmit("submitMe()");
|
||||
tag.setValidate("false");
|
||||
|
||||
|
||||
UpDownSelectTag t = new UpDownSelectTag();
|
||||
t.setPageContext(pageContext);
|
||||
t.setName("myUpDownSelectTag");
|
||||
t.setList("{}");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
t.doStartTag();
|
||||
t.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-6.txt"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Testing that this: <p>
|
||||
@@ -374,129 +368,129 @@ public class FormTagTest extends AbstractUITagTest {
|
||||
|
||||
verify(FormTag.class.getResource("Formtag-3.txt"));
|
||||
}
|
||||
|
||||
|
||||
public void testFormTagForStackOverflowException1() throws Exception {
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
FormTag form1 = new FormTag();
|
||||
form1.setPageContext(pageContext);
|
||||
form1.doStartTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.doStartTag();
|
||||
|
||||
assertEquals(tag.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form1.doEndTag();
|
||||
|
||||
assertNull(form1.getComponent()); // component is removed after end tag
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
FormTag form1 = new FormTag();
|
||||
form1.setPageContext(pageContext);
|
||||
form1.doStartTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.doStartTag();
|
||||
|
||||
assertEquals(tag.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form1.doEndTag();
|
||||
|
||||
assertNull(form1.getComponent()); // component is removed after end tag
|
||||
}
|
||||
|
||||
|
||||
public void testFormTagForStackOverflowException2() throws Exception {
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
FormTag form1 = new FormTag();
|
||||
form1.setPageContext(pageContext);
|
||||
form1.doStartTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
FormTag form2 = new FormTag();
|
||||
form2.setPageContext(pageContext);
|
||||
form2.doStartTag();
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.doStartTag();
|
||||
|
||||
assertEquals(tag.getComponent().getComponentStack().size(), 3);
|
||||
|
||||
tag.doEndTag();
|
||||
FormTag form1 = new FormTag();
|
||||
form1.setPageContext(pageContext);
|
||||
form1.doStartTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
form2.doEndTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form1.doEndTag();
|
||||
|
||||
assertNull(form1.getComponent()); // component is removed after end tag
|
||||
FormTag form2 = new FormTag();
|
||||
form2.setPageContext(pageContext);
|
||||
form2.doStartTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.doStartTag();
|
||||
|
||||
assertEquals(tag.getComponent().getComponentStack().size(), 3);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
form2.doEndTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form1.doEndTag();
|
||||
|
||||
assertNull(form1.getComponent()); // component is removed after end tag
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void testFormTagForStackOverflowException3() throws Exception {
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
FormTag form1 = new FormTag();
|
||||
form1.setPageContext(pageContext);
|
||||
form1.doStartTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
FormTag form2 = new FormTag();
|
||||
form2.setPageContext(pageContext);
|
||||
form2.doStartTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
FormTag form3 = new FormTag();
|
||||
form3.setPageContext(pageContext);
|
||||
form3.doStartTag();
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
assertEquals(form3.getComponent().getComponentStack().size(), 3);
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.doStartTag();
|
||||
|
||||
assertEquals(tag.getComponent().getComponentStack().size(), 4);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(form3.getComponent().getComponentStack().size(), 3);
|
||||
FormTag form1 = new FormTag();
|
||||
form1.setPageContext(pageContext);
|
||||
form1.doStartTag();
|
||||
|
||||
form3.doEndTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
form2.doEndTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form1.doEndTag();
|
||||
|
||||
assertNull(form1.getComponent()); // component is removed after end tag
|
||||
FormTag form2 = new FormTag();
|
||||
form2.setPageContext(pageContext);
|
||||
form2.doStartTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
FormTag form3 = new FormTag();
|
||||
form3.setPageContext(pageContext);
|
||||
form3.doStartTag();
|
||||
|
||||
assertEquals(form3.getComponent().getComponentStack().size(), 3);
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.doStartTag();
|
||||
|
||||
assertEquals(tag.getComponent().getComponentStack().size(), 4);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(form3.getComponent().getComponentStack().size(), 3);
|
||||
|
||||
form3.doEndTag();
|
||||
|
||||
assertEquals(form2.getComponent().getComponentStack().size(), 2);
|
||||
|
||||
form2.doEndTag();
|
||||
|
||||
assertEquals(form1.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form1.doEndTag();
|
||||
|
||||
assertNull(form1.getComponent()); // component is removed after end tag
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void testFormComponentIsRemoved() throws Exception {
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
FormTag form = new FormTag();
|
||||
form.setPageContext(pageContext);
|
||||
form.doStartTag();
|
||||
|
||||
assertEquals(form.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form.doEndTag();
|
||||
|
||||
assertNull(form.getComponent());
|
||||
request.setRequestURI("/requestUri");
|
||||
|
||||
FormTag form = new FormTag();
|
||||
form.setPageContext(pageContext);
|
||||
form.doStartTag();
|
||||
|
||||
assertEquals(form.getComponent().getComponentStack().size(), 1);
|
||||
|
||||
form.doEndTag();
|
||||
|
||||
assertNull(form.getComponent());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void testFormWithNoAction() throws Exception {
|
||||
request.setupGetServletPath("/");
|
||||
request.setupGetContextPath("/");
|
||||
@@ -548,8 +542,8 @@ public class FormTagTest extends AbstractUITagTest {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
ActionContext.getContext().setValueStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,360 +18,357 @@
|
||||
package org.apache.struts.action2.views.jsp.ui;
|
||||
|
||||
import com.mockobjects.servlet.MockJspWriter;
|
||||
import com.opensymphony.xwork.XWorkStatic;
|
||||
import org.apache.struts.action2.TestConfigurationProvider;
|
||||
import org.apache.struts.action2.views.jsp.AbstractUITagTest;
|
||||
import org.apache.struts.action2.views.jsp.ParamTag;
|
||||
import org.apache.struts.action2.views.jsp.StrutsMockBodyContent;
|
||||
|
||||
import com.opensymphony.xwork.config.ConfigurationManager;
|
||||
|
||||
/**
|
||||
* UI components Tooltip test case.
|
||||
*
|
||||
*/
|
||||
public class TooltipTest extends AbstractUITagTest {
|
||||
|
||||
public void testWithoutFormOverriding() throws Exception {
|
||||
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
|
||||
// we test it on textfield component, but since the tooltip are common to
|
||||
// all components, it will be the same for other components as well.
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
formTag.setName("myForm");
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
|
||||
|
||||
tag.setTooltip("myTooltip");
|
||||
tag.setTooltipConfig(
|
||||
"#{" +
|
||||
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'true', " +
|
||||
"'tooltipBgColor':'#ffffff', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/myBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'10', " +
|
||||
"'tooltipBorderColor':'#eeeeee', " +
|
||||
"'tooltipDelay':'2000', " +
|
||||
"'tooltipFixCoordinateX':'300', " +
|
||||
"'tooltipFixCoordinateY':'300', " +
|
||||
"'tooltipFontColor':'#dddddd', " +
|
||||
"'tooltipFontFace':'San-Serif,Verdana', " +
|
||||
"'tooltipFontSize':'20', "+
|
||||
"'tooltipFontWeight':'bold', " +
|
||||
"'tooltipLeftOfMousePointer':'true', " +
|
||||
"'tooltipOffsetX':'10', " +
|
||||
"'tooltipOffsetY':'20', " +
|
||||
"'tooltipOpacity':'90', " +
|
||||
"'tooltipPadding':'30', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'40', " +
|
||||
"'tooltipStatic':'true', " +
|
||||
"'tooltipSticky':'true', " +
|
||||
"'tooltipStayAppearTime':'3000', " +
|
||||
"'tooltipTextAlign':'right', " +
|
||||
"'tooltipTitle':'MyTitle', " +
|
||||
"'tooltipTitleColor':'#bbbbbb', " +
|
||||
"'tooltipWidth':'600' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
formTag.doStartTag();
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-1.txt"));
|
||||
}
|
||||
|
||||
public void testWithFormOverriding() throws Exception {
|
||||
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setName("myForm");
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
formTag.setTooltipConfig(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/formMyTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'false', " +
|
||||
"'tooltipBgColor':'#aaaaaa', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/formMyBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'11', " +
|
||||
"'tooltipBorderColor':'#bbbbbb', " +
|
||||
"'tooltipDelay':'2001', " +
|
||||
"'tooltipFixCoordinateX':'301', " +
|
||||
"'tooltipFixCoordinateY':'301', " +
|
||||
"'tooltipFontColor':'#cccccc', " +
|
||||
"'tooltipFontFace':'Verdana,San-Serif', " +
|
||||
"'tooltipFontSize':'21', " +
|
||||
"'tooltipFontWeight':'normal', " +
|
||||
"'tooltipLeftOfMousePointer':'false', " +
|
||||
"'tooltipOffsetX':'11', " +
|
||||
"'tooltipOffsetY':'21', " +
|
||||
"'tooltipOpacity':'91', " +
|
||||
"'tooltipPadding':'31', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'41', " +
|
||||
"'tooltipStatic':'false', " +
|
||||
"'tooltipSticky':'false', " +
|
||||
"'tooltipStayAppearTime':'3001', " +
|
||||
"'tooltipTextAlign':'left', " +
|
||||
"'tooltipTitle':'FormMyTitle', " +
|
||||
"'tooltipTitleColor':'#dddddd', " +
|
||||
"'tooltipWidth':'601' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
|
||||
tag.setTooltip("myTooltip");
|
||||
|
||||
formTag.doStartTag();
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-2.txt"));
|
||||
}
|
||||
|
||||
public void testWithPartialFormOverriding() throws Exception {
|
||||
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setName("myForm");
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
formTag.setTooltipConfig(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/formMyTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'false', " +
|
||||
"'tooltipBgColor':'#aaaaaa', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/formMyBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'11', " +
|
||||
"'tooltipBorderColor':'#bbbbbb', " +
|
||||
"'tooltipDelay':'2001', " +
|
||||
"'tooltipFixCoordinateX':'301', " +
|
||||
"'tooltipFixCoordinateY':'301', " +
|
||||
"'tooltipFontColor':'#cccccc', " +
|
||||
"'tooltipFontFace':'Verdana,San-Serif', " +
|
||||
"'tooltipFontSize':'21', " +
|
||||
"'tooltipFontWeight':'normal', " +
|
||||
"'tooltipLeftOfMousePointer':'false', " +
|
||||
"'tooltipOffsetX':'11', " +
|
||||
"'tooltipOffsetY':'21', " +
|
||||
"'tooltipOpacity':'91', " +
|
||||
"'tooltipPadding':'31', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'41', " +
|
||||
"'tooltipStatic':'false', " +
|
||||
"'tooltipSticky':'false', " +
|
||||
"'tooltipStayAppearTime':'3001', " +
|
||||
"'tooltipTextAlign':'left', " +
|
||||
"'tooltipTitle':'FormMyTitle', " +
|
||||
"'tooltipTitleColor':'#dddddd', " +
|
||||
"'tooltipWidth':'601' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
|
||||
tag.setTooltip("myTooltip");
|
||||
tag.setTooltipConfig(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'true', " +
|
||||
"'tooltipBgColor':'#ffffff', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/myBgImg.gif' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
formTag.doStartTag();
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-3.txt"));
|
||||
}
|
||||
|
||||
|
||||
public void testUsingParamValueToSetConfigurations() throws Exception {
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setName("myForm");
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
|
||||
ParamTag formParamTag = new ParamTag();
|
||||
formParamTag.setPageContext(pageContext);
|
||||
formParamTag.setName("tooltipConfig");
|
||||
formParamTag.setValue(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/formMyTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'false', " +
|
||||
"'tooltipBgColor':'#aaaaaa', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/formMyBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'11', " +
|
||||
"'tooltipBorderColor':'#bbbbbb', " +
|
||||
"'tooltipDelay':'2001', " +
|
||||
"'tooltipFixCoordinateX':'301', " +
|
||||
"'tooltipFixCoordinateY':'301', " +
|
||||
"'tooltipFontColor':'#cccccc', " +
|
||||
"'tooltipFontFace':'Verdana,San-Serif', " +
|
||||
"'tooltipFontSize':'21', " +
|
||||
"'tooltipFontWeight':'normal', " +
|
||||
"'tooltipLeftOfMousePointer':'false', " +
|
||||
"'tooltipOffsetX':'11', " +
|
||||
"'tooltipOffsetY':'21', " +
|
||||
"'tooltipOpacity':'91', " +
|
||||
"'tooltipPadding':'31', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'41', " +
|
||||
"'tooltipStatic':'false', " +
|
||||
"'tooltipSticky':'false', " +
|
||||
"'tooltipStayAppearTime':'3001', " +
|
||||
"'tooltipTextAlign':'left', " +
|
||||
"'tooltipTitle':'FormMyTitle', " +
|
||||
"'tooltipTitleColor':'#dddddd', " +
|
||||
"'tooltipWidth':'601' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
tag.setTooltip("myTooltip");
|
||||
|
||||
ParamTag textFieldParamTag = new ParamTag();
|
||||
textFieldParamTag.setPageContext(pageContext);
|
||||
textFieldParamTag.setName("tooltipConfig");
|
||||
textFieldParamTag.setValue(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'true', " +
|
||||
"'tooltipBgColor':'#ffffff', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/myBgImg.gif' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
formTag.doStartTag();
|
||||
formParamTag.doStartTag();
|
||||
formParamTag.doEndTag();
|
||||
tag.doStartTag();
|
||||
textFieldParamTag.doStartTag();
|
||||
textFieldParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-3.txt"));
|
||||
}
|
||||
|
||||
|
||||
public void testUsingParamBodyValueToSetConfigurations() throws Exception {
|
||||
ConfigurationManager.clearConfigurationProviders();
|
||||
ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setName("myForm");
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
|
||||
ParamTag formParamTag = new ParamTag();
|
||||
formParamTag.setPageContext(pageContext);
|
||||
formParamTag.setName("tooltipConfig");
|
||||
StrutsMockBodyContent bodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
bodyContent.setString(
|
||||
"tooltipIcon = /struts/tooltip/formMyTooltip.gif | " +
|
||||
"tooltipAboveMousePointer = false | " +
|
||||
"tooltipBgColor = #aaaaaa| " +
|
||||
"tooltipBgImg = /struts/tooltip/formMyBgImg.gif | " +
|
||||
"tooltipBorderWidth = 11 | " +
|
||||
"tooltipBorderColor = #bbbbbb| " +
|
||||
"tooltipDelay = 2001 | " +
|
||||
"tooltipFixCoordinateX = 301| " +
|
||||
"tooltipFixCoordinateY = 301| " +
|
||||
"tooltipFontColor = #cccccc | " +
|
||||
"tooltipFontFace = Verdana,San-Serif | " +
|
||||
"tooltipFontSize = 21 | " +
|
||||
"tooltipFontWeight = normal | " +
|
||||
"tooltipLeftOfMousePointer = false | " +
|
||||
"tooltipOffsetX = 11 | " +
|
||||
"tooltipOffsetY = 21| " +
|
||||
"tooltipOpacity = 91| " +
|
||||
"tooltipPadding = 31| " +
|
||||
"tooltipShadowColor = #cccccc| " +
|
||||
"tooltipShadowWidth = 41| " +
|
||||
"tooltipStatic = false | " +
|
||||
"tooltipSticky = false| " +
|
||||
"tooltipStayAppearTime = 3001| " +
|
||||
"tooltipTextAlign = left| " +
|
||||
"tooltipTitle = FormMyTitle| " +
|
||||
"tooltipTitleColor = #dddddd| " +
|
||||
"tooltipWidth = 601 "
|
||||
);
|
||||
formParamTag.setBodyContent(bodyContent);
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
tag.setTooltip("myTooltip");
|
||||
|
||||
|
||||
ParamTag textFieldParamTag = new ParamTag();
|
||||
textFieldParamTag.setPageContext(pageContext);
|
||||
textFieldParamTag.setName("tooltipConfig");
|
||||
StrutsMockBodyContent bodyContent2 = new StrutsMockBodyContent(new MockJspWriter());
|
||||
bodyContent2.setString(
|
||||
"tooltipIcon = /struts/tooltip/myTooltip.gif | " +
|
||||
"tooltipAboveMousePointer = true | " +
|
||||
"tooltipBgColor = #ffffff | " +
|
||||
"tooltipBgImg = /struts/tooltip/myBgImg.gif "
|
||||
);
|
||||
textFieldParamTag.setBodyContent(bodyContent2);
|
||||
|
||||
formTag.doStartTag();
|
||||
formParamTag.doStartTag();
|
||||
formParamTag.doEndTag();
|
||||
tag.doStartTag();
|
||||
textFieldParamTag.doStartTag();
|
||||
textFieldParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-3.txt"));
|
||||
}
|
||||
public void testWithoutFormOverriding() throws Exception {
|
||||
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
// we test it on textfield component, but since the tooltip are common to
|
||||
// all components, it will be the same for other components as well.
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
formTag.setName("myForm");
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
|
||||
|
||||
tag.setTooltip("myTooltip");
|
||||
tag.setTooltipConfig(
|
||||
"#{" +
|
||||
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'true', " +
|
||||
"'tooltipBgColor':'#ffffff', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/myBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'10', " +
|
||||
"'tooltipBorderColor':'#eeeeee', " +
|
||||
"'tooltipDelay':'2000', " +
|
||||
"'tooltipFixCoordinateX':'300', " +
|
||||
"'tooltipFixCoordinateY':'300', " +
|
||||
"'tooltipFontColor':'#dddddd', " +
|
||||
"'tooltipFontFace':'San-Serif,Verdana', " +
|
||||
"'tooltipFontSize':'20', " +
|
||||
"'tooltipFontWeight':'bold', " +
|
||||
"'tooltipLeftOfMousePointer':'true', " +
|
||||
"'tooltipOffsetX':'10', " +
|
||||
"'tooltipOffsetY':'20', " +
|
||||
"'tooltipOpacity':'90', " +
|
||||
"'tooltipPadding':'30', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'40', " +
|
||||
"'tooltipStatic':'true', " +
|
||||
"'tooltipSticky':'true', " +
|
||||
"'tooltipStayAppearTime':'3000', " +
|
||||
"'tooltipTextAlign':'right', " +
|
||||
"'tooltipTitle':'MyTitle', " +
|
||||
"'tooltipTitleColor':'#bbbbbb', " +
|
||||
"'tooltipWidth':'600' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
formTag.doStartTag();
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-1.txt"));
|
||||
}
|
||||
|
||||
public void testWithFormOverriding() throws Exception {
|
||||
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setName("myForm");
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
formTag.setTooltipConfig(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/formMyTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'false', " +
|
||||
"'tooltipBgColor':'#aaaaaa', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/formMyBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'11', " +
|
||||
"'tooltipBorderColor':'#bbbbbb', " +
|
||||
"'tooltipDelay':'2001', " +
|
||||
"'tooltipFixCoordinateX':'301', " +
|
||||
"'tooltipFixCoordinateY':'301', " +
|
||||
"'tooltipFontColor':'#cccccc', " +
|
||||
"'tooltipFontFace':'Verdana,San-Serif', " +
|
||||
"'tooltipFontSize':'21', " +
|
||||
"'tooltipFontWeight':'normal', " +
|
||||
"'tooltipLeftOfMousePointer':'false', " +
|
||||
"'tooltipOffsetX':'11', " +
|
||||
"'tooltipOffsetY':'21', " +
|
||||
"'tooltipOpacity':'91', " +
|
||||
"'tooltipPadding':'31', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'41', " +
|
||||
"'tooltipStatic':'false', " +
|
||||
"'tooltipSticky':'false', " +
|
||||
"'tooltipStayAppearTime':'3001', " +
|
||||
"'tooltipTextAlign':'left', " +
|
||||
"'tooltipTitle':'FormMyTitle', " +
|
||||
"'tooltipTitleColor':'#dddddd', " +
|
||||
"'tooltipWidth':'601' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
|
||||
tag.setTooltip("myTooltip");
|
||||
|
||||
formTag.doStartTag();
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-2.txt"));
|
||||
}
|
||||
|
||||
public void testWithPartialFormOverriding() throws Exception {
|
||||
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setName("myForm");
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
formTag.setTooltipConfig(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/formMyTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'false', " +
|
||||
"'tooltipBgColor':'#aaaaaa', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/formMyBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'11', " +
|
||||
"'tooltipBorderColor':'#bbbbbb', " +
|
||||
"'tooltipDelay':'2001', " +
|
||||
"'tooltipFixCoordinateX':'301', " +
|
||||
"'tooltipFixCoordinateY':'301', " +
|
||||
"'tooltipFontColor':'#cccccc', " +
|
||||
"'tooltipFontFace':'Verdana,San-Serif', " +
|
||||
"'tooltipFontSize':'21', " +
|
||||
"'tooltipFontWeight':'normal', " +
|
||||
"'tooltipLeftOfMousePointer':'false', " +
|
||||
"'tooltipOffsetX':'11', " +
|
||||
"'tooltipOffsetY':'21', " +
|
||||
"'tooltipOpacity':'91', " +
|
||||
"'tooltipPadding':'31', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'41', " +
|
||||
"'tooltipStatic':'false', " +
|
||||
"'tooltipSticky':'false', " +
|
||||
"'tooltipStayAppearTime':'3001', " +
|
||||
"'tooltipTextAlign':'left', " +
|
||||
"'tooltipTitle':'FormMyTitle', " +
|
||||
"'tooltipTitleColor':'#dddddd', " +
|
||||
"'tooltipWidth':'601' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
|
||||
tag.setTooltip("myTooltip");
|
||||
tag.setTooltipConfig(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'true', " +
|
||||
"'tooltipBgColor':'#ffffff', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/myBgImg.gif' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
formTag.doStartTag();
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-3.txt"));
|
||||
}
|
||||
|
||||
|
||||
public void testUsingParamValueToSetConfigurations() throws Exception {
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setName("myForm");
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
|
||||
ParamTag formParamTag = new ParamTag();
|
||||
formParamTag.setPageContext(pageContext);
|
||||
formParamTag.setName("tooltipConfig");
|
||||
formParamTag.setValue(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/formMyTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'false', " +
|
||||
"'tooltipBgColor':'#aaaaaa', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/formMyBgImg.gif', " +
|
||||
"'tooltipBorderWidth':'11', " +
|
||||
"'tooltipBorderColor':'#bbbbbb', " +
|
||||
"'tooltipDelay':'2001', " +
|
||||
"'tooltipFixCoordinateX':'301', " +
|
||||
"'tooltipFixCoordinateY':'301', " +
|
||||
"'tooltipFontColor':'#cccccc', " +
|
||||
"'tooltipFontFace':'Verdana,San-Serif', " +
|
||||
"'tooltipFontSize':'21', " +
|
||||
"'tooltipFontWeight':'normal', " +
|
||||
"'tooltipLeftOfMousePointer':'false', " +
|
||||
"'tooltipOffsetX':'11', " +
|
||||
"'tooltipOffsetY':'21', " +
|
||||
"'tooltipOpacity':'91', " +
|
||||
"'tooltipPadding':'31', " +
|
||||
"'tooltipShadowColor':'#cccccc', " +
|
||||
"'tooltipShadowWidth':'41', " +
|
||||
"'tooltipStatic':'false', " +
|
||||
"'tooltipSticky':'false', " +
|
||||
"'tooltipStayAppearTime':'3001', " +
|
||||
"'tooltipTextAlign':'left', " +
|
||||
"'tooltipTitle':'FormMyTitle', " +
|
||||
"'tooltipTitleColor':'#dddddd', " +
|
||||
"'tooltipWidth':'601' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
tag.setTooltip("myTooltip");
|
||||
|
||||
ParamTag textFieldParamTag = new ParamTag();
|
||||
textFieldParamTag.setPageContext(pageContext);
|
||||
textFieldParamTag.setName("tooltipConfig");
|
||||
textFieldParamTag.setValue(
|
||||
"#{ " +
|
||||
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
|
||||
"'tooltipAboveMousePointer':'true', " +
|
||||
"'tooltipBgColor':'#ffffff', " +
|
||||
"'tooltipBgImg':'/struts/tooltip/myBgImg.gif' " +
|
||||
"}"
|
||||
);
|
||||
|
||||
formTag.doStartTag();
|
||||
formParamTag.doStartTag();
|
||||
formParamTag.doEndTag();
|
||||
tag.doStartTag();
|
||||
textFieldParamTag.doStartTag();
|
||||
textFieldParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-3.txt"));
|
||||
}
|
||||
|
||||
|
||||
public void testUsingParamBodyValueToSetConfigurations() throws Exception {
|
||||
XWorkStatic.getConfigurationManager().clearConfigurationProviders();
|
||||
XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
|
||||
|
||||
FormTag formTag = new FormTag();
|
||||
formTag.setName("myForm");
|
||||
formTag.setPageContext(pageContext);
|
||||
formTag.setId("myFormId");
|
||||
formTag.setAction("testAction");
|
||||
|
||||
|
||||
ParamTag formParamTag = new ParamTag();
|
||||
formParamTag.setPageContext(pageContext);
|
||||
formParamTag.setName("tooltipConfig");
|
||||
StrutsMockBodyContent bodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
bodyContent.setString(
|
||||
"tooltipIcon = /struts/tooltip/formMyTooltip.gif | " +
|
||||
"tooltipAboveMousePointer = false | " +
|
||||
"tooltipBgColor = #aaaaaa| " +
|
||||
"tooltipBgImg = /struts/tooltip/formMyBgImg.gif | " +
|
||||
"tooltipBorderWidth = 11 | " +
|
||||
"tooltipBorderColor = #bbbbbb| " +
|
||||
"tooltipDelay = 2001 | " +
|
||||
"tooltipFixCoordinateX = 301| " +
|
||||
"tooltipFixCoordinateY = 301| " +
|
||||
"tooltipFontColor = #cccccc | " +
|
||||
"tooltipFontFace = Verdana,San-Serif | " +
|
||||
"tooltipFontSize = 21 | " +
|
||||
"tooltipFontWeight = normal | " +
|
||||
"tooltipLeftOfMousePointer = false | " +
|
||||
"tooltipOffsetX = 11 | " +
|
||||
"tooltipOffsetY = 21| " +
|
||||
"tooltipOpacity = 91| " +
|
||||
"tooltipPadding = 31| " +
|
||||
"tooltipShadowColor = #cccccc| " +
|
||||
"tooltipShadowWidth = 41| " +
|
||||
"tooltipStatic = false | " +
|
||||
"tooltipSticky = false| " +
|
||||
"tooltipStayAppearTime = 3001| " +
|
||||
"tooltipTextAlign = left| " +
|
||||
"tooltipTitle = FormMyTitle| " +
|
||||
"tooltipTitleColor = #dddddd| " +
|
||||
"tooltipWidth = 601 "
|
||||
);
|
||||
formParamTag.setBodyContent(bodyContent);
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("MyLabel");
|
||||
tag.setId("myId");
|
||||
tag.setTooltip("myTooltip");
|
||||
|
||||
|
||||
ParamTag textFieldParamTag = new ParamTag();
|
||||
textFieldParamTag.setPageContext(pageContext);
|
||||
textFieldParamTag.setName("tooltipConfig");
|
||||
StrutsMockBodyContent bodyContent2 = new StrutsMockBodyContent(new MockJspWriter());
|
||||
bodyContent2.setString(
|
||||
"tooltipIcon = /struts/tooltip/myTooltip.gif | " +
|
||||
"tooltipAboveMousePointer = true | " +
|
||||
"tooltipBgColor = #ffffff | " +
|
||||
"tooltipBgImg = /struts/tooltip/myBgImg.gif "
|
||||
);
|
||||
textFieldParamTag.setBodyContent(bodyContent2);
|
||||
|
||||
formTag.doStartTag();
|
||||
formParamTag.doStartTag();
|
||||
formParamTag.doEndTag();
|
||||
tag.doStartTag();
|
||||
textFieldParamTag.doStartTag();
|
||||
textFieldParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
formTag.doEndTag();
|
||||
|
||||
verify(TooltipTest.class.getResource("tooltip-3.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user