Examples of FormBeanConfig


Examples of org.apache.struts.config.FormBeanConfig

        CustomFormBeanConfigArg customBase =
            new CustomFormBeanConfigArg("customBase");

        moduleConfig.addFormBeanConfig(customBase);

        FormBeanConfig customSub = new CustomFormBeanConfigArg("customSub");

        customSub.setExtends("customBase");
        moduleConfig.addFormBeanConfig(customSub);

        try {
            actionServlet.processFormBeanConfigClass(customSub, moduleConfig);
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.struts.config.FormBeanConfig

    }

    // ----------------------------------------------------- Setup and Teardown
    public void setUp() {
        // Construct a FormBeanConfig to be used
        beanConfig = new FormBeanConfig();
        beanConfig.setName("dynaForm");
        beanConfig.setType("org.apache.struts.action.DynaActionForm");

        // Add relevant property definitions
        for (int i = 0; i < dynaProperties.length; i++) {
View Full Code Here

Examples of org.apache.struts.config.FormBeanConfig

        ModuleConfig moduleConfig)
        throws IllegalAccessException, InstantiationException {
        Map scope = this.getScope(scopeName);

        ActionForm instance;
        FormBeanConfig formBeanConfig =
            moduleConfig.findFormBeanConfig(formName);

        if (formBeanConfig == null) {
            throw new IllegalArgumentException("No form config found under "
                + formName + " in module " + moduleConfig.getPrefix());
        }

        instance = (ActionForm) scope.get(formName);

        // ISSUE: Can we recycle the existing instance (if any)?
        if (instance != null) {
            getLogger().trace("Found an instance in scope " + scopeName
                + "; test for reusability");

            if (formBeanConfig.canReuse(instance)) {
                return instance;
            }
        }

        ActionForm form = formBeanConfig.createActionForm(this);

        // ISSUE: Should we check this call to put?
        scope.put(formName, form);

        return form;
View Full Code Here

Examples of org.apache.struts.config.FormBeanConfig

        String name = mapping.getName();

        assert name != null : mapping.getPath();
        if ( name == null ) return null;

        FormBeanConfig config = moduleConfig.findFormBeanConfig( name );
        ActionForm instance;

        //
        // Create the form bean.  There's special handling for dyna-form-beans.
        //
        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() + '\'' );
                }
            }
            catch ( Exception e )
            {
                _log.error( servlet.getInternal().getMessage( "formBean", config.getType() ), e );
                return null;
            }
        }
        else
        {
            try
            {
                instance = ( ActionForm ) InternalUtils.newReloadableInstance( config.getType(), getServletContext() );

                if ( _log.isDebugEnabled() )
                {
                    _log.debug( " Creating new ActionForm instance " + "of type '" + config.getType() + '\'' );
                }
            }
            catch ( Exception e )
            {
                _log.error( servlet.getInternal().getMessage( "formBean", config.getType() ), e );
                return null;
            }
        }

        instance.setServlet( servlet );
View Full Code Here

Examples of org.apache.struts.config.FormBeanConfig

        else
        {
            //
            // The form bean class couldn't be loaded at init time -- just check against the class name.
            //
            FormBeanConfig mappingFormBean = moduleConfig.findFormBeanConfig( mapping.getName() );
            String formClassName = formBeanClass.getName();

            if ( mappingFormBean != null && mappingFormBean.getType().equals( formClassName ) ) return true;

            if ( mapping instanceof PageFlowActionMapping )
            {
                String desiredType = ( ( PageFlowActionMapping ) mapping ).getFormClass();
                if ( formClassName.equals( desiredType ) ) return true;
View Full Code Here

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

Examples of org.apache.struts.config.FormBeanConfig

                _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

Examples of org.apache.struts.config.FormBeanConfig

    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

Examples of org.apache.struts.config.FormBeanConfig

            }
        }

        // 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

Examples of org.apache.struts.config.FormBeanConfig

            return (null);
        }

        // Look up the form bean configuration information to use
        String name = mapping.getName();
        FormBeanConfig config = moduleConfig.findFormBeanConfig(name);
        if (config == null) {
            log.warn("No FormBeanConfig found under '" + name + "'");
            return (null);
        }

        ActionForm instance = lookupActionForm(request, attribute, mapping.getScope());

        // Can we recycle the existing form bean instance (if there is one)?
        try {
            if (instance != null && canReuseActionForm(instance, config)) {
                return (instance);
            }
        } catch(ClassNotFoundException e) {
            log.error(servlet.getInternal().getMessage("formBean", config.getType()), e);
            return (null);
        }

        return createActionForm(config, servlet);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.