aspose file tools*
The moose likes Struts and the fly likes question about  actionform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "question about  actionform" Watch "question about  actionform" New topic
Author

question about actionform

Tony Smith
Ranch Hand

Joined: Jul 07, 2007
Posts: 229
Is formbean required part of struts or is it optional? Meaning if you just design real simple app and not using form bean on purpose and send the action directly to action object, will it cause any error?

I guess formbean always gets processed first before the action object right?
[ September 24, 2007: Message edited by: Tony Smith ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
While it's theoretically possible to write a Struts application without using any form beans, the real question is: Why would anyone want to? The form bean is an integral part of Struts, and you take away most of the power of the framework if you don't use it. For one thing, you couldn't use any of the html:xxxx tags, because they all require the use of a form bean.

If you don't want to write a bunch of ActionForm beans, you still have the option of using DynaAction form and defining your fields in the struts-config.xml file.


Merrill
Consultant, Sima Solutions
Tony Smith
Ranch Hand

Joined: Jul 07, 2007
Posts: 229
I may have asked it wrong, I meant ActionForms not form beans. They are different things right? I just started learning few days ago, just trying to figuer out what is what here.

I meant to ask can we just send the action directly to action object and skip the actionforms. Of course just for testing purpose not used in real application.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Tony Smith:
I may have asked it wrong, I meant ActionForms not form beans. They are different things right?

No, they are not. The two terms are interchangeable.
Originally posted by Tony Smith:
I meant to ask can we just send the action directly to action object and skip the actionforms. Of course just for testing purpose not used in real application.

When you define an Action in your struts-config.xml, it is not required that you provide a name attribute that would like the action to an ActionForm. You can also include a <form> tag that specifies myAction.do as the action, even if that action has no ActionForm associated with it.

However, you cannot have an <html:form> tag pointing to an action that has no ActionForm. If you do so, Struts will throw an exception.

As I said before, even though it's possible, it isn't advisable to try to use Struts without ActionForms.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Tony: Welcome to the wonderful world of Struts. Are you learning Struts for work or just for fun? Since you are talking about action forms, I am guessing you are learning Struts 1.x. You might want to jump right into Struts 2.x (though 1.x is very widely used and still valid technology).

Back to your question...if you have done even a little jsp/servlet programming you would know that there is a bit of tedious work dealing with form fields and the session/request. The real power of Struts is how the action classes, actions forms and html tags work together so you don't have to deal with all the tedious stuff. I occasionally have a simple action that does not have a form, but if you are jumping into Struts programming and you are not using Action Forms then you are missing out on a lot of what Struts offers.

- Brent
Tony Smith
Ranch Hand

Joined: Jul 07, 2007
Posts: 229
"Tony: Welcome to the wonderful world of Struts. Are you learning Struts for work or just for fun?"

Hi, thanks for the comment. I am just trying to learn as much as I can so I can get a job. I just passed the SCJP, and will try to get SCWCD and learn struts. Hopefully that well at least get me a job to get started.

I think Struts 2 is pretty new right? I may be in trouble if I only know struts 2 and not struts 1. I am guessing most industry still requires you to know 1. So I will probably learn 2 later. Besides learn 1 probably helps in learning 2. Thanks Brent.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question about actionform
 
Similar Threads
FormBean for two action classes.
how to use the same form bean in two action class
Action Class - Thread safe
Passing data between beans
html:select and html:options or html:optionsCollection