You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dmitry Shyshkin <sh...@devoler.com> on 2008/03/06 16:05:36 UTC

T4: EventListener on multiple elements

Hello, All.

I want to apply the only @EventListener("onchange") for multiple form 
elements (say checkboxes or selectboxes). Each of them is placed into 
his own row in the table (table is not a component, it's formed using 
@For by <tr>). But the problem here is that I do not know how many table 
rows I will have in the table so can't specify explicit targets/elements 
for @EventListener annotation (because I do not know its identifiers). 
I'd also like to get informed about the source of the event (table row 
id for example).

Thanks in advance.

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


Re: T4: EventListener on multiple elements

Posted by Andreas Andreou <an...@gmail.com>.
I think i was just printing the value parameter of @For inside the
EventListener enhanced listener, and was always seeing the value
of the last iteration (btw, without using BrowserEvent ).

But, I will recheck and try to come up with a testcase this weekend.


On Thu, Mar 6, 2008 at 10:19 PM, Jesse Kuhnert <jk...@gmail.com> wrote:
> I'm not sure.
>
>  In my case the rows are rendered within a @For loop over a list of
>  objects.   When my listener is invoked the object that was the
>  "current object" during that loop iteration is still the current
>  object when the listener is invoked so it works for me as expected.
>
>  The BrowserEvent should also contain the client side ID assigned to
>  the node in question and other misc information...
>
>  Is there something else missing?
>
>
>
>  On Thu, Mar 6, 2008 at 2:51 PM, Andreas Andreou <an...@gmail.com> wrote:
>  > Jesse, correct me if i'm wrong, but I believe that defaultChecked
>  >  will be triggered after the rewind, so, it will not be possible to know
>  >  at which iteration this took place (or get values the way they were
>  >  at that iteration).
>  >
>  >  So, this really reminds me of
>  >  http://article.gmane.org/gmane.comp.java.tapestry.user/58049/
>  >  and i don't have a workaround for that...
>  >
>  >  Any ideas?
>  >
>  >
>  >
>  >
>  >  On Thu, Mar 6, 2008 at 9:27 PM, Jesse Kuhnert <jk...@gmail.com> wrote:
>  >  > I'm not sure how you have your page set up but this is all I have to
>  >  >  do in a similar situation:
>  >  >
>  >  >
>  >  >  @EventListener(targets = "publishByDefault", events = {"onclick", "onchange"})
>  >  >  public void defaultChecked() {
>  >  >  ...
>  >  >  }
>  >  >
>  >  >  ...
>  >  >  <td align="center">
>  >  >        <input jwcid="publishByDefault@Checkbox"
>  >  >  value="ognl:publisher.usedByDefault" class="checkbox"/>
>  >  >  </td>
>  >  >  ..
>  >  >
>  >  >  It's listening to both onclick/onchange because IE doesn't fire
>  >  >  onchange events for checkboxes.   The checkbox component is rendered
>  >  >  in a looop as well so,  it should probably be as easy as this for you
>  >  >  to do it.  (though anytime someone says something is easy it always
>  >  >  ends up biting them, so let's say it should be straightforward in most
>  >  >  cases to be safe ;) )
>  >  >
>  >  >
>  >  >
>  >  >  On Thu, Mar 6, 2008 at 10:05 AM, Dmitry Shyshkin <sh...@devoler.com> wrote:
>  >  >  > Hello, All.
>  >  >  >
>  >  >  >  I want to apply the only @EventListener("onchange") for multiple form
>  >  >  >  elements (say checkboxes or selectboxes). Each of them is placed into
>  >  >  >  his own row in the table (table is not a component, it's formed using
>  >  >  >  @For by <tr>). But the problem here is that I do not know how many table
>  >  >  >  rows I will have in the table so can't specify explicit targets/elements
>  >  >  >  for @EventListener annotation (because I do not know its identifiers).
>  >  >  >  I'd also like to get informed about the source of the event (table row
>  >  >  >  id for example).
>  >  >  >
>  >  >  >  Thanks in advance.
>  >  >  >
>  >  >  >  ---------------------------------------------------------------------
>  >  >  >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  >  >  >  For additional commands, e-mail: users-help@tapestry.apache.org
>  >  >  >
>  >  >  >
>  >  >
>  >  >
>  >  >
>  >  >  --
>  >  >  Jesse Kuhnert
>  >  >  Tapestry / OGNL / 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
>  >  >
>  >  >
>  >
>  >
>  >
>  >  --
>  >  Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
>  >  Tapestry / Tacos developer
>  >  Open Source / JEE Consulting
>  >
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  >  For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>
>
>
>  --
>  Jesse Kuhnert
>  Tapestry / OGNL / 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
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: T4: EventListener on multiple elements

Posted by Jesse Kuhnert <jk...@gmail.com>.
I'm not sure.

In my case the rows are rendered within a @For loop over a list of
objects.   When my listener is invoked the object that was the
"current object" during that loop iteration is still the current
object when the listener is invoked so it works for me as expected.

The BrowserEvent should also contain the client side ID assigned to
the node in question and other misc information...

Is there something else missing?

On Thu, Mar 6, 2008 at 2:51 PM, Andreas Andreou <an...@gmail.com> wrote:
> Jesse, correct me if i'm wrong, but I believe that defaultChecked
>  will be triggered after the rewind, so, it will not be possible to know
>  at which iteration this took place (or get values the way they were
>  at that iteration).
>
>  So, this really reminds me of
>  http://article.gmane.org/gmane.comp.java.tapestry.user/58049/
>  and i don't have a workaround for that...
>
>  Any ideas?
>
>
>
>
>  On Thu, Mar 6, 2008 at 9:27 PM, Jesse Kuhnert <jk...@gmail.com> wrote:
>  > I'm not sure how you have your page set up but this is all I have to
>  >  do in a similar situation:
>  >
>  >
>  >  @EventListener(targets = "publishByDefault", events = {"onclick", "onchange"})
>  >  public void defaultChecked() {
>  >  ...
>  >  }
>  >
>  >  ...
>  >  <td align="center">
>  >        <input jwcid="publishByDefault@Checkbox"
>  >  value="ognl:publisher.usedByDefault" class="checkbox"/>
>  >  </td>
>  >  ..
>  >
>  >  It's listening to both onclick/onchange because IE doesn't fire
>  >  onchange events for checkboxes.   The checkbox component is rendered
>  >  in a looop as well so,  it should probably be as easy as this for you
>  >  to do it.  (though anytime someone says something is easy it always
>  >  ends up biting them, so let's say it should be straightforward in most
>  >  cases to be safe ;) )
>  >
>  >
>  >
>  >  On Thu, Mar 6, 2008 at 10:05 AM, Dmitry Shyshkin <sh...@devoler.com> wrote:
>  >  > Hello, All.
>  >  >
>  >  >  I want to apply the only @EventListener("onchange") for multiple form
>  >  >  elements (say checkboxes or selectboxes). Each of them is placed into
>  >  >  his own row in the table (table is not a component, it's formed using
>  >  >  @For by <tr>). But the problem here is that I do not know how many table
>  >  >  rows I will have in the table so can't specify explicit targets/elements
>  >  >  for @EventListener annotation (because I do not know its identifiers).
>  >  >  I'd also like to get informed about the source of the event (table row
>  >  >  id for example).
>  >  >
>  >  >  Thanks in advance.
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  >  >  For additional commands, e-mail: users-help@tapestry.apache.org
>  >  >
>  >  >
>  >
>  >
>  >
>  >  --
>  >  Jesse Kuhnert
>  >  Tapestry / OGNL / 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
>  >
>  >
>
>
>
>  --
>  Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
>  Tapestry / Tacos developer
>  Open Source / JEE Consulting
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Jesse Kuhnert
Tapestry / OGNL / 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


Re: T4: EventListener on multiple elements

Posted by Andreas Andreou <an...@gmail.com>.
Jesse, correct me if i'm wrong, but I believe that defaultChecked
will be triggered after the rewind, so, it will not be possible to know
at which iteration this took place (or get values the way they were
at that iteration).

So, this really reminds me of
http://article.gmane.org/gmane.comp.java.tapestry.user/58049/
and i don't have a workaround for that...

Any ideas?


On Thu, Mar 6, 2008 at 9:27 PM, Jesse Kuhnert <jk...@gmail.com> wrote:
> I'm not sure how you have your page set up but this is all I have to
>  do in a similar situation:
>
>
>  @EventListener(targets = "publishByDefault", events = {"onclick", "onchange"})
>  public void defaultChecked() {
>  ...
>  }
>
>  ...
>  <td align="center">
>        <input jwcid="publishByDefault@Checkbox"
>  value="ognl:publisher.usedByDefault" class="checkbox"/>
>  </td>
>  ..
>
>  It's listening to both onclick/onchange because IE doesn't fire
>  onchange events for checkboxes.   The checkbox component is rendered
>  in a looop as well so,  it should probably be as easy as this for you
>  to do it.  (though anytime someone says something is easy it always
>  ends up biting them, so let's say it should be straightforward in most
>  cases to be safe ;) )
>
>
>
>  On Thu, Mar 6, 2008 at 10:05 AM, Dmitry Shyshkin <sh...@devoler.com> wrote:
>  > Hello, All.
>  >
>  >  I want to apply the only @EventListener("onchange") for multiple form
>  >  elements (say checkboxes or selectboxes). Each of them is placed into
>  >  his own row in the table (table is not a component, it's formed using
>  >  @For by <tr>). But the problem here is that I do not know how many table
>  >  rows I will have in the table so can't specify explicit targets/elements
>  >  for @EventListener annotation (because I do not know its identifiers).
>  >  I'd also like to get informed about the source of the event (table row
>  >  id for example).
>  >
>  >  Thanks in advance.
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  >  For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>
>
>
>  --
>  Jesse Kuhnert
>  Tapestry / OGNL / 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
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: T4: EventListener on multiple elements

Posted by Jesse Kuhnert <jk...@gmail.com>.
I'm not sure how you have your page set up but this is all I have to
do in a similar situation:


@EventListener(targets = "publishByDefault", events = {"onclick", "onchange"})
public void defaultChecked() {
...
}

...
<td align="center">
       <input jwcid="publishByDefault@Checkbox"
value="ognl:publisher.usedByDefault" class="checkbox"/>
</td>
..

It's listening to both onclick/onchange because IE doesn't fire
onchange events for checkboxes.   The checkbox component is rendered
in a looop as well so,  it should probably be as easy as this for you
to do it.  (though anytime someone says something is easy it always
ends up biting them, so let's say it should be straightforward in most
cases to be safe ;) )

On Thu, Mar 6, 2008 at 10:05 AM, Dmitry Shyshkin <sh...@devoler.com> wrote:
> Hello, All.
>
>  I want to apply the only @EventListener("onchange") for multiple form
>  elements (say checkboxes or selectboxes). Each of them is placed into
>  his own row in the table (table is not a component, it's formed using
>  @For by <tr>). But the problem here is that I do not know how many table
>  rows I will have in the table so can't specify explicit targets/elements
>  for @EventListener annotation (because I do not know its identifiers).
>  I'd also like to get informed about the source of the event (table row
>  id for example).
>
>  Thanks in advance.
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Jesse Kuhnert
Tapestry / OGNL / 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