You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tony Nelson <tn...@starpoint.com> on 2007/05/03 18:45:53 UTC

Tap 4.1.2 EventListener

Is it possible to use an EventListener in a component that is displayed 
multiple times on a page?

Specifically, I would like a component that has 2 inputs, and when the 
1st one is updated an onchange event causes the 2nd component to update 
it's value.  From my testing, it appears that only the first component 
responds to a change event (meaning causes my java method to be called), 
and when it's called, I don't seem to have access to the updated values.

My component in progress looks like:

<input jwcid="jobExportId@Hidden" value="ognl:jobExportValues.id" />
<input jwcid="externalJobBoard@Hidden" 
value="ognl:jobExportValues.externalJobBoard" />
<input jwcid="jobIdField" value="ognl:jobExportValues.jobId" size="5" />

And I register the EventListener in the component as follows:

    @EventListener(events={"onchange"}, targets="jobIdField")
    public void testEvent()
    {
        logger.debug("LOOKHERE... " + getJobExportValues().getJobId() + 
" " + getJobExportValues().getId());
    }


When the listener is actually called, I always get NULL for both 
values.  And again, the listener only fires for the first component on 
the page.

Looking at the page source, it appears that dojo code for all of my 
inputs is being generated which I won't include here due to it's length.

Any help would be greatly appreciated.  Am I just missing the whole 
concept on the new dojo stuff?

Tony


Re: Tap 4.1.2 EventListener

Posted by Jesse Kuhnert <jk...@gmail.com>.
You should expect it to behave exactly the same way as it would if you had
just submitted the form normally without any ajax stuff.

In your case you are probably looking for the value to be in a temporary
property you use when iterating over your values in a For loop - when really
the value will have already been updated inside of whatever your original
"source" parameter was to the For. (assuming it's able to figure out which
one it was in case you haven't used a converter / something else )

On 5/3/07, Tony Nelson <tn...@starpoint.com> wrote:
>
> I grabbed the latest snapshot and now the callback is getting called for
> all of my inputs.  Thank you very much.
>
> I still get NULL as the value, but I think that's my fault.  I'm going
> to have to do some serious thinking about how this page works.
>
> For my understanding, when the "onchange" event fires, what data should
> I expect to be posted back to the server?  The entire form?  Or just the
> changed field?  Reading all the logging that I have in my page, it
> appears as though the entire page is being reconstructed (like a
> rewind?) on the back end.  Is that normal?  Should I expect that?
>
> I'm going to have to add even more logging, but should I expect
> pageBeginRender() to be called?  I would expect not.. but I might be
> wrong.
>
> I can see that Tapestry is definitely evaluating the entire template
> because of all the logging I get just updating one field in the browser,
> and I guess that might be necessary, I just need to figure out what the
> consequences of that will be on my code.
>
> Thanks for all your help
> Tony
>
> Jesse Kuhnert wrote:
> > Yes the feeling was correct. The snapshot version should be fixed and
> > deployed already.
> >
> > Sorry for the inconvenience,  you caught me in the middle of some larger
> > changes and I guess this use case was a victim.
> >
> > On 5/3/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> >>
> >> Hmm...I have a bad feeling this is my fault - obviously it should work
> >> fine as-is. I'll take a look...
> >>
> >> On 5/3/07, Tony Nelson < tnelson@starpoint.com> wrote:
> >> >
> >> > A little additional info.. when I change the value on any of the
> >> inputs
> >> > beyond the first one, it is causing the form to be submitted, it just
> >> > doesn't call my EventListener method.  Also, I am using the latest
> >> > (today's) Tapestry build.
> >> >
> >> > Thanks again
> >> > Tony
> >> >
> >> > Tony Nelson wrote:
> >> > > Is it possible to use an EventListener in a component that is
> >> > > displayed multiple times on a page?
> >> > >
> >> > > Specifically, I would like a component that has 2 inputs, and
> >> when the
> >> > > 1st one is updated an onchange event causes the 2nd component to
> >> > > update it's value.  From my testing, it appears that only the first
> >> > > component responds to a change event (meaning causes my java
> >> method to
> >> > > be called), and when it's called, I don't seem to have access to
> the
> >> > > updated values.
> >> > >
> >> > > My component in progress looks like:
> >> > >
> >> > > <input jwcid="jobExportId@Hidden" value="ognl:jobExportValues.id"
> />
> >> > > <input jwcid="externalJobBoard@Hidden "
> >> > > value="ognl:jobExportValues.externalJobBoard" />
> >> > > <input jwcid="jobIdField" value="ognl:jobExportValues.jobId"
> >> size="5"
> >> > />
> >> > >
> >> > > And I register the EventListener in the component as follows:
> >> > >
> >> > >    @EventListener(events={"onchange"}, targets="jobIdField")
> >> > >    public void testEvent()
> >> > >    {
> >> > >        logger.debug("LOOKHERE... " +
> >> getJobExportValues().getJobId() +
> >> >
> >> > > " " + getJobExportValues().getId());
> >> > >    }
> >> > >
> >> > >
> >> > > When the listener is actually called, I always get NULL for both
> >> > > values.  And again, the listener only fires for the first
> >> component on
> >> >
> >> > > the page.
> >> > >
> >> > > Looking at the page source, it appears that dojo code for all of my
> >> > > inputs is being generated which I won't include here due to it's
> >> > length.
> >> > >
> >> > > Any help would be greatly appreciated.  Am I just missing the whole
> >> > > concept on the new dojo stuff?
> >> > >
> >> > > Tony
> >> > >
> >> > >
> >> >
> >>
> ------------------------------------------------------------------------
> >> > >
> >> > >
> >> ---------------------------------------------------------------------
> >> > > 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
> >> >
> >>
> >>
> >>
> >> --
> >> Jesse Kuhnert
> >> Tapestry/Dojo team member/developer
> >>
> >> Open source based consulting work centered around
> >> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: Tap 4.1.2 EventListener

Posted by Tony Nelson <tn...@starpoint.com>.
I grabbed the latest snapshot and now the callback is getting called for 
all of my inputs.  Thank you very much. 

I still get NULL as the value, but I think that's my fault.  I'm going 
to have to do some serious thinking about how this page works.

For my understanding, when the "onchange" event fires, what data should 
I expect to be posted back to the server?  The entire form?  Or just the 
changed field?  Reading all the logging that I have in my page, it 
appears as though the entire page is being reconstructed (like a 
rewind?) on the back end.  Is that normal?  Should I expect that?

I'm going to have to add even more logging, but should I expect 
pageBeginRender() to be called?  I would expect not.. but I might be wrong.

I can see that Tapestry is definitely evaluating the entire template 
because of all the logging I get just updating one field in the browser, 
and I guess that might be necessary, I just need to figure out what the 
consequences of that will be on my code.

Thanks for all your help
Tony

Jesse Kuhnert wrote:
> Yes the feeling was correct. The snapshot version should be fixed and
> deployed already.
>
> Sorry for the inconvenience,  you caught me in the middle of some larger
> changes and I guess this use case was a victim.
>
> On 5/3/07, Jesse Kuhnert <jk...@gmail.com> wrote:
>>
>> Hmm...I have a bad feeling this is my fault - obviously it should work
>> fine as-is. I'll take a look...
>>
>> On 5/3/07, Tony Nelson < tnelson@starpoint.com> wrote:
>> >
>> > A little additional info.. when I change the value on any of the 
>> inputs
>> > beyond the first one, it is causing the form to be submitted, it just
>> > doesn't call my EventListener method.  Also, I am using the latest
>> > (today's) Tapestry build.
>> >
>> > Thanks again
>> > Tony
>> >
>> > Tony Nelson wrote:
>> > > Is it possible to use an EventListener in a component that is
>> > > displayed multiple times on a page?
>> > >
>> > > Specifically, I would like a component that has 2 inputs, and 
>> when the
>> > > 1st one is updated an onchange event causes the 2nd component to
>> > > update it's value.  From my testing, it appears that only the first
>> > > component responds to a change event (meaning causes my java 
>> method to
>> > > be called), and when it's called, I don't seem to have access to the
>> > > updated values.
>> > >
>> > > My component in progress looks like:
>> > >
>> > > <input jwcid="jobExportId@Hidden" value="ognl:jobExportValues.id" />
>> > > <input jwcid="externalJobBoard@Hidden "
>> > > value="ognl:jobExportValues.externalJobBoard" />
>> > > <input jwcid="jobIdField" value="ognl:jobExportValues.jobId" 
>> size="5"
>> > />
>> > >
>> > > And I register the EventListener in the component as follows:
>> > >
>> > >    @EventListener(events={"onchange"}, targets="jobIdField")
>> > >    public void testEvent()
>> > >    {
>> > >        logger.debug("LOOKHERE... " + 
>> getJobExportValues().getJobId() +
>> >
>> > > " " + getJobExportValues().getId());
>> > >    }
>> > >
>> > >
>> > > When the listener is actually called, I always get NULL for both
>> > > values.  And again, the listener only fires for the first 
>> component on
>> >
>> > > the page.
>> > >
>> > > Looking at the page source, it appears that dojo code for all of my
>> > > inputs is being generated which I won't include here due to it's
>> > length.
>> > >
>> > > Any help would be greatly appreciated.  Am I just missing the whole
>> > > concept on the new dojo stuff?
>> > >
>> > > Tony
>> > >
>> > >
>> > 
>> ------------------------------------------------------------------------
>> > >
>> > > 
>> ---------------------------------------------------------------------
>> > > 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
>> >
>>
>>
>>
>> -- 
>> Jesse Kuhnert
>> Tapestry/Dojo team member/developer
>>
>> Open source based consulting work centered around
>> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
>
>
>



Re: Tap 4.1.2 EventListener

Posted by Jesse Kuhnert <jk...@gmail.com>.
Yes the feeling was correct. The snapshot version should be fixed and
deployed already.

Sorry for the inconvenience,  you caught me in the middle of some larger
changes and I guess this use case was a victim.

On 5/3/07, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> Hmm...I have a bad feeling this is my fault - obviously it should work
> fine as-is. I'll take a look...
>
> On 5/3/07, Tony Nelson < tnelson@starpoint.com> wrote:
> >
> > A little additional info.. when I change the value on any of the inputs
> > beyond the first one, it is causing the form to be submitted, it just
> > doesn't call my EventListener method.  Also, I am using the latest
> > (today's) Tapestry build.
> >
> > Thanks again
> > Tony
> >
> > Tony Nelson wrote:
> > > Is it possible to use an EventListener in a component that is
> > > displayed multiple times on a page?
> > >
> > > Specifically, I would like a component that has 2 inputs, and when the
> > > 1st one is updated an onchange event causes the 2nd component to
> > > update it's value.  From my testing, it appears that only the first
> > > component responds to a change event (meaning causes my java method to
> > > be called), and when it's called, I don't seem to have access to the
> > > updated values.
> > >
> > > My component in progress looks like:
> > >
> > > <input jwcid="jobExportId@Hidden" value="ognl:jobExportValues.id" />
> > > <input jwcid="externalJobBoard@Hidden "
> > > value="ognl:jobExportValues.externalJobBoard" />
> > > <input jwcid="jobIdField" value="ognl:jobExportValues.jobId" size="5"
> > />
> > >
> > > And I register the EventListener in the component as follows:
> > >
> > >    @EventListener(events={"onchange"}, targets="jobIdField")
> > >    public void testEvent()
> > >    {
> > >        logger.debug("LOOKHERE... " + getJobExportValues().getJobId() +
> >
> > > " " + getJobExportValues().getId());
> > >    }
> > >
> > >
> > > When the listener is actually called, I always get NULL for both
> > > values.  And again, the listener only fires for the first component on
> >
> > > the page.
> > >
> > > Looking at the page source, it appears that dojo code for all of my
> > > inputs is being generated which I won't include here due to it's
> > length.
> > >
> > > Any help would be greatly appreciated.  Am I just missing the whole
> > > concept on the new dojo stuff?
> > >
> > > Tony
> > >
> > >
> > ------------------------------------------------------------------------
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
>
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com




-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: Tap 4.1.2 EventListener

Posted by Jesse Kuhnert <jk...@gmail.com>.
Hmm...I have a bad feeling this is my fault - obviously it should work fine
as-is. I'll take a look...

On 5/3/07, Tony Nelson <tn...@starpoint.com> wrote:
>
> A little additional info.. when I change the value on any of the inputs
> beyond the first one, it is causing the form to be submitted, it just
> doesn't call my EventListener method.  Also, I am using the latest
> (today's) Tapestry build.
>
> Thanks again
> Tony
>
> Tony Nelson wrote:
> > Is it possible to use an EventListener in a component that is
> > displayed multiple times on a page?
> >
> > Specifically, I would like a component that has 2 inputs, and when the
> > 1st one is updated an onchange event causes the 2nd component to
> > update it's value.  From my testing, it appears that only the first
> > component responds to a change event (meaning causes my java method to
> > be called), and when it's called, I don't seem to have access to the
> > updated values.
> >
> > My component in progress looks like:
> >
> > <input jwcid="jobExportId@Hidden" value="ognl:jobExportValues.id" />
> > <input jwcid="externalJobBoard@Hidden"
> > value="ognl:jobExportValues.externalJobBoard" />
> > <input jwcid="jobIdField" value="ognl:jobExportValues.jobId" size="5" />
> >
> > And I register the EventListener in the component as follows:
> >
> >    @EventListener(events={"onchange"}, targets="jobIdField")
> >    public void testEvent()
> >    {
> >        logger.debug("LOOKHERE... " + getJobExportValues().getJobId() +
> > " " + getJobExportValues().getId());
> >    }
> >
> >
> > When the listener is actually called, I always get NULL for both
> > values.  And again, the listener only fires for the first component on
> > the page.
> >
> > Looking at the page source, it appears that dojo code for all of my
> > inputs is being generated which I won't include here due to it's length.
> >
> > Any help would be greatly appreciated.  Am I just missing the whole
> > concept on the new dojo stuff?
> >
> > Tony
> >
> > ------------------------------------------------------------------------
> >
> > ---------------------------------------------------------------------
> > 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
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: Tap 4.1.2 EventListener

Posted by Tony Nelson <tn...@starpoint.com>.
A little additional info.. when I change the value on any of the inputs 
beyond the first one, it is causing the form to be submitted, it just 
doesn't call my EventListener method.  Also, I am using the latest 
(today's) Tapestry build.

Thanks again
Tony

Tony Nelson wrote:
> Is it possible to use an EventListener in a component that is 
> displayed multiple times on a page?
>
> Specifically, I would like a component that has 2 inputs, and when the 
> 1st one is updated an onchange event causes the 2nd component to 
> update it's value.  From my testing, it appears that only the first 
> component responds to a change event (meaning causes my java method to 
> be called), and when it's called, I don't seem to have access to the 
> updated values.
>
> My component in progress looks like:
>
> <input jwcid="jobExportId@Hidden" value="ognl:jobExportValues.id" />
> <input jwcid="externalJobBoard@Hidden" 
> value="ognl:jobExportValues.externalJobBoard" />
> <input jwcid="jobIdField" value="ognl:jobExportValues.jobId" size="5" />
>
> And I register the EventListener in the component as follows:
>
>    @EventListener(events={"onchange"}, targets="jobIdField")
>    public void testEvent()
>    {
>        logger.debug("LOOKHERE... " + getJobExportValues().getJobId() + 
> " " + getJobExportValues().getId());
>    }
>
>
> When the listener is actually called, I always get NULL for both 
> values.  And again, the listener only fires for the first component on 
> the page.
>
> Looking at the page source, it appears that dojo code for all of my 
> inputs is being generated which I won't include here due to it's length.
>
> Any help would be greatly appreciated.  Am I just missing the whole 
> concept on the new dojo stuff?
>
> Tony
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org