Hi,

if have the following classes:

abstract class Customer
{
   public String name;
   abstract public getMaximumAllowedBooks();
}

class NormalCustomer extends Customer
{
   public getMaximumAllowedBooks() { return 5; }
}

class VIPCustomer extends Customer
{
   public String name;
   public getMaximumAllowedBooks() { return 50; }
}

The method getMaximumAllowedBooks() returns the number of books a 
Customer is allowed to lend in paralell.
These classes are part of a program to manage a fictional library. It's 
not meant to make to much sense, it is just a learning application for me.
Now I have a form for an administrator to add customers. He chooses the 
type of customer from a drop down menu and enters a name. The text field 
with the name is called "customer.name" for stripes to be able to auto 
populate the form and to bind the name to the customer immediately. The 
ActionBean of the form has a property
"public Customer customer;".
Additionally there is an enum type with all available classes:
"public Customer.Type customerType;"
Problem is: I need to instantiate customer based on the information in 
customerType. But before I can read customerType I can't instantiate the 
correct class because I don't know which type. And after the 
customerType has been set by stripes it is already too late because 
stripes already tried and failed to set the customer.name property.

What would be the "best" way to deal with this?

Thank you,

Thomas

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to