You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ray Nicholus <rn...@widen.com> on 2011/07/11 17:49:36 UTC

updating a zone inside of an ajaxformloop

Here is a fragment of some template code inside of a tapestry form:

<t:ajaxformloop t:id="existingAutoImportSettings" source="existingSettings"
value="currentSetting">
 <t:label for="typeSelect"/>
<t:select t:id="typeSelect" zone="fileMetadataSelectZone"
value="currentSetting.fileMetadataType" label="${message:type}"/>

<t:zone t:id="fileMetadataSelectZone">
<t:label for="fileMetadataSelect"/>
 <t:select t:id="fileMetadataSelect"
value="currentSetting.fileMetadataObject"
  model="autoImportFileMetadataModel" label="${message:file-metadata}"/>
 </t:zone>

                                          ..........

</t:ajaxformloop>

<input type="submit" value="Update"/>


As soon as I add the zone parameter to the 1st select & reload, I get a NPE
when I attempt to change the value in the 1st select.  It claims that the
currentSetting value is null when attempting to evaluate
currentSetting.fileMetadataType.

What am I doing wrong?

Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
I do not need to persist the "currentSettings" variable?

On Mon, Jul 11, 2011 at 11:45 AM, George Christman
<gc...@cardaddy.com>wrote:

> I think your going to want to set a unique id for your
> fileMetadataSelectZone
> Zone example <t:zone t:id="fileMetadataSelectZone" id="prop:zoneID">
>
> and your going to need to persist autoImportFileMetadataModel selectModel.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4575734.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
I'm also not quite sure how I can set a unique ID to my zone and then
retrieve this zone id in the previous select.

On Mon, Jul 11, 2011 at 11:45 AM, George Christman
<gc...@cardaddy.com>wrote:

> I think your going to want to set a unique id for your
> fileMetadataSelectZone
> Zone example <t:zone t:id="fileMetadataSelectZone" id="prop:zoneID">
>
> and your going to need to persist autoImportFileMetadataModel selectModel.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4575734.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: updating a zone inside of an ajaxformloop

Posted by George Christman <gc...@cardaddy.com>.
I think your going to want to set a unique id for your fileMetadataSelectZone
Zone example <t:zone t:id="fileMetadataSelectZone" id="prop:zoneID">

and your going to need to persist autoImportFileMetadataModel selectModel. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4575734.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: updating a zone inside of an ajaxformloop

Posted by George Christman <gc...@cardaddy.com>.
could you post your code? Also, are you using hibernate?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4575918.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: updating a zone inside of an ajaxformloop

Posted by Mark <ma...@xeric.net>.
Ray,

I think the ValueEncoder is doing what you are looking for in George's
example.  When the loop is rendered the encoder helps figure out a
unique id to encode into the form so that when you make a change an
trigger the zone update, that id is handed back to the encoder and it
sets purchaseRequest back to the value it was when the form originally
rendered that iteration of the loop.

So to answer your question, no.  The purchaseRequest isn't set to the
last instance it encountered--it gets reset to whatever it was at that
particular point in time.

Does that help?

Mark

On Tue, Jul 12, 2011 at 2:24 PM, Ray Nicholus <rn...@widen.com> wrote:
> When the select in your loopZone reloads after the zone update, it uses
> purchaseRequest to determine it's value.  However, after the loop has
> already executed, purchaseRequest, which you persist, points to the last
> purchaseRequest instant enountered by the ajaxformloop.  Correct?
>
> On Tue, Jul 12, 2011 at 2:14 PM, George Christman
> <gc...@cardaddy.com>wrote:
>
>> I might not be understanding your question completely, so please correct me
>> if I'm misunderstanding you. The sample code I posted enables you to only
>> update the zone within the row of the select menu triggering it.  If you
>> select an option in the first select menu / first row, it will only update
>> the zone in the first row and not the last row.
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4579967.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
When the select in your loopZone reloads after the zone update, it uses
purchaseRequest to determine it's value.  However, after the loop has
already executed, purchaseRequest, which you persist, points to the last
purchaseRequest instant enountered by the ajaxformloop.  Correct?

On Tue, Jul 12, 2011 at 2:14 PM, George Christman
<gc...@cardaddy.com>wrote:

> I might not be understanding your question completely, so please correct me
> if I'm misunderstanding you. The sample code I posted enables you to only
> update the zone within the row of the select menu triggering it.  If you
> select an option in the first select menu / first row, it will only update
> the zone in the first row and not the last row.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4579967.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: updating a zone inside of an ajaxformloop

Posted by George Christman <gc...@cardaddy.com>.
I might not be understanding your question completely, so please correct me
if I'm misunderstanding you. The sample code I posted enables you to only
update the zone within the row of the select menu triggering it.  If you
select an option in the first select menu / first row, it will only update
the zone in the first row and not the last row.  

--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4579967.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
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
<gc...@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: updating a zone inside of an ajaxformloop

Posted by George Christman <gc...@cardaddy.com>.
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: updating a zone inside of an ajaxformloop

Posted by George Christman <gc...@cardaddy.com>.
Please post your code and I'll help you. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-inside-of-an-ajaxformloop-tp4575519p4576086.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: updating a zone inside of an ajaxformloop

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 11 Jul 2011 17:46:58 -0300, Ray Nicholus <rn...@widen.com>  
wrote:

> It seems like zone updates on form elements are quite difficult to  
> perfect in tapestry.

Yep, not easy. Putting a whole form inside a zone is trivial, though.

> I simply want to update a select via a zone update

I guess Tapestry should have a mixin for that. I wrote one specifically  
for the state -> city scenario here:  
http://ars-machina.svn.sourceforge.net/viewvc/ars-machina/brasil-tapestry/trunk/.  
Source code is in Portuguese but it's still readable, I guess. The mixin  
name is CidadesDoEstado, is applied to the Select which selects cities and  
has the state chooser as a parameter (seletorEstado).

> and I'm finding myself attempting to work around the framework to get  
> this to
> happen.

I'd say you're twisting some components to use them in scenarios they  
weren't made for. Paraphrasing Howard, Zone is not catch-all solution for  
all AJAX scenarios.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
It seems like zone updates on form elements are quite difficult to perfect
in tapestry.  I simply want to update a select via a zone update and I'm
finding myself attempting to work around the framework to get this to
happen.  I have a counter variable in my loop that is used when rendering
all of my form elements. When a change to one of the selects triggers an
update of a zone containing another select, the form relies on my now null
counter variable to render it.  Persisting the counter variable doesn't
solve the problem, as that will always point to the last element encountered
when iterating over my source objects in the loop.  So, I'm left to figure
out a way to track the state of all of my form elements on the server side
via ajax (onValueChanged) calls.  This sort of defeats the purpose of the
loop element.  I'm still hoping I do not understand how this works
correctly.

On Mon, Jul 11, 2011 at 2:19 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 11 Jul 2011 15:54:02 -0300, Ray Nicholus <rn...@widen.com>
> wrote:
>
>  Note: I just noticed that the select component page for the select element
>> includes an example that illustrates updating a select inside of a form via
>> a zone update.  I'm essentially trying to do the same thing, only with
>> dynamically generated selects.
>>
>
> Tapestry pages and components have strictly static structure. When inside a
> Loop, a component can be rendered many times, but it's still a single
> instance.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>

Re: updating a zone inside of an ajaxformloop

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 11 Jul 2011 15:54:02 -0300, Ray Nicholus <rn...@widen.com>  
wrote:

> Note: I just noticed that the select component page for the select  
> element includes an example that illustrates updating a select inside of  
> a form via a zone update.  I'm essentially trying to do the same thing,  
> only with
> dynamically generated selects.

Tapestry pages and components have strictly static structure. When inside  
a Loop, a component can be rendered many times, but it's still a single  
instance.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
Note: I just noticed that the select component page for the select element
includes an example that illustrates updating a select inside of a form via
a zone update.  I'm essentially trying to do the same thing, only with
dynamically generated selects.

On Mon, Jul 11, 2011 at 1:48 PM, Ray Nicholus <rn...@widen.com> wrote:

> Actually, in this case, I have a zone including a form field inside a loop,
> there are no nested zones.  I was worried that I would have to revert to
> custom javascript, but I'm hoping that isn't true.  I'm not quite sure why
> this doesn't work, but once the 2nd select in the form (the one inside the
> zone) is updated, changes I make to the selection in that select are ignored
> unless I submit and then choose an option in that select.
>
>
> On Mon, Jul 11, 2011 at 1:45 PM, Thiago H. de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> On Mon, 11 Jul 2011 15:34:58 -0300, Ray Nicholus <rn...@widen.com>
>> wrote:
>>
>>  No, indeed it looks like I cannot use a submit button here.  Surely I
>>> can't be the first person who wanted to update a select via a zone update
>>> inside of a loop.  Isn't there a straightforward way to make this happen?
>>>
>>
>> As I've written in a little bit similar thread . . .
>>
>> "Maybe you're just rying to use the components in a way that wasn't
>> intended. The Tapestry
>> out-of-the-box AJAX support covers many scenarios but not all (and I guess
>> Zones including form fields inside a Zone inside a Loop is definetely not
>> one of them). Some scenarios are better covered with custom JavaScript."
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
Actually, in this case, I have a zone including a form field inside a loop,
there are no nested zones.  I was worried that I would have to revert to
custom javascript, but I'm hoping that isn't true.  I'm not quite sure why
this doesn't work, but once the 2nd select in the form (the one inside the
zone) is updated, changes I make to the selection in that select are ignored
unless I submit and then choose an option in that select.

On Mon, Jul 11, 2011 at 1:45 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 11 Jul 2011 15:34:58 -0300, Ray Nicholus <rn...@widen.com>
> wrote:
>
>  No, indeed it looks like I cannot use a submit button here.  Surely I
>> can't be the first person who wanted to update a select via a zone update
>> inside of a loop.  Isn't there a straightforward way to make this happen?
>>
>
> As I've written in a little bit similar thread . . .
>
> "Maybe you're just rying to use the components in a way that wasn't
> intended. The Tapestry
> out-of-the-box AJAX support covers many scenarios but not all (and I guess
> Zones including form fields inside a Zone inside a Loop is definetely not
> one of them). Some scenarios are better covered with custom JavaScript."
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: updating a zone inside of an ajaxformloop

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 11 Jul 2011 15:34:58 -0300, Ray Nicholus <rn...@widen.com>  
wrote:

> No, indeed it looks like I cannot use a submit button here.  Surely I  
> can't be the first person who wanted to update a select via a zone  
> update inside of a loop.  Isn't there a straightforward way to make this  
> happen?

As I've written in a little bit similar thread . . .

"Maybe you're just rying to use the components in a way that wasn't  
intended. The Tapestry
out-of-the-box AJAX support covers many scenarios but not all (and I guess
Zones including form fields inside a Zone inside a Loop is definetely not
one of them). Some scenarios are better covered with custom JavaScript."

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
No, indeed it looks like I cannot use a submit button here.  Surely I can't
be the first person who wanted to update a select via a zone update inside
of a loop.  Isn't there a straightforward way to make this happen?

On Mon, Jul 11, 2011 at 1:16 PM, Ray Nicholus <rn...@widen.com> wrote:

> Eh, it may be because I'm not updating the correct currentSetting object.
>  The behavior I want to support is fairly simple, but seems to be quite
> complex to get working in Tapestry, unless I'm missing something.
>
> On Mon, Jul 11, 2011 at 1:12 PM, Ray Nicholus <rn...@widen.com> wrote:
>
>> It sounds like I can't use a submit button at all in this case.  If I
>> update the first select this in turn updates the 2nd select via a zone
>> update.  Then, when I choose a new value in the 2nd select and hit submit,
>> my newly selected value is not persisted.  Instead, the default value of the
>> select is persisted.
>>
>>
>> On Mon, Jul 11, 2011 at 1:01 PM, Josh Canfield <jo...@gmail.com>wrote:
>>
>>> > Sorry for not noticing that. IFIAK you wont be able to use loop
>>> > variable(value parameter in loop or ajaxforloop) during a
>>> non-submission
>>> > ajax call.
>>>
>>> You can use the variable, you just can't count on it being set for you
>>> when you're using it out of context of the loop. Encode enough
>>> information in your events that you can re-hydrate your required
>>> properties yourself.
>>>
>>>
>>>
>>> On Mon, Jul 11, 2011 at 10:39 AM, Taha Hafeez <ta...@gmail.com>
>>> wrote:
>>> > Sorry for not noticing that. IFIAK you wont be able to use loop
>>> > variable(value parameter in loop or ajaxforloop) during a
>>> non-submission
>>> > ajax call. In case of a loop, the context of each iteration(i.e the
>>> loop
>>> > variable) is stored in hidden fields in the form. A value-encoder is
>>> used to
>>> > convert the current loop variable into a client side string and on
>>> > submission the same value-encoder converts it back into the loop
>>> variable
>>> > which is used to set the value of each form field in an iteration. Now
>>> if
>>> > you make an ajax call which only refreshes a zone inside the loop, the
>>> > current loop value(currentSetting in our case) is null as the decoding
>>> using
>>> > value-encoder does not happen without a submission.
>>> >
>>> > regards
>>> > Taha
>>> >
>>> >
>>> > On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com>
>>> wrote:
>>> >
>>> >> I'm not sure what variable you are talking about.  Do you mean
>>> >> "currentSetting"?  There is no "currentSettings" variable.  If so,
>>> >> currentSetting is the variable set by the ajaxformloop so there is
>>> nothing
>>> >> for me to initialize there.
>>> >>
>>> >> On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <
>>> tawus.tapestry@gmail.com
>>> >> >wrote:
>>> >>
>>> >> > My first question was where have you initialized currentSettings.
>>> Say you
>>> >> > have initialized it in onPrepare(), then during an ajax call, this
>>> method
>>> >> > is
>>> >> > not called and so currentSettings is not initialized for that
>>> request. If
>>> >> > you are setting it in setupRender() of the main component, then as
>>> only
>>> >> an
>>> >> > internal zone is updated, setupRender() or beginRender() of main
>>> >> > component/page are not called for ajax update of an internal zone.
>>> >> >
>>> >> > So you have to be careful about where you setup currentSettings and
>>> >> whether
>>> >> > that phase is called during ajax update. In case it is not, then you
>>> have
>>> >> > to
>>> >> > keep the variable in session so that you can use it across multiple
>>> >> > requests.
>>> >> >
>>> >> > regards
>>> >> > Taha
>>> >> >
>>> >> >
>>> >> > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rnicholus@widen.com
>>> >
>>> >> > wrote:
>>> >> >
>>> >> > > Hello Taha,
>>> >> > >
>>> >> > > I guess I'm confused about why I need to worry about any of this.
>>> >> >  Without
>>> >> > > the zone parameter, I have no problem changing values of my
>>> selects.
>>> >> > >  However, I need the zone so that I can change the available
>>> options in
>>> >> > the
>>> >> > > 2nd select after the value changes in the first select.  Shouldn't
>>> I
>>> >> just
>>> >> > > be
>>> >> > > able to refresh the 2nd select via a zone update?
>>> >> > >
>>> >> > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
>>> >> tawus.tapestry@gmail.com
>>> >> > > >wrote:
>>> >> > >
>>> >> > > > Hi Ray,
>>> >> > > >
>>> >> > > > Where are you initializing currentSetting.fileMetadataTyp?e and
>>> is
>>> >> this
>>> >> > > > value @Persisted as you are using it across multiple requests.
>>> >> > > >
>>> >> > > > regards
>>> >> > > > Taha
>>> >> > > >
>>> >> > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <
>>> rnicholus@widen.com>
>>> >> > > wrote:
>>> >> > > >
>>> >> > > > > Here is a fragment of some template code inside of a tapestry
>>> form:
>>> >> > > > >
>>> >> > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
>>> >> > > > source="existingSettings"
>>> >> > > > > value="currentSetting">
>>> >> > > > >  <t:label for="typeSelect"/>
>>> >> > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
>>> >> > > > > value="currentSetting.fileMetadataType"
>>> label="${message:type}"/>
>>> >> > > > >
>>> >> > > > > <t:zone t:id="fileMetadataSelectZone">
>>> >> > > > > <t:label for="fileMetadataSelect"/>
>>> >> > > > >  <t:select t:id="fileMetadataSelect"
>>> >> > > > > value="currentSetting.fileMetadataObject"
>>> >> > > > >  model="autoImportFileMetadataModel"
>>> >> > label="${message:file-metadata}"/>
>>> >> > > > >  </t:zone>
>>> >> > > > >
>>> >> > > > >                                          ..........
>>> >> > > > >
>>> >> > > > > </t:ajaxformloop>
>>> >> > > > >
>>> >> > > > > <input type="submit" value="Update"/>
>>> >> > > > >
>>> >> > > > >
>>> >> > > > > As soon as I add the zone parameter to the 1st select &
>>> reload, I
>>> >> get
>>> >> > a
>>> >> > > > NPE
>>> >> > > > > when I attempt to change the value in the 1st select.  It
>>> claims
>>> >> that
>>> >> > > the
>>> >> > > > > currentSetting value is null when attempting to evaluate
>>> >> > > > > currentSetting.fileMetadataType.
>>> >> > > > >
>>> >> > > > > What am I doing wrong?
>>> >> > > > >
>>> >> > > >
>>> >> > >
>>> >> >
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>

Re: updating a zone inside of an ajaxformloop

Posted by Josh Canfield <jo...@gmail.com>.
:) I guess it depends on what you consider simple. As my co-worker
often says "It's just SMOPs"
(http://en.wikipedia.org/wiki/Small_matter_of_programming)

You need to provide more information for us to understand what you are
getting hung up on.


On Mon, Jul 11, 2011 at 11:16 AM, Ray Nicholus <rn...@widen.com> wrote:
> Eh, it may be because I'm not updating the correct currentSetting object.
>  The behavior I want to support is fairly simple, but seems to be quite
> complex to get working in Tapestry, unless I'm missing something.
>
> On Mon, Jul 11, 2011 at 1:12 PM, Ray Nicholus <rn...@widen.com> wrote:
>
>> It sounds like I can't use a submit button at all in this case.  If I
>> update the first select this in turn updates the 2nd select via a zone
>> update.  Then, when I choose a new value in the 2nd select and hit submit,
>> my newly selected value is not persisted.  Instead, the default value of the
>> select is persisted.
>>
>>
>> On Mon, Jul 11, 2011 at 1:01 PM, Josh Canfield <jo...@gmail.com>wrote:
>>
>>> > Sorry for not noticing that. IFIAK you wont be able to use loop
>>> > variable(value parameter in loop or ajaxforloop) during a non-submission
>>> > ajax call.
>>>
>>> You can use the variable, you just can't count on it being set for you
>>> when you're using it out of context of the loop. Encode enough
>>> information in your events that you can re-hydrate your required
>>> properties yourself.
>>>
>>>
>>>
>>> On Mon, Jul 11, 2011 at 10:39 AM, Taha Hafeez <ta...@gmail.com>
>>> wrote:
>>> > Sorry for not noticing that. IFIAK you wont be able to use loop
>>> > variable(value parameter in loop or ajaxforloop) during a non-submission
>>> > ajax call. In case of a loop, the context of each iteration(i.e the loop
>>> > variable) is stored in hidden fields in the form. A value-encoder is
>>> used to
>>> > convert the current loop variable into a client side string and on
>>> > submission the same value-encoder converts it back into the loop
>>> variable
>>> > which is used to set the value of each form field in an iteration. Now
>>> if
>>> > you make an ajax call which only refreshes a zone inside the loop, the
>>> > current loop value(currentSetting in our case) is null as the decoding
>>> using
>>> > value-encoder does not happen without a submission.
>>> >
>>> > regards
>>> > Taha
>>> >
>>> >
>>> > On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com>
>>> wrote:
>>> >
>>> >> I'm not sure what variable you are talking about.  Do you mean
>>> >> "currentSetting"?  There is no "currentSettings" variable.  If so,
>>> >> currentSetting is the variable set by the ajaxformloop so there is
>>> nothing
>>> >> for me to initialize there.
>>> >>
>>> >> On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <
>>> tawus.tapestry@gmail.com
>>> >> >wrote:
>>> >>
>>> >> > My first question was where have you initialized currentSettings. Say
>>> you
>>> >> > have initialized it in onPrepare(), then during an ajax call, this
>>> method
>>> >> > is
>>> >> > not called and so currentSettings is not initialized for that
>>> request. If
>>> >> > you are setting it in setupRender() of the main component, then as
>>> only
>>> >> an
>>> >> > internal zone is updated, setupRender() or beginRender() of main
>>> >> > component/page are not called for ajax update of an internal zone.
>>> >> >
>>> >> > So you have to be careful about where you setup currentSettings and
>>> >> whether
>>> >> > that phase is called during ajax update. In case it is not, then you
>>> have
>>> >> > to
>>> >> > keep the variable in session so that you can use it across multiple
>>> >> > requests.
>>> >> >
>>> >> > regards
>>> >> > Taha
>>> >> >
>>> >> >
>>> >> > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
>>> >> > wrote:
>>> >> >
>>> >> > > Hello Taha,
>>> >> > >
>>> >> > > I guess I'm confused about why I need to worry about any of this.
>>> >> >  Without
>>> >> > > the zone parameter, I have no problem changing values of my
>>> selects.
>>> >> > >  However, I need the zone so that I can change the available
>>> options in
>>> >> > the
>>> >> > > 2nd select after the value changes in the first select.  Shouldn't
>>> I
>>> >> just
>>> >> > > be
>>> >> > > able to refresh the 2nd select via a zone update?
>>> >> > >
>>> >> > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
>>> >> tawus.tapestry@gmail.com
>>> >> > > >wrote:
>>> >> > >
>>> >> > > > Hi Ray,
>>> >> > > >
>>> >> > > > Where are you initializing currentSetting.fileMetadataTyp?e and
>>> is
>>> >> this
>>> >> > > > value @Persisted as you are using it across multiple requests.
>>> >> > > >
>>> >> > > > regards
>>> >> > > > Taha
>>> >> > > >
>>> >> > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <
>>> rnicholus@widen.com>
>>> >> > > wrote:
>>> >> > > >
>>> >> > > > > Here is a fragment of some template code inside of a tapestry
>>> form:
>>> >> > > > >
>>> >> > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
>>> >> > > > source="existingSettings"
>>> >> > > > > value="currentSetting">
>>> >> > > > >  <t:label for="typeSelect"/>
>>> >> > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
>>> >> > > > > value="currentSetting.fileMetadataType"
>>> label="${message:type}"/>
>>> >> > > > >
>>> >> > > > > <t:zone t:id="fileMetadataSelectZone">
>>> >> > > > > <t:label for="fileMetadataSelect"/>
>>> >> > > > >  <t:select t:id="fileMetadataSelect"
>>> >> > > > > value="currentSetting.fileMetadataObject"
>>> >> > > > >  model="autoImportFileMetadataModel"
>>> >> > label="${message:file-metadata}"/>
>>> >> > > > >  </t:zone>
>>> >> > > > >
>>> >> > > > >                                          ..........
>>> >> > > > >
>>> >> > > > > </t:ajaxformloop>
>>> >> > > > >
>>> >> > > > > <input type="submit" value="Update"/>
>>> >> > > > >
>>> >> > > > >
>>> >> > > > > As soon as I add the zone parameter to the 1st select & reload,
>>> I
>>> >> get
>>> >> > a
>>> >> > > > NPE
>>> >> > > > > when I attempt to change the value in the 1st select.  It
>>> claims
>>> >> that
>>> >> > > the
>>> >> > > > > currentSetting value is null when attempting to evaluate
>>> >> > > > > currentSetting.fileMetadataType.
>>> >> > > > >
>>> >> > > > > What am I doing wrong?
>>> >> > > > >
>>> >> > > >
>>> >> > >
>>> >> >
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
Eh, it may be because I'm not updating the correct currentSetting object.
 The behavior I want to support is fairly simple, but seems to be quite
complex to get working in Tapestry, unless I'm missing something.

On Mon, Jul 11, 2011 at 1:12 PM, Ray Nicholus <rn...@widen.com> wrote:

> It sounds like I can't use a submit button at all in this case.  If I
> update the first select this in turn updates the 2nd select via a zone
> update.  Then, when I choose a new value in the 2nd select and hit submit,
> my newly selected value is not persisted.  Instead, the default value of the
> select is persisted.
>
>
> On Mon, Jul 11, 2011 at 1:01 PM, Josh Canfield <jo...@gmail.com>wrote:
>
>> > Sorry for not noticing that. IFIAK you wont be able to use loop
>> > variable(value parameter in loop or ajaxforloop) during a non-submission
>> > ajax call.
>>
>> You can use the variable, you just can't count on it being set for you
>> when you're using it out of context of the loop. Encode enough
>> information in your events that you can re-hydrate your required
>> properties yourself.
>>
>>
>>
>> On Mon, Jul 11, 2011 at 10:39 AM, Taha Hafeez <ta...@gmail.com>
>> wrote:
>> > Sorry for not noticing that. IFIAK you wont be able to use loop
>> > variable(value parameter in loop or ajaxforloop) during a non-submission
>> > ajax call. In case of a loop, the context of each iteration(i.e the loop
>> > variable) is stored in hidden fields in the form. A value-encoder is
>> used to
>> > convert the current loop variable into a client side string and on
>> > submission the same value-encoder converts it back into the loop
>> variable
>> > which is used to set the value of each form field in an iteration. Now
>> if
>> > you make an ajax call which only refreshes a zone inside the loop, the
>> > current loop value(currentSetting in our case) is null as the decoding
>> using
>> > value-encoder does not happen without a submission.
>> >
>> > regards
>> > Taha
>> >
>> >
>> > On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com>
>> wrote:
>> >
>> >> I'm not sure what variable you are talking about.  Do you mean
>> >> "currentSetting"?  There is no "currentSettings" variable.  If so,
>> >> currentSetting is the variable set by the ajaxformloop so there is
>> nothing
>> >> for me to initialize there.
>> >>
>> >> On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <
>> tawus.tapestry@gmail.com
>> >> >wrote:
>> >>
>> >> > My first question was where have you initialized currentSettings. Say
>> you
>> >> > have initialized it in onPrepare(), then during an ajax call, this
>> method
>> >> > is
>> >> > not called and so currentSettings is not initialized for that
>> request. If
>> >> > you are setting it in setupRender() of the main component, then as
>> only
>> >> an
>> >> > internal zone is updated, setupRender() or beginRender() of main
>> >> > component/page are not called for ajax update of an internal zone.
>> >> >
>> >> > So you have to be careful about where you setup currentSettings and
>> >> whether
>> >> > that phase is called during ajax update. In case it is not, then you
>> have
>> >> > to
>> >> > keep the variable in session so that you can use it across multiple
>> >> > requests.
>> >> >
>> >> > regards
>> >> > Taha
>> >> >
>> >> >
>> >> > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
>> >> > wrote:
>> >> >
>> >> > > Hello Taha,
>> >> > >
>> >> > > I guess I'm confused about why I need to worry about any of this.
>> >> >  Without
>> >> > > the zone parameter, I have no problem changing values of my
>> selects.
>> >> > >  However, I need the zone so that I can change the available
>> options in
>> >> > the
>> >> > > 2nd select after the value changes in the first select.  Shouldn't
>> I
>> >> just
>> >> > > be
>> >> > > able to refresh the 2nd select via a zone update?
>> >> > >
>> >> > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
>> >> tawus.tapestry@gmail.com
>> >> > > >wrote:
>> >> > >
>> >> > > > Hi Ray,
>> >> > > >
>> >> > > > Where are you initializing currentSetting.fileMetadataTyp?e and
>> is
>> >> this
>> >> > > > value @Persisted as you are using it across multiple requests.
>> >> > > >
>> >> > > > regards
>> >> > > > Taha
>> >> > > >
>> >> > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <
>> rnicholus@widen.com>
>> >> > > wrote:
>> >> > > >
>> >> > > > > Here is a fragment of some template code inside of a tapestry
>> form:
>> >> > > > >
>> >> > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
>> >> > > > source="existingSettings"
>> >> > > > > value="currentSetting">
>> >> > > > >  <t:label for="typeSelect"/>
>> >> > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
>> >> > > > > value="currentSetting.fileMetadataType"
>> label="${message:type}"/>
>> >> > > > >
>> >> > > > > <t:zone t:id="fileMetadataSelectZone">
>> >> > > > > <t:label for="fileMetadataSelect"/>
>> >> > > > >  <t:select t:id="fileMetadataSelect"
>> >> > > > > value="currentSetting.fileMetadataObject"
>> >> > > > >  model="autoImportFileMetadataModel"
>> >> > label="${message:file-metadata}"/>
>> >> > > > >  </t:zone>
>> >> > > > >
>> >> > > > >                                          ..........
>> >> > > > >
>> >> > > > > </t:ajaxformloop>
>> >> > > > >
>> >> > > > > <input type="submit" value="Update"/>
>> >> > > > >
>> >> > > > >
>> >> > > > > As soon as I add the zone parameter to the 1st select & reload,
>> I
>> >> get
>> >> > a
>> >> > > > NPE
>> >> > > > > when I attempt to change the value in the 1st select.  It
>> claims
>> >> that
>> >> > > the
>> >> > > > > currentSetting value is null when attempting to evaluate
>> >> > > > > currentSetting.fileMetadataType.
>> >> > > > >
>> >> > > > > What am I doing wrong?
>> >> > > > >
>> >> > > >
>> >> > >
>> >> >
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
It sounds like I can't use a submit button at all in this case.  If I update
the first select this in turn updates the 2nd select via a zone update.
 Then, when I choose a new value in the 2nd select and hit submit, my newly
selected value is not persisted.  Instead, the default value of the select
is persisted.

On Mon, Jul 11, 2011 at 1:01 PM, Josh Canfield <jo...@gmail.com>wrote:

> > Sorry for not noticing that. IFIAK you wont be able to use loop
> > variable(value parameter in loop or ajaxforloop) during a non-submission
> > ajax call.
>
> You can use the variable, you just can't count on it being set for you
> when you're using it out of context of the loop. Encode enough
> information in your events that you can re-hydrate your required
> properties yourself.
>
>
>
> On Mon, Jul 11, 2011 at 10:39 AM, Taha Hafeez <ta...@gmail.com>
> wrote:
> > Sorry for not noticing that. IFIAK you wont be able to use loop
> > variable(value parameter in loop or ajaxforloop) during a non-submission
> > ajax call. In case of a loop, the context of each iteration(i.e the loop
> > variable) is stored in hidden fields in the form. A value-encoder is used
> to
> > convert the current loop variable into a client side string and on
> > submission the same value-encoder converts it back into the loop variable
> > which is used to set the value of each form field in an iteration. Now if
> > you make an ajax call which only refreshes a zone inside the loop, the
> > current loop value(currentSetting in our case) is null as the decoding
> using
> > value-encoder does not happen without a submission.
> >
> > regards
> > Taha
> >
> >
> > On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com>
> wrote:
> >
> >> I'm not sure what variable you are talking about.  Do you mean
> >> "currentSetting"?  There is no "currentSettings" variable.  If so,
> >> currentSetting is the variable set by the ajaxformloop so there is
> nothing
> >> for me to initialize there.
> >>
> >> On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <tawus.tapestry@gmail.com
> >> >wrote:
> >>
> >> > My first question was where have you initialized currentSettings. Say
> you
> >> > have initialized it in onPrepare(), then during an ajax call, this
> method
> >> > is
> >> > not called and so currentSettings is not initialized for that request.
> If
> >> > you are setting it in setupRender() of the main component, then as
> only
> >> an
> >> > internal zone is updated, setupRender() or beginRender() of main
> >> > component/page are not called for ajax update of an internal zone.
> >> >
> >> > So you have to be careful about where you setup currentSettings and
> >> whether
> >> > that phase is called during ajax update. In case it is not, then you
> have
> >> > to
> >> > keep the variable in session so that you can use it across multiple
> >> > requests.
> >> >
> >> > regards
> >> > Taha
> >> >
> >> >
> >> > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
> >> > wrote:
> >> >
> >> > > Hello Taha,
> >> > >
> >> > > I guess I'm confused about why I need to worry about any of this.
> >> >  Without
> >> > > the zone parameter, I have no problem changing values of my selects.
> >> > >  However, I need the zone so that I can change the available options
> in
> >> > the
> >> > > 2nd select after the value changes in the first select.  Shouldn't I
> >> just
> >> > > be
> >> > > able to refresh the 2nd select via a zone update?
> >> > >
> >> > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
> >> tawus.tapestry@gmail.com
> >> > > >wrote:
> >> > >
> >> > > > Hi Ray,
> >> > > >
> >> > > > Where are you initializing currentSetting.fileMetadataTyp?e and is
> >> this
> >> > > > value @Persisted as you are using it across multiple requests.
> >> > > >
> >> > > > regards
> >> > > > Taha
> >> > > >
> >> > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <
> rnicholus@widen.com>
> >> > > wrote:
> >> > > >
> >> > > > > Here is a fragment of some template code inside of a tapestry
> form:
> >> > > > >
> >> > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
> >> > > > source="existingSettings"
> >> > > > > value="currentSetting">
> >> > > > >  <t:label for="typeSelect"/>
> >> > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> >> > > > > value="currentSetting.fileMetadataType"
> label="${message:type}"/>
> >> > > > >
> >> > > > > <t:zone t:id="fileMetadataSelectZone">
> >> > > > > <t:label for="fileMetadataSelect"/>
> >> > > > >  <t:select t:id="fileMetadataSelect"
> >> > > > > value="currentSetting.fileMetadataObject"
> >> > > > >  model="autoImportFileMetadataModel"
> >> > label="${message:file-metadata}"/>
> >> > > > >  </t:zone>
> >> > > > >
> >> > > > >                                          ..........
> >> > > > >
> >> > > > > </t:ajaxformloop>
> >> > > > >
> >> > > > > <input type="submit" value="Update"/>
> >> > > > >
> >> > > > >
> >> > > > > As soon as I add the zone parameter to the 1st select & reload,
> I
> >> get
> >> > a
> >> > > > NPE
> >> > > > > when I attempt to change the value in the 1st select.  It claims
> >> that
> >> > > the
> >> > > > > currentSetting value is null when attempting to evaluate
> >> > > > > currentSetting.fileMetadataType.
> >> > > > >
> >> > > > > What am I doing wrong?
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: updating a zone inside of an ajaxformloop

Posted by Josh Canfield <jo...@gmail.com>.
> Sorry for not noticing that. IFIAK you wont be able to use loop
> variable(value parameter in loop or ajaxforloop) during a non-submission
> ajax call.

You can use the variable, you just can't count on it being set for you
when you're using it out of context of the loop. Encode enough
information in your events that you can re-hydrate your required
properties yourself.



On Mon, Jul 11, 2011 at 10:39 AM, Taha Hafeez <ta...@gmail.com> wrote:
> Sorry for not noticing that. IFIAK you wont be able to use loop
> variable(value parameter in loop or ajaxforloop) during a non-submission
> ajax call. In case of a loop, the context of each iteration(i.e the loop
> variable) is stored in hidden fields in the form. A value-encoder is used to
> convert the current loop variable into a client side string and on
> submission the same value-encoder converts it back into the loop variable
> which is used to set the value of each form field in an iteration. Now if
> you make an ajax call which only refreshes a zone inside the loop, the
> current loop value(currentSetting in our case) is null as the decoding using
> value-encoder does not happen without a submission.
>
> regards
> Taha
>
>
> On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com> wrote:
>
>> I'm not sure what variable you are talking about.  Do you mean
>> "currentSetting"?  There is no "currentSettings" variable.  If so,
>> currentSetting is the variable set by the ajaxformloop so there is nothing
>> for me to initialize there.
>>
>> On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <tawus.tapestry@gmail.com
>> >wrote:
>>
>> > My first question was where have you initialized currentSettings. Say you
>> > have initialized it in onPrepare(), then during an ajax call, this method
>> > is
>> > not called and so currentSettings is not initialized for that request. If
>> > you are setting it in setupRender() of the main component, then as only
>> an
>> > internal zone is updated, setupRender() or beginRender() of main
>> > component/page are not called for ajax update of an internal zone.
>> >
>> > So you have to be careful about where you setup currentSettings and
>> whether
>> > that phase is called during ajax update. In case it is not, then you have
>> > to
>> > keep the variable in session so that you can use it across multiple
>> > requests.
>> >
>> > regards
>> > Taha
>> >
>> >
>> > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
>> > wrote:
>> >
>> > > Hello Taha,
>> > >
>> > > I guess I'm confused about why I need to worry about any of this.
>> >  Without
>> > > the zone parameter, I have no problem changing values of my selects.
>> > >  However, I need the zone so that I can change the available options in
>> > the
>> > > 2nd select after the value changes in the first select.  Shouldn't I
>> just
>> > > be
>> > > able to refresh the 2nd select via a zone update?
>> > >
>> > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
>> tawus.tapestry@gmail.com
>> > > >wrote:
>> > >
>> > > > Hi Ray,
>> > > >
>> > > > Where are you initializing currentSetting.fileMetadataTyp?e and is
>> this
>> > > > value @Persisted as you are using it across multiple requests.
>> > > >
>> > > > regards
>> > > > Taha
>> > > >
>> > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com>
>> > > wrote:
>> > > >
>> > > > > Here is a fragment of some template code inside of a tapestry form:
>> > > > >
>> > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
>> > > > source="existingSettings"
>> > > > > value="currentSetting">
>> > > > >  <t:label for="typeSelect"/>
>> > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
>> > > > > value="currentSetting.fileMetadataType" label="${message:type}"/>
>> > > > >
>> > > > > <t:zone t:id="fileMetadataSelectZone">
>> > > > > <t:label for="fileMetadataSelect"/>
>> > > > >  <t:select t:id="fileMetadataSelect"
>> > > > > value="currentSetting.fileMetadataObject"
>> > > > >  model="autoImportFileMetadataModel"
>> > label="${message:file-metadata}"/>
>> > > > >  </t:zone>
>> > > > >
>> > > > >                                          ..........
>> > > > >
>> > > > > </t:ajaxformloop>
>> > > > >
>> > > > > <input type="submit" value="Update"/>
>> > > > >
>> > > > >
>> > > > > As soon as I add the zone parameter to the 1st select & reload, I
>> get
>> > a
>> > > > NPE
>> > > > > when I attempt to change the value in the 1st select.  It claims
>> that
>> > > the
>> > > > > currentSetting value is null when attempting to evaluate
>> > > > > currentSetting.fileMetadataType.
>> > > > >
>> > > > > What am I doing wrong?
>> > > > >
>> > > >
>> > >
>> >
>>
>

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
Ouch.  That's not good news.  What can I do to make this work?  Just to
restate again, after changing the value of the first select, I need to
update the options in the second select in the same row.  Then, when I
submit, I need all values reflected in the UI to be persisted.  I am using
Hibernate, so a simple @CommitAfter onSuccess would normally allow me to
commit these changes.

On Mon, Jul 11, 2011 at 12:39 PM, Taha Hafeez <ta...@gmail.com>wrote:

> Sorry for not noticing that. IFIAK you wont be able to use loop
> variable(value parameter in loop or ajaxforloop) during a non-submission
> ajax call. In case of a loop, the context of each iteration(i.e the loop
> variable) is stored in hidden fields in the form. A value-encoder is used
> to
> convert the current loop variable into a client side string and on
> submission the same value-encoder converts it back into the loop variable
> which is used to set the value of each form field in an iteration. Now if
> you make an ajax call which only refreshes a zone inside the loop, the
> current loop value(currentSetting in our case) is null as the decoding
> using
> value-encoder does not happen without a submission.
>
> regards
> Taha
>
>
> On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com>
> wrote:
>
> > I'm not sure what variable you are talking about.  Do you mean
> > "currentSetting"?  There is no "currentSettings" variable.  If so,
> > currentSetting is the variable set by the ajaxformloop so there is
> nothing
> > for me to initialize there.
> >
> > On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <tawus.tapestry@gmail.com
> > >wrote:
> >
> > > My first question was where have you initialized currentSettings. Say
> you
> > > have initialized it in onPrepare(), then during an ajax call, this
> method
> > > is
> > > not called and so currentSettings is not initialized for that request.
> If
> > > you are setting it in setupRender() of the main component, then as only
> > an
> > > internal zone is updated, setupRender() or beginRender() of main
> > > component/page are not called for ajax update of an internal zone.
> > >
> > > So you have to be careful about where you setup currentSettings and
> > whether
> > > that phase is called during ajax update. In case it is not, then you
> have
> > > to
> > > keep the variable in session so that you can use it across multiple
> > > requests.
> > >
> > > regards
> > > Taha
> > >
> > >
> > > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
> > > wrote:
> > >
> > > > Hello Taha,
> > > >
> > > > I guess I'm confused about why I need to worry about any of this.
> > >  Without
> > > > the zone parameter, I have no problem changing values of my selects.
> > > >  However, I need the zone so that I can change the available options
> in
> > > the
> > > > 2nd select after the value changes in the first select.  Shouldn't I
> > just
> > > > be
> > > > able to refresh the 2nd select via a zone update?
> > > >
> > > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
> > tawus.tapestry@gmail.com
> > > > >wrote:
> > > >
> > > > > Hi Ray,
> > > > >
> > > > > Where are you initializing currentSetting.fileMetadataTyp?e and is
> > this
> > > > > value @Persisted as you are using it across multiple requests.
> > > > >
> > > > > regards
> > > > > Taha
> > > > >
> > > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rnicholus@widen.com
> >
> > > > wrote:
> > > > >
> > > > > > Here is a fragment of some template code inside of a tapestry
> form:
> > > > > >
> > > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
> > > > > source="existingSettings"
> > > > > > value="currentSetting">
> > > > > >  <t:label for="typeSelect"/>
> > > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> > > > > > value="currentSetting.fileMetadataType" label="${message:type}"/>
> > > > > >
> > > > > > <t:zone t:id="fileMetadataSelectZone">
> > > > > > <t:label for="fileMetadataSelect"/>
> > > > > >  <t:select t:id="fileMetadataSelect"
> > > > > > value="currentSetting.fileMetadataObject"
> > > > > >  model="autoImportFileMetadataModel"
> > > label="${message:file-metadata}"/>
> > > > > >  </t:zone>
> > > > > >
> > > > > >                                          ..........
> > > > > >
> > > > > > </t:ajaxformloop>
> > > > > >
> > > > > > <input type="submit" value="Update"/>
> > > > > >
> > > > > >
> > > > > > As soon as I add the zone parameter to the 1st select & reload, I
> > get
> > > a
> > > > > NPE
> > > > > > when I attempt to change the value in the 1st select.  It claims
> > that
> > > > the
> > > > > > currentSetting value is null when attempting to evaluate
> > > > > > currentSetting.fileMetadataType.
> > > > > >
> > > > > > What am I doing wrong?
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: updating a zone inside of an ajaxformloop

Posted by Taha Hafeez <ta...@gmail.com>.
Sorry for not noticing that. IFIAK you wont be able to use loop
variable(value parameter in loop or ajaxforloop) during a non-submission
ajax call. In case of a loop, the context of each iteration(i.e the loop
variable) is stored in hidden fields in the form. A value-encoder is used to
convert the current loop variable into a client side string and on
submission the same value-encoder converts it back into the loop variable
which is used to set the value of each form field in an iteration. Now if
you make an ajax call which only refreshes a zone inside the loop, the
current loop value(currentSetting in our case) is null as the decoding using
value-encoder does not happen without a submission.

regards
Taha


On Mon, Jul 11, 2011 at 10:37 PM, Ray Nicholus <rn...@widen.com> wrote:

> I'm not sure what variable you are talking about.  Do you mean
> "currentSetting"?  There is no "currentSettings" variable.  If so,
> currentSetting is the variable set by the ajaxformloop so there is nothing
> for me to initialize there.
>
> On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <tawus.tapestry@gmail.com
> >wrote:
>
> > My first question was where have you initialized currentSettings. Say you
> > have initialized it in onPrepare(), then during an ajax call, this method
> > is
> > not called and so currentSettings is not initialized for that request. If
> > you are setting it in setupRender() of the main component, then as only
> an
> > internal zone is updated, setupRender() or beginRender() of main
> > component/page are not called for ajax update of an internal zone.
> >
> > So you have to be careful about where you setup currentSettings and
> whether
> > that phase is called during ajax update. In case it is not, then you have
> > to
> > keep the variable in session so that you can use it across multiple
> > requests.
> >
> > regards
> > Taha
> >
> >
> > On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
> > wrote:
> >
> > > Hello Taha,
> > >
> > > I guess I'm confused about why I need to worry about any of this.
> >  Without
> > > the zone parameter, I have no problem changing values of my selects.
> > >  However, I need the zone so that I can change the available options in
> > the
> > > 2nd select after the value changes in the first select.  Shouldn't I
> just
> > > be
> > > able to refresh the 2nd select via a zone update?
> > >
> > > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <
> tawus.tapestry@gmail.com
> > > >wrote:
> > >
> > > > Hi Ray,
> > > >
> > > > Where are you initializing currentSetting.fileMetadataTyp?e and is
> this
> > > > value @Persisted as you are using it across multiple requests.
> > > >
> > > > regards
> > > > Taha
> > > >
> > > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com>
> > > wrote:
> > > >
> > > > > Here is a fragment of some template code inside of a tapestry form:
> > > > >
> > > > > <t:ajaxformloop t:id="existingAutoImportSettings"
> > > > source="existingSettings"
> > > > > value="currentSetting">
> > > > >  <t:label for="typeSelect"/>
> > > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> > > > > value="currentSetting.fileMetadataType" label="${message:type}"/>
> > > > >
> > > > > <t:zone t:id="fileMetadataSelectZone">
> > > > > <t:label for="fileMetadataSelect"/>
> > > > >  <t:select t:id="fileMetadataSelect"
> > > > > value="currentSetting.fileMetadataObject"
> > > > >  model="autoImportFileMetadataModel"
> > label="${message:file-metadata}"/>
> > > > >  </t:zone>
> > > > >
> > > > >                                          ..........
> > > > >
> > > > > </t:ajaxformloop>
> > > > >
> > > > > <input type="submit" value="Update"/>
> > > > >
> > > > >
> > > > > As soon as I add the zone parameter to the 1st select & reload, I
> get
> > a
> > > > NPE
> > > > > when I attempt to change the value in the 1st select.  It claims
> that
> > > the
> > > > > currentSetting value is null when attempting to evaluate
> > > > > currentSetting.fileMetadataType.
> > > > >
> > > > > What am I doing wrong?
> > > > >
> > > >
> > >
> >
>

Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
I'm not sure what variable you are talking about.  Do you mean
"currentSetting"?  There is no "currentSettings" variable.  If so,
currentSetting is the variable set by the ajaxformloop so there is nothing
for me to initialize there.

On Mon, Jul 11, 2011 at 12:04 PM, Taha Hafeez <ta...@gmail.com>wrote:

> My first question was where have you initialized currentSettings. Say you
> have initialized it in onPrepare(), then during an ajax call, this method
> is
> not called and so currentSettings is not initialized for that request. If
> you are setting it in setupRender() of the main component, then as only an
> internal zone is updated, setupRender() or beginRender() of main
> component/page are not called for ajax update of an internal zone.
>
> So you have to be careful about where you setup currentSettings and whether
> that phase is called during ajax update. In case it is not, then you have
> to
> keep the variable in session so that you can use it across multiple
> requests.
>
> regards
> Taha
>
>
> On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com>
> wrote:
>
> > Hello Taha,
> >
> > I guess I'm confused about why I need to worry about any of this.
>  Without
> > the zone parameter, I have no problem changing values of my selects.
> >  However, I need the zone so that I can change the available options in
> the
> > 2nd select after the value changes in the first select.  Shouldn't I just
> > be
> > able to refresh the 2nd select via a zone update?
> >
> > On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <tawus.tapestry@gmail.com
> > >wrote:
> >
> > > Hi Ray,
> > >
> > > Where are you initializing currentSetting.fileMetadataTyp?e and is this
> > > value @Persisted as you are using it across multiple requests.
> > >
> > > regards
> > > Taha
> > >
> > > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com>
> > wrote:
> > >
> > > > Here is a fragment of some template code inside of a tapestry form:
> > > >
> > > > <t:ajaxformloop t:id="existingAutoImportSettings"
> > > source="existingSettings"
> > > > value="currentSetting">
> > > >  <t:label for="typeSelect"/>
> > > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> > > > value="currentSetting.fileMetadataType" label="${message:type}"/>
> > > >
> > > > <t:zone t:id="fileMetadataSelectZone">
> > > > <t:label for="fileMetadataSelect"/>
> > > >  <t:select t:id="fileMetadataSelect"
> > > > value="currentSetting.fileMetadataObject"
> > > >  model="autoImportFileMetadataModel"
> label="${message:file-metadata}"/>
> > > >  </t:zone>
> > > >
> > > >                                          ..........
> > > >
> > > > </t:ajaxformloop>
> > > >
> > > > <input type="submit" value="Update"/>
> > > >
> > > >
> > > > As soon as I add the zone parameter to the 1st select & reload, I get
> a
> > > NPE
> > > > when I attempt to change the value in the 1st select.  It claims that
> > the
> > > > currentSetting value is null when attempting to evaluate
> > > > currentSetting.fileMetadataType.
> > > >
> > > > What am I doing wrong?
> > > >
> > >
> >
>

Re: updating a zone inside of an ajaxformloop

Posted by Taha Hafeez <ta...@gmail.com>.
My first question was where have you initialized currentSettings. Say you
have initialized it in onPrepare(), then during an ajax call, this method is
not called and so currentSettings is not initialized for that request. If
you are setting it in setupRender() of the main component, then as only an
internal zone is updated, setupRender() or beginRender() of main
component/page are not called for ajax update of an internal zone.

So you have to be careful about where you setup currentSettings and whether
that phase is called during ajax update. In case it is not, then you have to
keep the variable in session so that you can use it across multiple
requests.

regards
Taha


On Mon, Jul 11, 2011 at 10:17 PM, Ray Nicholus <rn...@widen.com> wrote:

> Hello Taha,
>
> I guess I'm confused about why I need to worry about any of this.  Without
> the zone parameter, I have no problem changing values of my selects.
>  However, I need the zone so that I can change the available options in the
> 2nd select after the value changes in the first select.  Shouldn't I just
> be
> able to refresh the 2nd select via a zone update?
>
> On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <tawus.tapestry@gmail.com
> >wrote:
>
> > Hi Ray,
> >
> > Where are you initializing currentSetting.fileMetadataTyp?e and is this
> > value @Persisted as you are using it across multiple requests.
> >
> > regards
> > Taha
> >
> > On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com>
> wrote:
> >
> > > Here is a fragment of some template code inside of a tapestry form:
> > >
> > > <t:ajaxformloop t:id="existingAutoImportSettings"
> > source="existingSettings"
> > > value="currentSetting">
> > >  <t:label for="typeSelect"/>
> > > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> > > value="currentSetting.fileMetadataType" label="${message:type}"/>
> > >
> > > <t:zone t:id="fileMetadataSelectZone">
> > > <t:label for="fileMetadataSelect"/>
> > >  <t:select t:id="fileMetadataSelect"
> > > value="currentSetting.fileMetadataObject"
> > >  model="autoImportFileMetadataModel" label="${message:file-metadata}"/>
> > >  </t:zone>
> > >
> > >                                          ..........
> > >
> > > </t:ajaxformloop>
> > >
> > > <input type="submit" value="Update"/>
> > >
> > >
> > > As soon as I add the zone parameter to the 1st select & reload, I get a
> > NPE
> > > when I attempt to change the value in the 1st select.  It claims that
> the
> > > currentSetting value is null when attempting to evaluate
> > > currentSetting.fileMetadataType.
> > >
> > > What am I doing wrong?
> > >
> >
>

Re: updating a zone inside of an ajaxformloop

Posted by Josh Canfield <jo...@gmail.com>.
> I guess I'm confused about why I need to worry about any of this.  Without
> the zone parameter, I have no problem changing values of my selects.

You have to worry about it because without the zone parameter you
aren't doing an ajax request back to your component when the select
changes. When you add the zone parameter to the select it has to
actually make a request back to the server to render the zone and your
"currentSetting" object is null when it comes time to render because
it's only getting set if you're running through the AjaxFormLoop.

The select component only notifies your server about the new value of
the select. You probably need to encode enough information into your
select value that you can figure out which select you want to render.

You also need to provide an "id" attribute/parameter to your zone
(instead of or in addition to your t:id attribute). This will keep
your zone id at a fixed value that you can reference from your select.
Since you're in a loop you are rendering the zone multiple times and
it's going to get multiple ids, you should control what those ids are.
You could use the id of your currentSetting if it's unique, otherwise
you'll have to come up with something.

It can be as simple as:


<t:zone id="${currentSelect.id}_selectZone" ... >
</t:zone>

<t:select zone="${currentSelect.id}_selectZone" ... />

Josh

On Mon, Jul 11, 2011 at 9:47 AM, Ray Nicholus <rn...@widen.com> wrote:
> Hello Taha,
>
> I guess I'm confused about why I need to worry about any of this.  Without
> the zone parameter, I have no problem changing values of my selects.
>  However, I need the zone so that I can change the available options in the
> 2nd select after the value changes in the first select.  Shouldn't I just be
> able to refresh the 2nd select via a zone update?
>
> On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <ta...@gmail.com>wrote:
>
>> Hi Ray,
>>
>> Where are you initializing currentSetting.fileMetadataTyp?e and is this
>> value @Persisted as you are using it across multiple requests.
>>
>> regards
>> Taha
>>
>> On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com> wrote:
>>
>> > Here is a fragment of some template code inside of a tapestry form:
>> >
>> > <t:ajaxformloop t:id="existingAutoImportSettings"
>> source="existingSettings"
>> > value="currentSetting">
>> >  <t:label for="typeSelect"/>
>> > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
>> > value="currentSetting.fileMetadataType" label="${message:type}"/>
>> >
>> > <t:zone t:id="fileMetadataSelectZone">
>> > <t:label for="fileMetadataSelect"/>
>> >  <t:select t:id="fileMetadataSelect"
>> > value="currentSetting.fileMetadataObject"
>> >  model="autoImportFileMetadataModel" label="${message:file-metadata}"/>
>> >  </t:zone>
>> >
>> >                                          ..........
>> >
>> > </t:ajaxformloop>
>> >
>> > <input type="submit" value="Update"/>
>> >
>> >
>> > As soon as I add the zone parameter to the 1st select & reload, I get a
>> NPE
>> > when I attempt to change the value in the 1st select.  It claims that the
>> > currentSetting value is null when attempting to evaluate
>> > currentSetting.fileMetadataType.
>> >
>> > What am I doing wrong?
>> >
>>
>

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


Re: updating a zone inside of an ajaxformloop

Posted by Ray Nicholus <rn...@widen.com>.
Hello Taha,

I guess I'm confused about why I need to worry about any of this.  Without
the zone parameter, I have no problem changing values of my selects.
 However, I need the zone so that I can change the available options in the
2nd select after the value changes in the first select.  Shouldn't I just be
able to refresh the 2nd select via a zone update?

On Mon, Jul 11, 2011 at 11:26 AM, Taha Hafeez <ta...@gmail.com>wrote:

> Hi Ray,
>
> Where are you initializing currentSetting.fileMetadataTyp?e and is this
> value @Persisted as you are using it across multiple requests.
>
> regards
> Taha
>
> On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com> wrote:
>
> > Here is a fragment of some template code inside of a tapestry form:
> >
> > <t:ajaxformloop t:id="existingAutoImportSettings"
> source="existingSettings"
> > value="currentSetting">
> >  <t:label for="typeSelect"/>
> > <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> > value="currentSetting.fileMetadataType" label="${message:type}"/>
> >
> > <t:zone t:id="fileMetadataSelectZone">
> > <t:label for="fileMetadataSelect"/>
> >  <t:select t:id="fileMetadataSelect"
> > value="currentSetting.fileMetadataObject"
> >  model="autoImportFileMetadataModel" label="${message:file-metadata}"/>
> >  </t:zone>
> >
> >                                          ..........
> >
> > </t:ajaxformloop>
> >
> > <input type="submit" value="Update"/>
> >
> >
> > As soon as I add the zone parameter to the 1st select & reload, I get a
> NPE
> > when I attempt to change the value in the 1st select.  It claims that the
> > currentSetting value is null when attempting to evaluate
> > currentSetting.fileMetadataType.
> >
> > What am I doing wrong?
> >
>

Re: updating a zone inside of an ajaxformloop

Posted by Taha Hafeez <ta...@gmail.com>.
Hi Ray,

Where are you initializing currentSetting.fileMetadataTyp?e and is this
value @Persisted as you are using it across multiple requests.

regards
Taha

On Mon, Jul 11, 2011 at 9:19 PM, Ray Nicholus <rn...@widen.com> wrote:

> Here is a fragment of some template code inside of a tapestry form:
>
> <t:ajaxformloop t:id="existingAutoImportSettings" source="existingSettings"
> value="currentSetting">
>  <t:label for="typeSelect"/>
> <t:select t:id="typeSelect" zone="fileMetadataSelectZone"
> value="currentSetting.fileMetadataType" label="${message:type}"/>
>
> <t:zone t:id="fileMetadataSelectZone">
> <t:label for="fileMetadataSelect"/>
>  <t:select t:id="fileMetadataSelect"
> value="currentSetting.fileMetadataObject"
>  model="autoImportFileMetadataModel" label="${message:file-metadata}"/>
>  </t:zone>
>
>                                          ..........
>
> </t:ajaxformloop>
>
> <input type="submit" value="Update"/>
>
>
> As soon as I add the zone parameter to the 1st select & reload, I get a NPE
> when I attempt to change the value in the 1st select.  It claims that the
> currentSetting value is null when attempting to evaluate
> currentSetting.fileMetadataType.
>
> What am I doing wrong?
>