use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class FormTag method lookup.
// ------------------------------------------------------ Protected Methods
/**
* Look up values for the <code>name</code>, <code>scope</code>, and
* <code>type</code> properties if necessary.
*
* @throws JspException if a required value cannot be looked up
*/
protected void lookup() throws JspException {
// Look up the module configuration information we need
moduleConfig = TagUtils.getInstance().getModuleConfig(pageContext);
if (moduleConfig == null) {
JspException e = new JspException(messages.getMessage("formTag.collections"));
pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
throw e;
}
String calcAction = this.action;
// If the action is not specified, use the original request uri
if (this.action == null) {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
postbackAction = (String) request.getAttribute(Globals.ORIGINAL_URI_KEY);
String prefix = moduleConfig.getPrefix();
if (postbackAction != null && prefix.length() > 0 && postbackAction.startsWith(prefix)) {
postbackAction = postbackAction.substring(prefix.length());
}
calcAction = postbackAction;
} else {
// Translate the action if it is an actionId
ActionConfig actionConfig = moduleConfig.findActionConfigId(this.action);
if (actionConfig != null) {
this.action = actionConfig.getPath();
calcAction = this.action;
}
}
servlet = (ActionServlet) pageContext.getServletContext().getAttribute(Globals.ACTION_SERVLET_KEY);
// Look up the action mapping we will be submitting to
String mappingName = TagUtils.getInstance().getActionMappingName(calcAction);
mapping = (ActionMapping) moduleConfig.findActionConfig(mappingName);
if (mapping == null) {
JspException e = new JspException(messages.getMessage("formTag.mapping", mappingName));
pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
throw e;
}
// Look up the form bean definition
FormBeanConfig formBeanConfig = moduleConfig.findFormBeanConfig(mapping.getName());
if (formBeanConfig == null) {
JspException e = null;
if (mapping.getName() == null) {
e = new JspException(messages.getMessage("formTag.name", calcAction));
} else {
e = new JspException(messages.getMessage("formTag.formBean", mapping.getName(), calcAction));
}
pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
throw e;
}
// Calculate the required values
beanName = mapping.getAttribute();
beanScope = mapping.getScope();
beanType = formBeanConfig.getType();
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean1.
// use servlet mapping (extension mapping)
public void testString_getActionMappingURL_String_String_PageContext_boolean1() {
pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "*.do");
ActionConfig actionConfig = new ActionConfig();
actionConfig.setParameter("/foo");
moduleConfig.addActionConfig(actionConfig);
request.setAttribute(Globals.MODULE_KEY, moduleConfig);
request.setPathElements("/myapp", "/baz.do", null, null);
assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo", pageContext), "/myapp/foo.do");
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean3.
// use servlet mapping (extension mapping)
// -- path as "/"
// (this is probably not a realistic use case)
public void testString_getActionMappingURL_String_String_PageContext_boolean3() {
pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "*.do");
ActionConfig actionConfig = new ActionConfig();
actionConfig.setParameter("/foo");
moduleConfig.addActionConfig(actionConfig);
request.setAttribute(Globals.MODULE_KEY, moduleConfig);
request.setPathElements("/mycontext", "/baz", null, null);
assertEquals("Check path /foo", tagutils.getActionMappingURL("/", pageContext), "/mycontext/.do");
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean5.
// use servlet mapping (path mapping)
// -- with params
public void testString_getActionMappingURL_String_String_PageContext_boolean5() {
pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "/myapp/*");
ActionConfig actionConfig = new ActionConfig();
actionConfig.setParameter("/foo");
moduleConfig.addActionConfig(actionConfig);
request.setAttribute(Globals.MODULE_KEY, moduleConfig);
request.setPathElements("/mycontext", "/baz?foo=bar", null, null);
assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo?foo=bar", pageContext), "/mycontext/myapp/foo?foo=bar");
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean6.
// use servlet mapping (path mapping)
// -- using "/" as mapping
public void testString_getActionMappingURL_String_String_PageContext_boolean6() {
pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "/");
ActionConfig actionConfig = new ActionConfig();
actionConfig.setParameter("/foo");
moduleConfig.addActionConfig(actionConfig);
request.setAttribute(Globals.MODULE_KEY, moduleConfig);
request.setPathElements("/mycontext", "/baz", null, null);
assertEquals("Check path /foo", tagutils.getActionMappingURL("/", pageContext), "/mycontext/");
}
Aggregations