Package org.apache.struts2.dispatcher.mapper

Examples of org.apache.struts2.dispatcher.mapper.ActionMapping


  /**
   * reserved method parameter
   */
  public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
    ActionMapping mapping = super.getMapping(request, configManager);
    if (null != mapping) {
      String method = request.getParameter(methodParam);
      if (StringUtils.isNotEmpty(method)) {
        mapping.setMethod(method);
      }
    }
    return mapping;
  }
View Full Code Here


        ServletActionContext.setRequest(request);
        ServletActionContext.setResponse(response);
        ServletActionContext.setServletContext(servletContext);

        ActionMapping mapping = null;
        return dispatcher.getContainer()
           .getInstance(ActionProxyFactory.class)
           .createActionProxy(
            namespace,
            actionName,
View Full Code Here

              .getValue().toString(), invocation));
        }
      }
    }

    StringBuffer tmpLocation = new StringBuffer(actionMapper.getUriFromActionMapping(new ActionMapping(actionName,
        namespace, method, null)));
    UrlHelper.buildParametersString(requestParameters, tmpLocation, "&");

    setLocation(tmpLocation.toString());
View Full Code Here

            fullPath.append(namespace).append("/");
        } else {
            fullPath.append("/");
        }
        fullPath.append(defaultAction);
        ActionMapping mapping = new ActionMapping();
        mapping.setName(getActionName(fullPath.toString()));
        mapping.setNamespace(getNamespace(fullPath.toString()));
        if(method != null) {
          mapping.setMethod(method);
        }
        actionMap.put(portletMode, mapping);
    }
View Full Code Here

     *
     * @param request the PortletRequest object.
     * @return the namespace of the action.
     */
    protected ActionMapping getActionMapping(final PortletRequest request) {
        ActionMapping mapping = null;
        String actionPath = null;
        if (resetAction(request)) {
            mapping = (ActionMapping) actionMap.get(request.getPortletMode());
        } else {
            actionPath = request.getParameter(ACTION_PARAM);
View Full Code Here

        // This is necessary since we need the dispatcher instance, which was created by the prepare filter
        if (execute == null) {
            lazyInit();
        }

        ActionMapping mapping = prepare.findActionMapping(request, response);

        //if recusrion counter is > 1, it means we are in a "forward", in that case a mapping will still be
        //in the request, if we handle it, it will lead to an infinte loop, see WW-3077
        Integer recursionCounter = (Integer) request.getAttribute(PrepareOperations.CLEANUP_RECURSION_COUNTER);
View Full Code Here

            } else {
                prepare.setEncodingAndLocale(request, response);
                prepare.createActionContext(request, response);
                prepare.assignDispatcherToThread();
                request = prepare.wrapRequest(request);
                ActionMapping mapping = prepare.findActionMapping(request, response, true);
                if (mapping == null) {
                    boolean handled = execute.executeStaticResourceRequest(request, response);
                    if (!handled) {
                        chain.doFilter(request, response);
                    }
View Full Code Here

@ContextConfiguration(locations={"classpath*:applicationContext.xml"})
public class StrutsSpringJUnit4TestCaseTest extends StrutsSpringJUnit4TestCase<JUnitTestAction> {

  @Test
    public void getActionMapping() {
        ActionMapping mapping = getActionMapping("/test/testAction.action");
        Assert.assertNotNull(mapping);
        Assert.assertEquals("/test", mapping.getNamespace());
        Assert.assertEquals("testAction", mapping.getName());
    }
View Full Code Here

            if (validationAwareAction.hasErrors()) {
              if (LOG.isDebugEnabled()) {
                LOG.debug("Errors on action "+validationAwareAction+", returning result name 'input'");
              }
              ActionMapping mapping = (ActionMapping) ActionContext.getContext().get(ServletActionContext.ACTION_MAPPING);
              String method = inputResultName;
                if (postMethodName.equals(mapping.getMethod())) {
                   method = newMethodName;
                } else if (putMethodName.equals(mapping.getMethod())) {
                   method = editMethodName;
                }
               
               
              HttpHeaders info = new DefaultHttpHeaders()
View Full Code Here

        this.allowDynamicMethodCalls = "true".equalsIgnoreCase(allowDynamicMethodCalls);
    }
   
    public ActionMapping getMapping(HttpServletRequest request,
            ConfigurationManager configManager) {
        ActionMapping mapping = new ActionMapping();
        String uri = RequestUtils.getUri(request);

        uri = dropExtension(uri, mapping);
        if (uri == null) {
            return null;
        }

        parseNameAndNamespace(uri, mapping, configManager);

        handleSpecialParameters(request, mapping);

        if (mapping.getName() == null) {
            return null;
        }

        // handle "name!method" convention.
        handleDynamicMethodInvocation(mapping, mapping.getName());

        String fullName = mapping.getName();
        // Only try something if the action name is specified
        if (fullName != null && fullName.length() > 0) {

            // cut off any ;jsessionid= type appendix but allow the rails-like ;edit
            int scPos = fullName.indexOf(';');
            if (scPos > -1 && !"edit".equals(fullName.substring(scPos + 1))) {
                fullName = fullName.substring(0, scPos);
            }

            int lastSlashPos = fullName.lastIndexOf('/');
            String id = null;
            if (lastSlashPos > -1) {

                // fun trickery to parse 'actionName/id/methodName' in the case of 'animals/dog/edit'
                int prevSlashPos = fullName.lastIndexOf('/', lastSlashPos - 1);
                if (prevSlashPos > -1) {
                    mapping.setMethod(fullName.substring(lastSlashPos + 1));
                    fullName = fullName.substring(0, lastSlashPos);
                    lastSlashPos = prevSlashPos;
                }
                id = fullName.substring(lastSlashPos + 1);
            }



            // If a method hasn't been explicitly named, try to guess using ReST-style patterns
            if (mapping.getMethod() == null) {

              if (isOptions(request)) {
                  mapping.setMethod(optionsMethodName);
               
              // Handle uris with no id, possibly ending in '/'
              } else if (lastSlashPos == -1 || lastSlashPos == fullName.length() -1) {

                    // Index e.g. foo
                    if (isGet(request)) {
                        mapping.setMethod(indexMethodName);
                       
                    // Creating a new entry on POST e.g. foo
                    } else if (isPost(request)) {
                      if (isExpectContinue(request)) {
                            mapping.setMethod(postContinueMethodName);
                      } else {
                            mapping.setMethod(postMethodName);
                      }
                    }

                // Handle uris with an id at the end
                } else if (id != null) {
                   
                    // Viewing the form to edit an item e.g. foo/1;edit
                    if (isGet(request) && id.endsWith(";edit")) {
                        id = id.substring(0, id.length() - ";edit".length());
                        mapping.setMethod(editMethodName);
                       
                    // Viewing the form to create a new item e.g. foo/new
                    } else if (isGet(request) && "new".equals(id)) {
                        mapping.setMethod(newMethodName);

                    // Removing an item e.g. foo/1
                    } else if (isDelete(request)) {
                        mapping.setMethod(deleteMethodName);
                       
                    // Viewing an item e.g. foo/1
                    } else if (isGet(request)) {
                        mapping.setMethod(getMethodName);
                   
                    // Updating an item e.g. foo/1   
                    else if (isPut(request)) {
                      if (isExpectContinue(request)) {
                            mapping.setMethod(putContinueMethodName);
                      } else {
                            mapping.setMethod(putMethodName);
                      }
                    }
                }
            }

            // cut off the id parameter, even if a method is specified
            if (id != null) {
                if (!"new".equals(id)) {
                    if (mapping.getParams() == null) {
                        mapping.setParams(new HashMap());
                    }
                    mapping.getParams().put(idParameterName, new String[]{id});
                }
                fullName = fullName.substring(0, lastSlashPos);
            }

            mapping.setName(fullName);
            return mapping;
        }
        // if action name isn't specified, it can be a normal request, to static resource, return null to allow handle that case
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.struts2.dispatcher.mapper.ActionMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.