aspose file tools*
The moose likes Struts and the fly likes ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForm" Watch "ActionForm" New topic
Author

ActionForm

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
public class RegisterForm extends ActionForm

{

}

I have this in my execute method of the Action class :

Registerform rf = (RegisterForm) form; // what exactly is happening here ?

RegisterForm is not an abstract class then , why can we not create an instance of Registerform ? Also I read "The base ActionForm class cannot be instantiated". Is it because the ActionForm class is mentioned as abstract in the api docs :
public abstract class ActionForm extends Object implements Serializable

Is the ActionForm a javabean ?? If yes what are the rules/specifcation for a javabean ? Are there any datatype an ActionForm can/cannot take. Few rules for a class to be a java bean are :

1. must have getters and setters
2. must implement Serializable.
3.... ?
4.... ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

> Registerform rf = (RegisterForm) form; // what exactly is happening here ?

What do you mean? The form is being cast to an instance of RegisterForm.

> why can we not create an instance of Registerform

What makes you think you can't?

> Is the ActionForm a javabean

It *could* be, but doesn't have to be:

http://en.wikipedia.org/wiki/JavaBean
http://struts.apache.org/1.2.7/api/org/apache/struts/action/ActionForm.html

I don't understand the rest of your JavaBean questions.
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
I would like to know why is the ActionForm(org.apache.struts.action.ActionForm) class created as an abstract class , whereas the action(org.apache.struts.action) is not abstract ?

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
H David Newton,

public class RegisterForm extends ActionForm

{

}

Registerform rf = (RegisterForm) form;

I read this in "Struts in Action", so not sure why we are not creating an instance of the Registerform like :
Registerform rf = new Registerform();

Thanks for the two links that you provided.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Because the form already exists and is populated with form data. If you created a new one you'd have an empty form.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ActionForm
 
Similar Threads
can't typecasting in struts??
How to use class in same package
taglib in JSP not working in struts
ActionForm subclasses have to implement Serializable?
Whats wrong here? 'PACKAGE'