• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can I extend 2 forms in struts

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts newbie here who needs your help.

I need to design a page with 2 sections.
Section A is is similar to an existing page, while section B is similar to another existing page.

Can I design this page such that the Form bean for it extends the Form beans for pages A and B.

Can I say something like:
public final class myNewForm
extends myFirstForm, mySecondForm

Thank you.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a Struts forum -- I'll move this thread there for you.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, Java does not allow multiple inheritance.

Using containment might help you (myNewForm would contain and instance variable of type myFirstForm and an instance variable of type mySecondForm with get and set methods to access the contained forms). Rather than containing objects that both extend ActionForm, it might be cleaner to contain objects that are simple Java Beans. It might be easier to just cut and paste the needed properties.

- Brent
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you can't do this. Java doesn't allow multiple inheritance.

Don't over-think ActionForm beans. They're just simple JavaBeans and they're not part of the model. The only important thing is that they match what's on the page. If I were you, I'd just cut and paste the properties I need from either of the two form beans into your new form bean.

While I'd normally frown on "design by cut and paste", in this case I think it's the best solution.
reply
    Bookmark Topic Watch Topic
  • New Topic