Another solution would be to put all the complexity of managing items into a
general CartPanel class, but that wont get much cleaner I guess. One thing
that comes to mind is, If you have a Pricing domain object to handle pricing
issues, and a Summary object to handle the items summary , you can somehow
get rid of the inheritance hierarchy and manage them with a single Item
class at the top, and two dependent objects(Pricing and Summary). The actual
smell I sniff in your code is the parallel inheritance hierarchies in the
domain objects and UI. Thats what forces you to use a factory.

On 3/1/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:

On 2/28/07, Scott Swank <[EMAIL PROTECTED]> wrote:
> In our application we have several places where we are construction an
> html table but the content of the rows varies by ProductType.  For
> example:
>
> column 1. always an image
> column 2. the pricing: for hotels by room, for shows by ticket, for
> limo by hours
> column 3. item summary: for hotels the rooms/nights, for shows the
> seats and show time, etc
> column 4. the total
>
> There is a natural class hierarchy here where we have
>
> AbstractItem
>   HotelItem
>   ShowItem
>   LimoItem
>
> I'd like to have a comparable hierarchy of perhaps "RepeaterRow"
> objects that could have methods such as:
>
> AbstractItemRow
>   protected abstract Panel getPricingPanel();
>   protected abstract Panel getSummaryPanel();
>
> I've gotten this working with a ListView, but I'm doing things like:
>
>   populateItem(ListItem listItem) {
>     final AbstractItem cartItem =
(AbstractItem)listItem.getModelObject();
>     add(CartPanelFactory.getPricingPanel(cartItem));
>     add(CartPanelFactory.getSummaryPanel(cartItem));
>   }
>
> Is there a cleaner way than delegating this decision about which Panel
> I need to a factory?

That looks like a fine pattern to me tbh. What don't you like about it?

Eelco

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to