Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMapping


            throw e;
        }

        // Look up the action mapping we will be submitting to
        String mappingName = getActionMappingName();
        ActionMapping mapping = mappings.findMapping(mappingName);
        if (mapping == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.mapping", mappingName));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Look up the form bean definition
        ActionFormBean formBean =
            formBeans.findFormBean(mapping.getName());
        if (formBean == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.formBean", mapping.getName()));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Calculate the required values
        name = mapping.getName();
        scope = mapping.getScope();
        servlet = mappings.getServlet();
        type = formBean.getType();

    }
View Full Code Here


            throw e;
        }

        // Look up the action mapping we will be submitting to
        String mappingName = getActionMappingName();
        ActionMapping mapping = mappings.findMapping(mappingName);
        if (mapping == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.mapping", mappingName));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Look up the form bean definition
        ActionFormBean formBean =
            formBeans.findFormBean(mapping.getName());
        if (formBean == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.formBean", mapping.getName()));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Calculate the required values
        name = mapping.getName();
        scope = mapping.getScope();
        type = formBean.getType();

    }
View Full Code Here

            throw e;
        }

        // Look up the action mapping we will be submitting to
        String mappingName = getActionMappingName();
        ActionMapping mapping = mappings.findMapping(mappingName);
        if (mapping == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.mapping", mappingName));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Look up the form bean definition
        ActionFormBean formBean =
            formBeans.findFormBean(mapping.getName());
        if (formBean == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.formBean", mapping.getName()));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Calculate the required values
        name = mapping.getName();
        scope = mapping.getScope();
        servlet = mappings.getServlet();
        type = formBean.getType();

    }
View Full Code Here

            throw e;
        }

        // Look up the action mapping we will be submitting to
        String mappingName = getActionMappingName();
        ActionMapping mapping = mappings.findMapping(mappingName);
        if (mapping == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.mapping", mappingName));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Look up the form bean definition
        ActionFormBean formBean =
            formBeans.findFormBean(mapping.getName());
        if (formBean == null) {
            JspException e = new JspException
                (messages.getMessage("formTag.formBean", mapping.getName()));
            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
                                     PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Calculate the required values
        name = mapping.getName();
        scope = mapping.getScope();
        type = formBean.getType();

    }
View Full Code Here

     */
    public void testCreateActionMapping() {
        PackageConfig packageConfig = config.getPackageConfig(PACKAGE_NAME);
        com.opensymphony.xwork2.config.entities.ActionConfig actionConfig =
                (com.opensymphony.xwork2.config.entities.ActionConfig) packageConfig.getActionConfigs().get("action1");
        ActionMapping mapping = factory.createActionMapping(actionConfig);
        assertNotNull(mapping);

        assertNotNull(mapping.findForward("result1"));
        assertNotNull(mapping.findForwardConfig("result2"));

        ForwardConfig[] configs = mapping.findForwardConfigs();
        assertNotNull(configs);
        assertEquals(2, configs.length);

        String[] forwards = mapping.findForwards();
        assertNotNull(forwards);
        assertEquals(2, forwards.length);
       
        ActionForward fwd = mapping.findForward("result1");
        assertNotNull(fwd);
        assertEquals("result1", fwd.getName());

        assertNotNull(mapping.findException(NullPointerException.class));
        assertNotNull(mapping.findExceptionConfig("java.lang.IllegalStateException"));

        ExceptionConfig[] exceptionConfigs = mapping.findExceptionConfigs();
        assertNotNull(exceptionConfigs);
        assertEquals(3, exceptionConfigs.length);
       
        ModuleConfig moduleConfig = mapping.getModuleConfig();
        assertNotNull(moduleConfig);
       
        // For now, the path will be null if the ActionMapping was created on its own (as opposed to from a
        // WrapperModuleConfig, which knows the path).
        assertNull(mapping.getPath());
       
        // These methods are currently not implemented -- replace as functionality is added.
        assertNYI(mapping, "getInputForward", null);
        assertNYI(mapping, "getForward", null);
        assertNYI(mapping, "getInclude", null);
View Full Code Here

            ScopedModelDriven modelDriven = (ScopedModelDriven) action;
            Object model = modelDriven.getModel();
            if (model != null) {
                HttpServletRequest req = ServletActionContext.getRequest();
                Struts1Factory strutsFactory = new Struts1Factory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
                ActionMapping mapping = strutsFactory.createActionMapping(invocation.getProxy().getConfig());
                ModuleConfig moduleConfig = strutsFactory.createModuleConfig(invocation.getProxy().getConfig().getPackageName());
                req.setAttribute(Globals.MODULE_KEY, moduleConfig);
                req.setAttribute(Globals.MESSAGES_KEY, new WrapperMessageResources((TextProvider)invocation.getAction()));
               
                mapping.setAttribute(modelDriven.getScopeKey());
               
                ActionForm form = (ActionForm) model;
                form.setServlet(new ActionServlet(){
                    public ServletContext getServletContext() {
                        return ServletActionContext.getServletContext();
View Full Code Here

        }
       
        // We should call setServlet() here, but let's stub that out later
       
        Struts1Factory strutsFactory = new Struts1Factory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
        ActionMapping mapping = strutsFactory.createActionMapping(actionConfig);
        HttpServletRequest request = ServletActionContext.getRequest();
        HttpServletResponse response = ServletActionContext.getResponse();
        ActionForward forward = action.execute(mapping, actionForm, request, response);
       
        ActionMessages messages = (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY);
View Full Code Here

        if (action instanceof ScopedModelDriven) {
            ScopedModelDriven modelDriven = (ScopedModelDriven) action;
            Object model = modelDriven.getModel();
            if (model != null && model instanceof ActionForm) {
                Struts1Factory factory = new Struts1Factory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
                ActionMapping mapping = factory.createActionMapping(invocation.getProxy().getConfig());
                HttpServletRequest req = ServletActionContext.getRequest();
                ((ActionForm)model).reset(mapping, req);
            }
        }
        return invocation.invoke();
View Full Code Here

        if (null == itemKey)
        {
            itemKey = (String)req.getAttribute(RollerMenuModel.MENU_ITEM_KEY);
        }
       
        ActionMapping amapping = (ActionMapping)req.getAttribute(Globals.MAPPING_KEY);
        if (itemKey != null && itemKey.equals(mName))
        {
            selected = true;
        }
    else if (mForward != null && amapping != null)
    {
            ServletContext ctx = RollerContext.getServletContext();    
      ModuleConfig mConfig = RequestUtils.getModuleConfig(req, ctx);
            List fconfigs = new ArrayList();
      fconfigs.add(mConfig.findForwardConfig(mForward));
            if (mSubforwards != null) {
                String[] subforwards = mSubforwards.split(",");
                for (int i=0; i<subforwards.length; i++) {
                    fconfigs.add(mConfig.findForwardConfig(subforwards[i]));
                }
            }
            for (Iterator iter = fconfigs.iterator(); iter.hasNext();) {
                ForwardConfig fconfig = (ForwardConfig)iter.next();
                String fwdPath = fconfig.getPath();
                int end = fwdPath.indexOf(".do");
                fwdPath = (end == -1) ? fwdPath : fwdPath.substring(0, end);
                if  (fwdPath.equals(amapping.getPath()))
                {
                    selected = true;
                    break;
                }
            }
View Full Code Here

     * Renders date field by calling a JSP page.
     */
    public int doStartTag() throws JspException {
       
        // Get form name
        ActionMapping mapping =
                (ActionMapping) pageContext.getRequest().getAttribute(
                Globals.MAPPING_KEY);
        if (formName == null) {
            formName = mapping.getName();
        }
       
        // Get value of form field
        Object value =
                RequestUtils.lookup(pageContext, formName, property, null);
View Full Code Here

TOP

Related Classes of org.apache.struts.action.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.