当前位置: 首页>>代码示例>>Java>>正文


Java FormBeanConfig类代码示例

本文整理汇总了Java中org.apache.struts.config.FormBeanConfig的典型用法代码示例。如果您正苦于以下问题:Java FormBeanConfig类的具体用法?Java FormBeanConfig怎么用?Java FormBeanConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormBeanConfig类属于org.apache.struts.config包,在下文中一共展示了FormBeanConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createActionForm

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p>Create and return an <code>ActionForm</code> instance appropriate to
 * the information in <code>config</code>.</p>
 *
 * <p>Does not perform any checks to see if an existing ActionForm exists
 * which could be reused.</p>
 *
 * @param config  The configuration for the Form bean which is to be
 *                created.
 * @param servlet The action servlet
 * @return ActionForm instance associated with this request
 */
public static ActionForm createActionForm(FormBeanConfig config,
    ActionServlet servlet) {
    if (config == null) {
        return (null);
    }

    ActionForm instance = null;

    // Create and return a new form bean instance
    try {
        instance = config.createActionForm(servlet);

        if (log.isDebugEnabled()) {
            log.debug(" Creating new "
                + (config.getDynamic() ? "DynaActionForm" : "ActionForm")
                + " instance of type '" + config.getType() + "'");
            log.trace(" --> " + instance);
        }
    } catch (Throwable t) {
        log.error(servlet.getInternal().getMessage("formBean",
                config.getType()), t);
    }

    return (instance);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:38,代码来源:RequestUtils.java

示例2: initialize

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p>Initialize all bean properties to their initial values, as specified
 * in the {@link FormPropertyConfig} elements associated with the
 * definition of this <code>DynaActionForm</code>.</p>
 *
 * @param mapping The mapping used to select this instance
 */
public void initialize(ActionMapping mapping) {
    String name = mapping.getName();

    if (name == null) {
        return;
    }

    FormBeanConfig config =
        mapping.getModuleConfig().findFormBeanConfig(name);

    if (config == null) {
        return;
    }

    initialize(config);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:24,代码来源:DynaActionForm.java

示例3: testProcessFormBeanConfigClassNoExtends

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * Make sure processFormBeanConfigClass() returns what it was given if the
 * form passed to it doesn't extend anything.
 */
public void testProcessFormBeanConfigClassNoExtends()
    throws Exception {
    moduleConfig.addFormBeanConfig(baseFormBean);

    FormBeanConfig result = null;

    try {
        result =
            actionServlet.processFormBeanConfigClass(baseFormBean,
                moduleConfig);
    } catch (UnavailableException e) {
        fail("An exception should not be thrown when there's nothing to do");
    }

    assertSame("Result should be the same as the input.", baseFormBean,
        result);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:22,代码来源:TestActionServlet.java

示例4: testProcessFormBeanConfigClassSubFormCustomClass

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * Make sure processFormBeanConfigClass() returns the same class instance
 * if the base config isn't using a custom class.
 */
public void testProcessFormBeanConfigClassSubFormCustomClass()
    throws Exception {
    moduleConfig.addFormBeanConfig(baseFormBean);

    FormBeanConfig customSub = new FormBeanConfig();

    customSub.setName("customSub");
    customSub.setExtends("baseForm");
    moduleConfig.addFormBeanConfig(customSub);

    FormBeanConfig result =
        actionServlet.processFormBeanConfigClass(customSub, moduleConfig);

    assertSame("The instance returned should be the param given it.",
        customSub, result);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:21,代码来源:TestActionServlet.java

示例5: testProcessFormBeanConfigClassOverriddenSubFormClass

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * Test the case where the subform has already specified its own form bean
 * config class.  If the code still attempts to create a new instance, an
 * error will be thrown.
 */
public void testProcessFormBeanConfigClassOverriddenSubFormClass()
    throws Exception {
    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) {
        fail("Exception should not be thrown");
    }
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:24,代码来源:TestActionServlet.java

示例6: createNewActionForm

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
private ActionForm createNewActionForm(ActionMapping mapping, HttpServletRequest request) {
       String name = mapping.getName();
       FormBeanConfig config = moduleConfig.findFormBeanConfig(name);
       if (config == null) {
           log.warn("No FormBeanConfig found under '" + name + "'");
           return (null);
       }
       ActionForm instance = RequestUtils.createActionForm(config, servlet);
       if ("request".equals(mapping.getScope())) {
           request.setAttribute(mapping.getAttribute(), instance);
       } else {
           HttpSession session = request.getSession();
           session.setAttribute(mapping.getAttribute(), instance);
       }
       return instance;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:KualiRequestProcessor.java

示例7: setUp

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    // set the context directory to /zeprs
    // to find the /WEB-INF/web.xml
    this.setContextDirectory(new File("webapps/zeprs"));
    this.setConfigFile("/WEB-INF/foo.xml");
    ServletConfigSimulator cfgSim = new ServletConfigSimulator();
    Enumeration initParams = cfgSim.getInitParameterNames();
    ServletContext cntx = cfgSim.getServletContext();
    DataSource dataSource = DatabaseUtils.createConnectionPool();
    cntx.setAttribute("java:comp/env/jdbc/zeprsDB", dataSource);
    // Construct a FormBeanConfig to be used
    beanConfig = new FormBeanConfig();
    beanConfig.setName("dynaForm");
    beanConfig.setType("org.apache.struts.action.DynaActionForm");
    // zeprsDatasource = DatabaseUtils.createConnectionPool();
}
 
开发者ID:chrisekelley,项目名称:zeprs,代码行数:18,代码来源:CreatePatientRecordTest.java

示例8: setUp

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    // set the context directory to /zeprs
    // to find the /WEB-INF/web.xml
    this.setContextDirectory(new File("webapps/zeprs"));
    this.setConfigFile("/WEB-INF/strutstest.xml");
    ServletConfigSimulator cfgSim = new ServletConfigSimulator();
    Enumeration initParams = cfgSim.getInitParameterNames();
    ServletContext cntx = cfgSim.getServletContext();
    // set the book into the action form
    //bookEditForm = new BookEditForm();
    //bookEditForm.setBook(new Book(1, "laliluna", "StrutsTestCases Tutorial", true));

    // set the form data in the action form
    // ActionForm form

    form4 = new DynaValidatorForm();
    form4.getDynaClass();

    // Construct a FormBeanConfig to be used
    beanConfig = new FormBeanConfig();
    beanConfig.setName("dynaForm");
    beanConfig.setType("org.apache.struts.action.DynaActionForm");

}
 
开发者ID:chrisekelley,项目名称:zeprs,代码行数:26,代码来源:SafeMotherhoodActionTest.java

示例9: removeFormBeanConfig

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * Remove the specified form bean configuration instance.
 *
 * @param config FormBeanConfig instance to be removed
 *
 * @exception IllegalStateException if this module configuration
 *  has been frozen
 */
public void removeFormBeanConfig(FormBeanConfig config) {

    if (configured) {
        throw new IllegalStateException("Configuration is frozen");
    }
    formBeans.remove(config.getName());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ModuleConfigImpl.java

示例10: createActionForm

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p>Create (if necessary) and return an <code>ActionForm</code> instance appropriate
 * for this request.  If no <code>ActionForm</code> instance is required, return
 * <code>null</code>.</p>
 *
 * @param request The servlet request we are processing
 * @param mapping The action mapping for this request
 * @param moduleConfig The configuration for this module
 * @param servlet The action servlet
 *
 * @return ActionForm instance associated with this request
 */
public static ActionForm createActionForm(
        HttpServletRequest request,
        ActionMapping mapping,
        ModuleConfig moduleConfig,
        ActionServlet servlet) {

    // Is there a form bean associated with this mapping?
    String attribute = mapping.getAttribute();
    if (attribute == null) {
        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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:RequestUtils.java

示例11: canReuseActionForm

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p>Determine whether <code>instance</code> of <code>ActionForm</code> is
 * suitable for re-use as an instance of the form described by
 * <code>config</code>.</p>
 * @param instance an instance of <code>ActionForm</code> which was found,
 * probably in either request or session scope.
 * @param config the configuration for the ActionForm which is needed.
 * @return true if the instance found is "compatible" with the type required
 * in the <code>FormBeanConfig</code>; false if not, or if <code>instance</code>
 * is null.
 * @throws ClassNotFoundException if the <code>type</code> property of
 * <code>config</code> is not a valid Class name.
 */
private static boolean canReuseActionForm(ActionForm instance, FormBeanConfig config)
        throws ClassNotFoundException
{
    if (instance == null) {
        return (false);
    }

    boolean canReuse = false;
    String formType = null;
    String className = null;

    if (config.getDynamic()) {
        className = ((DynaBean) instance).getDynaClass().getName();
        canReuse = className.equals(config.getName());
        formType = "DynaActionForm";
    } else {
        Class configClass = applicationClass(config.getType());
        className = instance.getClass().getName();
        canReuse = configClass.isAssignableFrom(instance.getClass());
        formType = "ActionForm";
    }

    if (log.isDebugEnabled()) {
        log.debug(
                " Can recycle existing "
                + formType
                + " instance "
                + "of type '"
                + className
                + "'?: "
                + canReuse);
        log.trace(" --> " + instance);
    }
    return (canReuse);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:RequestUtils.java

示例12: initialize

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p>Initialize all bean properties to their initial values, as specified
 * in the {@link FormPropertyConfig} elements associated with the
 * definition of this <code>DynaActionForm</code>.</p>
 *
 * @param mapping The mapping used to select this instance
 */
public void initialize(ActionMapping mapping) {

    String name = mapping.getName();
    if (name == null) {
        return;
    }
    FormBeanConfig config =
        mapping.getModuleConfig().findFormBeanConfig(name);
    if (config == null) {
        return;
    }

    initialize(config);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:DynaActionForm.java

示例13: introspect

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p>Introspect our form bean configuration to identify the supported
 * properties.</p>
 *
 * @param config The FormBeanConfig instance describing the properties
 *  of the bean to be created
 *
 * @exception IllegalArgumentException if the bean implementation class
 *  specified in the configuration is not DynaActionForm (or a subclass
 *  of DynaActionForm)
 */
protected void introspect(FormBeanConfig config) {

    this.config = config;

    // Validate the ActionFormBean implementation class
    try {
        beanClass = RequestUtils.applicationClass(config.getType());
    } catch (Throwable t) {
        throw new IllegalArgumentException
            ("Cannot instantiate ActionFormBean class '" +
             config.getType() + "': " + t);
    }
    if (!DynaActionForm.class.isAssignableFrom(beanClass)) {
        throw new IllegalArgumentException
            ("Class '" + config.getType() + "' is not a subclass of " +
             "'org.apache.struts.action.DynaActionForm'");
    }

    // Set the name we will know ourselves by from the form bean name
    this.name = config.getName();

    // Look up the property descriptors for this bean class
    FormPropertyConfig descriptors[] = config.findFormPropertyConfigs();
    if (descriptors == null) {
        descriptors = new FormPropertyConfig[0];
    }

    // Create corresponding dynamic property definitions
    properties = new DynaProperty[descriptors.length];
    for (int i = 0; i < descriptors.length; i++) {
        properties[i] =
            new DynaProperty(descriptors[i].getName(),
                             descriptors[i].getTypeClass());
        propertiesMap.put(properties[i].getName(),
                          properties[i]);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:DynaActionFormClass.java

示例14: reset

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
public void reset(ActionMapping mapping, HttpServletRequest request) {
    log.debug("reset");
    super.reset(mapping, request);
    try {
        InstanciaDelegate delegate = RegistroManager.recuperarInstancia(request);
        Pantalla pantalla = delegate.obtenerPantalla();

        FormBeanConfig config = new FormBeanConfig();
        config.setName("p_" + pantalla.getId());
        config.setType(this.getClass().getName());
        config.setModuleConfig(mapping.getModuleConfig());

        for (int i = 0; i < pantalla.getCampos().size(); i++) {
            Campo campo = (Campo) pantalla.getCampos().get(i);
            config.addFormPropertyConfig(getCampoConfig(campo));
        }

        // Aix� nomes s'hauria de fer quan desde el back s'actualitza una pantalla - camp.
        // per poder aprofitar el cache the dynaClass.
        DynaActionFormClass.clear();
        dynaClass = DynaActionFormClass.createDynaActionFormClass(config);

        FormPropertyConfig props[] = config.findFormPropertyConfigs();
        for (int i = 0; i < props.length; i++) {
            this.set(props[i].getName(), props[i].initial());
        }

        // Preparar resources de validacion
        ServletContext application = getServlet().getServletContext();
        DynValidatorResources resources =
                (DynValidatorResources) Resources.getValidatorResources(application, request);
        resources.setPantalla(pantalla);

    } catch (DelegateException e) {
        log.error("Excepci�n en reset", e);
    } catch (Throwable t) {
        log.error("Error en reset", t);
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:40,代码来源:PantallaForm.java

示例15: findOrCreateActionForm

import org.apache.struts.config.FormBeanConfig; //导入依赖的package包/类
/**
 * <p> In the context of the given <code>ModuleConfig</code> and this
 * <code>ActionContext</code>, look for an existing
 * <code>ActionForm</code> in the specified scope. If one is found, return
 * it; otherwise, create a new instance, add it to that scope, and then
 * return it. </p>
 *
 * @param formName  The name attribute of our ActionForm
 * @param scopeName The scope identier (request, session)
 * @return The ActionForm for this request
 * @throws IllegalAccessException   If object cannot be created
 * @throws InstantiationException   If object cannot be created
 * @throws IllegalArgumentException If form config is missing from module
 *                                  or scopeName is invalid
 */
public ActionForm findOrCreateActionForm(String formName, String scopeName,
    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;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:49,代码来源:ActionContextBase.java


注:本文中的org.apache.struts.config.FormBeanConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。