History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: STR-2894
Type: Bug Bug
Status: Closed Closed
Resolution: Not A Problem
Priority: Major Major
Assignee: Unassigned
Reporter: Wendy Smoak
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts 1

The <form-bean> type attribute should be optional

Created: 26/Jun/06 03:56 AM   Updated: 03/Jul/07 08:36 PM
Component/s: Core
Affects Version/s: Nightly Build
Fix Version/s: 1.3.6

File Attachments:
  Size
Zip Archive my-webapp.zip 2006-06-26 04:24 AM Wendy Smoak 6 kb


 Description  « Hide
According to the 1.3 DTD, the 'type' attribute of <form-bean> is optional.
   http://struts.apache.org/dtds/struts-config/1_3/

However, omitting it from the form bean definition in struts-config.xml results in an error.

        <form-bean
            name="inputForm" />

SEVERE: Servlet /my-webapp threw load() exception
javax.servlet.UnavailableException: Missing type value for inputForm form bean
at org.apache.struts.action.ActionServlet.handleValueRequiredException(ActionServlet.java:830)
at org.apache.struts.action.ActionServlet.initModuleFormBeans(ActionServlet.java:926)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:357)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)



 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Wendy Smoak - 26/Jun/06 03:57 AM
s/element/attribute

Wendy Smoak - 26/Jun/06 04:24 AM
Attached a sample Maven 2 project based on the struts-blank archetype which demonstrates the problem.

To reproduce:
 1. extract the zip file to a temporary location,
 2. modify pom.xml <container>/<home> with the path to a local install of Tomcat 5x
 3. mvn package cargo:start
 4. CTRL-C to stop the container
 5. look at target/tomcat5x.out for the stack trace

Wendy Smoak - 26/Aug/06 08:41 PM
TODO: Update the sample app. It no longer builds. It was done when the groupId was org.apache.struts.action, and those artifacts have been removed from the snapshot repo.

Paul Benedict - 18/Nov/06 09:08 AM
Wendy,

I see the offending line in the ActionServlet on line 927 (and again on 939):

            // Verify that required fields are all present for the form config
            if (formBean.getType() == null) {
                handleValueRequiredException("type", formBean.getName(),
                    "form bean");
            }

Are you asking to delete that line?

Since the type is optional. What is the type when it is not explicilty stated?

Wendy Smoak - 19/Nov/06 10:18 AM
It's been so long that I don't really remember.

The main issue is that the documentation doesn't match the actual behavior. The DTD says the type attribute is optional, but you get an error if you leave it out.

Martin Cooper - 19/Nov/06 11:11 AM
The type attribute on <form-bean> was made optional with Hubert's 'extends' changes. It's not entirely optional insofar as every actual form bean has to have the type attribute specified. However, it's optional insofar you can omit it from any given level in the extension hierarchy, so long as it exists at least once in that hierarchy. So I believe this bug report is invalid, but someone please correct me if I'm wrong.

Paul Benedict - 19/Nov/06 11:23 AM
Thanks Wendy and Martin. So if both the "type" and "extends" attribute are absent, throw the error? That's a good business rule.

Wendy Smoak - 19/Nov/06 11:32 AM
Resolving as invalid. Thanks to Martin for the explanation.

Martin Cooper - 19/Nov/06 11:44 AM
Not quite, Paul. I could define a "base" form bean that has neither, such that a later 'extends' form bean adds the 'type' attribute. The rule would have to be that every concrete form bean - those actually referenced / used - ultimately has a type attribute provided somewhere in its definition hierarchy.