It turns out there is a simple way to do this. So simple I was
overlooking it. When you create a multizone update you give it the
client id and the zone you wish to update.  The zone will render with
the present context. However, you can also simply give it a string
with the contents you want rendered.  So something like:


        MultiZoneUpdate update = new MultiZoneUpdate("totalPriceZone",
totalPriceZone);
        for (Item aitem : getItems()) {
           update =  update.add("priceZone-" + aItem.getId(),
getTotalPriceForItem(aItem)); <-- important part
        }
        return update;

Where getTotalPriceForItem returns a string that is the total price
for the row containing aItem.

Thanks for everyone's help.

Mark




On Tue, Jan 11, 2011 at 11:35 AM, Mark <mark-li...@xeric.net> wrote:
> I have a form with a loop that looks something like this:
>
> |__QTY__|_ITEM__|__PRICE__|
> |__1_____|_soup__|____$1____|
> |__3_____|_peas__|____$3____|
> etc.
>
> Users can change the quantity and it automatically changes the price.
> Each price is in its own zone and the KeyUp action on the
> cooresponding QTY causes that price zone to update. (I'm using the
> zoneUpdater described at
> http://tinybits.blogspot.com/2010/03/new-and-better-zoneupdater.html)
>
> Now the requirements have changed and we need to be able to offer a
> discount based on the number of items being purchased.  This means
> that an update to the soup row will sometimes need to change not only
> the price soup row, but also the peas row. At first I tried building a
> MultiZoneUpdate (Thank you for your help Josh), but that just sets
> every price to the same thing as the row that is being updated. This
> is because the context of the row/event that triggered the updated
> doesn't provide the context for the zones that need to be updated. If
> I change the Qty of soup to 2, the soup item is the context for that
> update, so when I update the row for peas, that zone doesn't know
> anything about peas--only soup.
>
> So my question is:
> How can I access an item from the context when the zone was rendered
> instead of the context of the section that is triggering the zone
> update.
>
> It seems like I could solve this if each zone was rendered with a
> context that could be used when an update was triggered on that zone.
> Something like:
> <t:zone t:context="item" t:id="priceZone" id="priceZoneId">
> ${itemSubtotal}</t:zone>
>
> The idea being, that when you update a zone, it can figure out the
> context at which the zone was originally created and not just the
> context of the event firing the update. (Of course I don't know how
> this would work on the Java side of things.)
>
> Is there a way to do something like this?  Is there a different way to
> do it that I've just overlooked and I'm making things harder than they
> need to be?
>
> Mark
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to