I need multi page forms for multiple forms with a common ancester.Help
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nuno_Rodrigues
Posted On:   Wednesday, August 17, 2005 02:47 PM

Hi, i'm a newbie to struts and i'm facing an uncommon problem. I have a 2 level type of products that i need to use.Simple products use only the common attributes of all products (ex:price,name,etc) and the second level, for complex products, adds the specific product attributes (ex:volume). CommonProduct(ALL) String category (ex:Drink,Audio,etc-IF NULL means its a simple product) String name int price DrinkProduct(extends CommonProduct) int volume AudioProduct (extends CommonProduct) int minutes ... For the complex products creation/update purposes i need to use a   More>>

Hi, i'm a newbie to struts and i'm facing an uncommon problem.
I have a 2 level type of products that i need to use.Simple products use only the common attributes of all products (ex:price,name,etc) and the second level, for complex products, adds the specific product attributes (ex:volume).


CommonProduct(ALL)


String category (ex:Drink,Audio,etc-IF NULL means its a simple product)


String name


int price



DrinkProduct(extends CommonProduct)


int volume



AudioProduct (extends CommonProduct)


int minutes


...


For the complex products creation/update purposes i need to use at least two forms (commonProductsForm + specificProductsForm) and i only know which specific form to use from the "category" field in the first form. Which is the best pratice (versus the simplest) to achieve this ?


In the forms i've made the specificProductsForm to extend the commonProductsForm.
Sorry if this looks messy...
Thanks

   <<Less

Re: I need multi page forms for multiple forms with a common ancester.Help

Posted By:   alan_do  
Posted On:   Wednesday, August 17, 2005 04:22 PM

this not an uncommon issue, but rather there isn't a common solution for it. there are several ways you can do this (i am assuming you're using declarative form-bean, e.g DynaActionForm).


1. you can add one additional attribute to your form bean definition:




in this approach you need to define a ProductAttribute object (may contain attributeName, attributeValue) and manipulate the arrays of objects using struts indexed properties features. if you are not using declarative form-bean, you can still add the array of ProductAttribute to your commonProductsForm. the apache struts user guide and plenty of other online resources will show you how indexed properties work. btw, it should be CommonProductsForm (upper case C) since it's a class, not a method.


2. you can modify your ActionServlet and create a InheritableDynaValidatorForm which allows for you to extend a form-bean definition declaratively. this is rather complicated and required very keen advance understanding of struts. i have the codes for this, but i do not encourage it. - alan

About | Sitemap | Contact