You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tim Sawyer <li...@calidris.co.uk> on 2007/05/05 23:32:15 UTC

T5: Same event from multiple components

Hi folks,

I had a complex if/then structure in my component's html template, such that I 
want to render different things under different conditions.  Two of the 
conditions will result in logins, but with different link text.

I therefore found myself wanting to do:

  @OnEvent(component="login")
  public Login login()
  {
    // ...
  }

in my code, but I can't have the id of both ActionLink components 
being "login"

<a href="#" t:type="actionLink" t:id="login">login one way</a>
<a href="#" t:type="actionLink" t:id="login">login another</a>

I therefore ended up having different ids in my html, and trying to catch them 
both with annotations which didn't seem to work either.

Can someone point me in the right direction please?  Or is this not possible 
and I have to write another method for the second login link?

ta,

Tim.

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


Re: T5: Same event from multiple components

Posted by Howard Lewis Ship <hl...@gmail.com>.
Yes, the extra method is not bad, though I'm not too happy with the URL
itself (T5 URLs are approaching what a handle-tooled RESTful URL would look
like). But as an action request URL, it's somewhat transitory.

On 5/6/07, Tim Sawyer <li...@calidris.co.uk> wrote:
>
> Thanks for that - that's where I ended up myself.  I wondered if it was
> possible to get away without having to do the onActionFromLogin2() method,
> but it's not exactly difficult to write!
>
> ta,
>
> Tim.
>
> On Sunday 06 May 2007 02:08, Howard Lewis Ship wrote:
> > You can capture the action even from multiple components:
> >
> > void onAction() { ... }
> >
> > But you probably have more than one component that will fire action
> events
> > and you don't want all of them to cause a login, so:
> >
> > void onActionFromLogin() { ...}
> >
> > Now, you have a second component on your page; component ids have to be
> > unique, so this other component needs its own id:
> >
> > <t:actionlink t:id="login2">login another</t:actionlink>
> >
> > and
> >
> > void onActionFromLogin2() { return onActionFromLogin(); }
> >
> > On 5/5/07, Tim Sawyer <li...@calidris.co.uk> wrote:
> > > Hi folks,
> > >
> > > I had a complex if/then structure in my component's html template,
> such
> > > that I
> > > want to render different things under different conditions.  Two of
> the
> > > conditions will result in logins, but with different link text.
> > >
> > > I therefore found myself wanting to do:
> > >
> > >   @OnEvent(component="login")
> > >   public Login login()
> > >   {
> > >     // ...
> > >   }
> > >
> > > in my code, but I can't have the id of both ActionLink components
> > > being "login"
> > >
> > > <a href="#" t:type="actionLink" t:id="login">login one way</a>
> > > <a href="#" t:type="actionLink" t:id="login">login another</a>
> > >
> > > I therefore ended up having different ids in my html, and trying to
> catch
> > > them
> > > both with annotations which didn't seem to work either.
> > >
> > > Can someone point me in the right direction please?  Or is this not
> > > possible
> > > and I have to write another method for the second login link?
> > >
> > > ta,
> > >
> > > Tim.
> > >
> > > ---------------------------------------------------------------------
> > > 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
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: T5: Same event from multiple components

Posted by Tim Sawyer <li...@calidris.co.uk>.
Thanks for that - that's where I ended up myself.  I wondered if it was 
possible to get away without having to do the onActionFromLogin2() method, 
but it's not exactly difficult to write!

ta,

Tim.

On Sunday 06 May 2007 02:08, Howard Lewis Ship wrote:
> You can capture the action even from multiple components:
>
> void onAction() { ... }
>
> But you probably have more than one component that will fire action events
> and you don't want all of them to cause a login, so:
>
> void onActionFromLogin() { ...}
>
> Now, you have a second component on your page; component ids have to be
> unique, so this other component needs its own id:
>
> <t:actionlink t:id="login2">login another</t:actionlink>
>
> and
>
> void onActionFromLogin2() { return onActionFromLogin(); }
>
> On 5/5/07, Tim Sawyer <li...@calidris.co.uk> wrote:
> > Hi folks,
> >
> > I had a complex if/then structure in my component's html template, such
> > that I
> > want to render different things under different conditions.  Two of the
> > conditions will result in logins, but with different link text.
> >
> > I therefore found myself wanting to do:
> >
> >   @OnEvent(component="login")
> >   public Login login()
> >   {
> >     // ...
> >   }
> >
> > in my code, but I can't have the id of both ActionLink components
> > being "login"
> >
> > <a href="#" t:type="actionLink" t:id="login">login one way</a>
> > <a href="#" t:type="actionLink" t:id="login">login another</a>
> >
> > I therefore ended up having different ids in my html, and trying to catch
> > them
> > both with annotations which didn't seem to work either.
> >
> > Can someone point me in the right direction please?  Or is this not
> > possible
> > and I have to write another method for the second login link?
> >
> > ta,
> >
> > Tim.
> >
> > ---------------------------------------------------------------------
> > 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: T5: Same event from multiple components

Posted by Howard Lewis Ship <hl...@gmail.com>.
You can capture the action even from multiple components:

void onAction() { ... }

But you probably have more than one component that will fire action events
and you don't want all of them to cause a login, so:

void onActionFromLogin() { ...}

Now, you have a second component on your page; component ids have to be
unique, so this other component needs its own id:

<t:actionlink t:id="login2">login another</t:actionlink>

and

void onActionFromLogin2() { return onActionFromLogin(); }



On 5/5/07, Tim Sawyer <li...@calidris.co.uk> wrote:
>
> Hi folks,
>
> I had a complex if/then structure in my component's html template, such
> that I
> want to render different things under different conditions.  Two of the
> conditions will result in logins, but with different link text.
>
> I therefore found myself wanting to do:
>
>   @OnEvent(component="login")
>   public Login login()
>   {
>     // ...
>   }
>
> in my code, but I can't have the id of both ActionLink components
> being "login"
>
> <a href="#" t:type="actionLink" t:id="login">login one way</a>
> <a href="#" t:type="actionLink" t:id="login">login another</a>
>
> I therefore ended up having different ids in my html, and trying to catch
> them
> both with annotations which didn't seem to work either.
>
> Can someone point me in the right direction please?  Or is this not
> possible
> and I have to write another method for the second login link?
>
> ta,
>
> Tim.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com