struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ahearn, Denis" <>
Subject Problems subclassing FormBeanConfig
Date Tue, 03 Dec 2002 17:13:40 GMT
I ran into a problem trying to subclass
org.apache.struts.config.FormBeanConfig.  Here is essentially what I was

<form-bean name="myForm" dynamic="true"

public class MyFormBeanConfig extends

The error I was getting was a "Cannot find message resources under key"
exception.  After removing the use of bean:message tags from my login page,
I then saw the true error, "ClassCastException for
mycompany.MyFormBeanConfig".  This led me to the following code in

     * Perform backwards-compatible configuration of an ActionFormBeans
     * collection, and expose it as a servlet context attribute (as was
     * used in Struts 1.0).  Note that the current controller code does
     * not (and should not) reference this attribute for any reason.
     * @param config The ApplicationConfig object for the default app
     * @since Struts 1.1
     * @deprecated Will be removed in a release after Struts 1.1.
    private void defaultFormBeansConfig(ApplicationConfig config) {

        FormBeanConfig fbcs[] = config.findFormBeanConfigs();
        ActionFormBeans afb = new ActionFormBeans();
        for (int i = 0; i < fbcs.length; i++) {
            afb.addFormBean((ActionFormBean) fbcs[i]);
        getServletContext().setAttribute(Action.FORM_BEANS_KEY, afb);


Since this code blindly casts a FormBeanConfig to an ActionFormBean, I
really needed to subclass from ActionFormBean instead of FormBeanConfig

The documentation for the "form-bean" element in
<>   seems
misleading in that it states that if you specify "className" for a
form-bean" element, that the object must be a subclass of

Just a heads up in case anyone wants to use the <set-property> element with
a <form-bean> element, and needs to subclass FormBeanConfig to do so.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message