Package org.apache.struts.config

Examples of org.apache.struts.config.FormBeanConfig


        FormBeanConfig[] formBeans = moduleConfig.findFormBeanConfigs();
        ReloadableClassHandler rch = _handlers.getReloadableClassHandler();
       
        for ( int i = 0; i < formBeans.length; i++ )
        {
            FormBeanConfig formBeanConfig = formBeans[i];
            String formType = InternalUtils.getFormBeanType( formBeanConfig );
           
            try
            {
                Class formBeanClass = rch.loadClass( formType );
                _formBeanClasses.put( formBeanConfig.getName(), formBeanClass );
            }
            catch ( ClassNotFoundException e )
            {
                _log.error( "Could not load class " + formType + " referenced from form bean config "
                            + formBeanConfig.getName() + " in Struts module " + moduleConfig );
            }
        }
    }
View Full Code Here


                _beanScope = "session";
            return;
        }

        // Look up the form bean definition
        FormBeanConfig formBeanConfig = _appConfig.findFormBeanConfig(_mapping.getName());
        if (formBeanConfig == null) {
            // clear any _beanType
            _beanType = null;
        }
        else {
            // Calculate the required values
            _beanName = _mapping.getAttribute();
            _beanScope = _mapping.getScope();
            _beanType = formBeanConfig.getType();
        }
    }
View Full Code Here

    public static ActionForm createActionForm( ActionMapping mapping, ModuleConfig moduleConfig,
                                               ActionServlet actionServlet, ServletContext servletContext )
    {
        String formName = mapping.getName();
        if ( formName == null ) return null;
        FormBeanConfig config = moduleConfig.findFormBeanConfig( formName );
        if ( config == null ) return null;
       
        try
        {
            ActionForm bean;
           
            if ( config.getDynamic() )
            {
                if ( _log.isDebugEnabled() )
                {
                    _log.debug( "Creating new DynaActionForm instance of type " + config.getType() );
                }
               
                DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass( config );
                bean = ( ActionForm ) dynaClass.newInstance();
                ( ( DynaActionForm ) bean ).initialize( mapping );
            }
            else
            {
                if ( _log.isDebugEnabled() )
                {
                    _log.debug( "Creating new ActionForm instance of type " + config.getType() );
                }
               
                bean = ( ActionForm ) newReloadableInstance( config.getType(), servletContext );
            }
           
            bean.setServlet( actionServlet );
            return bean;
        }
        catch ( Exception e )
        {
            if ( _log.isErrorEnabled() )
            {
                _log.error( "Error creating action form of type " + config.getType(), e );
            }
           
            return null;
        }
    }
View Full Code Here

            }
        }

        // Force creation and registration of DynaActionFormClass instances
        // for all dynamic form beans we wil be using
        FormBeanConfig fbs[] = moduleConfig.findFormBeanConfigs();
        for ( int i = 0; i < fbs.length; i++ )
        {
            if ( fbs[i].getDynamic() )
            {
                DynaActionFormClass.createDynaActionFormClass( fbs[i] );
View Full Code Here

            return (null);
        }

        // Look up the form bean configuration information to use
        String name = mapping.getName();
        FormBeanConfig config = moduleConfig.findFormBeanConfig(name);
        if (config == null) {
            return (null);
        }

        // Look up any existing form bean instance
        if (log.isDebugEnabled()) {
            log.debug(
                " Looking for ActionForm bean instance in scope '"
                    + mapping.getScope()
                    + "' under attribute key '"
                    + attribute
                    + "'");
        }
        ActionForm instance = null;
        HttpSession session = null;
        if ("request".equals(mapping.getScope())) {
            instance = (ActionForm) request.getAttribute(attribute);
        } else {
            session = request.getSession();
            instance = (ActionForm) session.getAttribute(attribute);
        }

        // Can we recycle the existing form bean instance (if there is one)?
        if (instance != null) {
            if (config.getDynamic()) {
                String className = ((DynaBean) instance).getDynaClass().getName();
                if (className.equals(config.getName())) {
                    if (log.isDebugEnabled()) {
                        log.debug(
                            " Recycling existing DynaActionForm instance "
                                + "of type '"
                                + className
                                + "'");
                        log.trace(" --> " + instance);
                    }
                    return (instance);
                }
            } else {
                try {
                    Class configClass = applicationClass(config.getType());
                    if (configClass.isAssignableFrom(instance.getClass())) {
                        if (log.isDebugEnabled()) {
                            log.debug(
                                " Recycling existing ActionForm instance "
                                    + "of class '"
                                    + instance.getClass().getName()
                                    + "'");
                            log.trace(" --> " + instance);
                        }
                        return (instance);
                    }
                    return (instance);
                } catch (Throwable t) {
                    log.error(servlet.getInternal().getMessage("formBean", config.getType()), t);
                    return (null);
                }
            }
        }

        // Create and return a new form bean instance
        if (config.getDynamic()) {
            try {
                DynaActionFormClass dynaClass =
                    DynaActionFormClass.createDynaActionFormClass(config);
                instance = (ActionForm) dynaClass.newInstance();
                ((DynaActionForm) instance).initialize(mapping);
                if (log.isDebugEnabled()) {
                    log.debug(
                        " Creating new DynaActionForm instance "
                            + "of type '"
                            + config.getType()
                            + "'");
                    log.trace(" --> " + instance);
                }
            } catch (Throwable t) {
                log.error(servlet.getInternal().getMessage("formBean", config.getType()), t);
                return (null);
            }
        } else {
            try {
                instance = (ActionForm) applicationInstance(config.getType());
                if (log.isDebugEnabled()) {
                    log.debug(
                        " Creating new ActionForm instance "
                            + "of type '"
                            + config.getType()
                            + "'");
                    log.trace(" --> " + instance);
                }
            } catch (Throwable t) {
                log.error(servlet.getInternal().getMessage("formBean", config.getType()), t);
                return (null);
            }
        }
        instance.setServlet(servlet);
        return (instance);
View Full Code Here

            }
        }

        // Force creation and registration of DynaActionFormClass instances
        // for all dynamic form beans we wil be using
        FormBeanConfig fbs[] = config.findFormBeanConfigs();
        for (int i = 0; i < fbs.length; i++) {
            if (fbs[i].getDynamic()) {
                DynaActionFormClass.createDynaActionFormClass(fbs[i]);
            }
        }
View Full Code Here

     * @since Struts 1.1
     * @deprecated Will be removed in a release after Struts 1.1.
     */
    private void defaultFormBeansConfig(ModuleConfig config) {

        FormBeanConfig fbcs[] = config.findFormBeanConfigs();
        ActionFormBeans afb = new ActionFormBeans();
        afb.setFast(false);
        for (int i = 0; i < fbcs.length; i++) {
            afb.addFormBean((ActionFormBean) fbcs[i]);
        }
View Full Code Here

        String name = mapping.getName();
        if (name == null) {
            return;
        }
        FormBeanConfig config =
            mapping.getModuleConfig().findFormBeanConfig(name);
        if (config == null) {
            return;
        }
        FormPropertyConfig props[] = config.findFormPropertyConfigs();
        for (int i = 0; i < props.length; i++) {
            set(props[i].getName(), props[i].initial());
        }

    }
View Full Code Here

            beanType = type;
            return;
        }

        // Look up the form bean definition
        FormBeanConfig formBeanConfig = moduleConfig.findFormBeanConfig(mapping.getName());
        if (formBeanConfig == null) {
            JspException e =
                new JspException(messages.getMessage("formTag.formBean", mapping.getName()));
            pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
            throw e;
        }

        // Calculate the required values
        beanName = mapping.getAttribute();
        beanScope = mapping.getScope();
        beanType = formBeanConfig.getType();
    }
View Full Code Here

     *
     * @deprecated Will be removed in a release after Struts 1.1.
     */
    private void defaultFormBeansConfig(ApplicationConfig config) {

        FormBeanConfig fbcs[] = config.findFormBeanConfigs();
        ActionFormBeans afb = new ActionFormBeans();
        afb.setFast(false);
        for (int i = 0; i < fbcs.length; i++) {
            afb.addFormBean((ActionFormBean) fbcs[i]);
        }
View Full Code Here

TOP

Related Classes of org.apache.struts.config.FormBeanConfig

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.