Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

ActionForm

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.... ?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because the form already exists and is populated with form data. If you created a new one you'd have an empty form.
 
I knew I would regret that burrito. But this tiny ad has never caused regrets:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic