Unless I'm missing something, it looks like this will have the
same problem I've been battling.  After the loop executes and the zone is
updated, the purchaseRequest, in this case, will always be the last
purchaseRequest encountered by the loop.  Please correct me if I am
incorrect.

At this time, I've decided to resort to writing some javascript, instead of
using a zone update, to change the choices in my 2nd select when the value
of the 1st select changes.

On Tue, Jul 12, 2011 at 7:34 AM, George Christman
<gchrist...@cardaddy.com>wrote:

> Ray, I'm not sure if this helps, but here is an example of a AjaxFormLoop
> with a nested select / zone and nested within the zone is another select.
> The tempId in the value encoder is just a @Transient UUID generated from
> your entity class. Hope it helps.
>
>
>        <t:AjaxFormLoop source="purchaseRequests" value="purchaseRequest"
> encoder="encoder">
>            <t:TextField value="purchaseRequest.name"/>
>            <t:Select value="purchaseRequest.parentState"
> model="parentStateModel" zone="prop:loopZoneId"/>
>            <t:Zone t:id="loopZone" id="prop:loopZoneId">
>                <t:Select value="purchaseRequest.parentState"
> model="parentStateModel"/>
>            </t:Zone>
>        </t:AjaxFormLoop>
>
>
>
>
>
>    @Inject
>    private Session session;
>
>    @Property
>    private List<PurchaseRequest> purchaseRequests;
>
>    @Persist
>    @Property
>    private PurchaseRequest purchaseRequest;
>
>    @Persist
>    @Property
>    private SelectModel parentStateModel;
>
>    @Inject
>    private SelectModelFactory selectModelFactory;
>
>    @InjectComponent
>    private Zone loopZone;
>
>    private List<ParentState> parentStates;
>
>    void onPrepare() {
>        purchaseRequests =
> session.createCriteria(PurchaseRequest.class).list();
>
>        parentStates = session.createCriteria(ParentState.class).list();
>        parentStateModel = selectModelFactory.create(parentStates, "label");
>    }
>
>    @SuppressWarnings("unchecked")
>    public ValueEncoder getEncoder() {
>        return new ValueEncoder<PurchaseRequest>() {
>            public String toClient(PurchaseRequest value) {
>                Long key = value.getTempId();
>                return key.toString();
>            }
>
>            public PurchaseRequest toValue(String keyAsString) {
>                Long key = new Long(keyAsString);
>                for (PurchaseRequest holder : purchaseRequests) {
>                    if (holder.getTempId() == key) {
>                        return holder;
>                    }
>                }
>                return null;
>            }
>        };
>    }
>
>    PurchaseRequest onAddRow() {
>        PurchaseRequest newPurchaseRequest = new PurchaseRequest();
>        return newPurchaseRequest;
>    }
>
>    Object onValueChanged() {
>        return loopZone.getBody();
>    }
>
>    public String getLoopZoneId() {
>        return "purchaseRequest-" + getEncoder().toClient(purchaseRequest);
>    }
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4578714.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to