You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christopher Gardner <ch...@gmail.com> on 2007/10/03 15:03:37 UTC

Adding a Link for a Whole ListItem

With a ListView is there a way to actually create a Link component
that encompasses the whole ListItem, such that when you click anywhere
on a row the onClick event is fired?  I know you can do this with Ajax
support, but I'm curious if you can do this using the traditional way,
i.e., with a full page refresh.  I don't want to add a "click here"
button to my row.

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


Re: Adding a Link for a Whole ListItem

Posted by Christopher Gardner <ch...@gmail.com>.
I'm continuing to experiment with making a click of a row do a page
refresh.  I coded up a class called LinkableListView that uses a
LinkableListItem, which implements ILinkListener.  When the
LinkableListItem's onLinkedClick() is called, LinkableListItem
delegates back to LinkableListView.onClick().

Here is the what my LinkableListView generates for the 2 <tr>'s.

<!-- for row zero -->
...
 <tr onclick="window.location.href='?wicket:interface=:0:plan:0:::ILinkListener::';return
false;">
...
<!-- for row one -->
<tr onclick="window.location.href='?wicket:interface=:0:plan:1:::ILinkListener::';return
false;">

To use this component, I created a very simple page with two tables.

One table contains a list of objects fetched from memory.  These
objects are fetched only once (at WebPage construction time).  Now
when I click on a row, I want the data from the LinkableListItem in
the selected row to be popped over to the second table which is
designed to hold only a single row.

In this simple page, EVERY time I click on a row in table 1, I get the
page expired message.  I'm new to Wicket, so please forgive and blot
out my ignorance.


On 10/4/07, swaroop belur <sw...@gmail.com> wrote:
>
>
> Look up how requesttargets work in wicket. In particular
> look up ListenerInterfaceRequestTarget for this use case.
> It just knows how to call ur component(link for example)
> in ur page object. Call will land in onLinkClicked.
>
> -swaroop
>
>
>
>
>
>
> Christopher Gardner-2 wrote:
> >
> > Thank you.  I got this to work.  Now I'm wondering how the
> > ILinkListener gets registered to pick up the event.  Does anything
> > that happens to implement that interface automatically get registered?
> >
> > On 10/3/07, Martijn Dashorst <ma...@gmail.com> wrote:
> >> Yes, but odds are you already had to do that, to override populateItem().
> >>
> >> Martijn
> >>
> >> On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> >> > Do you also have to subclass ListView (overriding newItem()) to create
> >> > an object of the ListItem subclass?
> >> >
> >> > On 10/3/07, Maurice Marrink <ma...@gmail.com> wrote:
> >> > > Yes you can, The trick is to extend ListItem and have it implement
> >> > > ILinkListener you can then add the onclick behavior through an
> >> > > attributemodifier or override oncomponenttag. To prevent having to
> >> > > make a subclass per page you should make the onLinkClicked method in
> >> > > your listitem redirect to a method in your listview.
> >> > >
> >> > > I could show you our code but it is cluttered with non relevant code,
> >> > > and the above really says it all.
> >> > >
> >> > > Maurice
> >> > >
> >> > > On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> >> > > > With a ListView is there a way to actually create a Link component
> >> > > > that encompasses the whole ListItem, such that when you click
> >> anywhere
> >> > > > on a row the onClick event is fired?  I know you can do this with
> >> Ajax
> >> > > > support, but I'm curious if you can do this using the traditional
> >> way,
> >> > > > i.e., with a full page refresh.  I don't want to add a "click here"
> >> > > > button to my row.
> >> > > >
> >> > > >
> >> ---------------------------------------------------------------------
> >> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > > > For additional commands, e-mail: users-help@wicket.apache.org
> >> > > >
> >> > > >
> >> > >
> >> > > ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > > For additional commands, e-mail: users-help@wicket.apache.org
> >> > >
> >> > >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> Buy Wicket in Action: http://manning.com/dashorst
> >> Apache Wicket 1.3.0-beta3 is released
> >> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-a-Link-for-a-Whole-ListItem-tf4561727.html#a13032210
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Adding a Link for a Whole ListItem

Posted by swaroop belur <sw...@gmail.com>.

Look up how requesttargets work in wicket. In particular
look up ListenerInterfaceRequestTarget for this use case.
It just knows how to call ur component(link for example)
in ur page object. Call will land in onLinkClicked.

-swaroop






Christopher Gardner-2 wrote:
> 
> Thank you.  I got this to work.  Now I'm wondering how the
> ILinkListener gets registered to pick up the event.  Does anything
> that happens to implement that interface automatically get registered?
> 
> On 10/3/07, Martijn Dashorst <ma...@gmail.com> wrote:
>> Yes, but odds are you already had to do that, to override populateItem().
>>
>> Martijn
>>
>> On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
>> > Do you also have to subclass ListView (overriding newItem()) to create
>> > an object of the ListItem subclass?
>> >
>> > On 10/3/07, Maurice Marrink <ma...@gmail.com> wrote:
>> > > Yes you can, The trick is to extend ListItem and have it implement
>> > > ILinkListener you can then add the onclick behavior through an
>> > > attributemodifier or override oncomponenttag. To prevent having to
>> > > make a subclass per page you should make the onLinkClicked method in
>> > > your listitem redirect to a method in your listview.
>> > >
>> > > I could show you our code but it is cluttered with non relevant code,
>> > > and the above really says it all.
>> > >
>> > > Maurice
>> > >
>> > > On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
>> > > > With a ListView is there a way to actually create a Link component
>> > > > that encompasses the whole ListItem, such that when you click
>> anywhere
>> > > > on a row the onClick event is fired?  I know you can do this with
>> Ajax
>> > > > support, but I'm curious if you can do this using the traditional
>> way,
>> > > > i.e., with a full page refresh.  I don't want to add a "click here"
>> > > > button to my row.
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > > > For additional commands, e-mail: users-help@wicket.apache.org
>> > > >
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>>
>> --
>> Buy Wicket in Action: http://manning.com/dashorst
>> Apache Wicket 1.3.0-beta3 is released
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-a-Link-for-a-Whole-ListItem-tf4561727.html#a13032210
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Adding a Link for a Whole ListItem

Posted by Christopher Gardner <ch...@gmail.com>.
Thank you.  I got this to work.  Now I'm wondering how the
ILinkListener gets registered to pick up the event.  Does anything
that happens to implement that interface automatically get registered?

On 10/3/07, Martijn Dashorst <ma...@gmail.com> wrote:
> Yes, but odds are you already had to do that, to override populateItem().
>
> Martijn
>
> On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> > Do you also have to subclass ListView (overriding newItem()) to create
> > an object of the ListItem subclass?
> >
> > On 10/3/07, Maurice Marrink <ma...@gmail.com> wrote:
> > > Yes you can, The trick is to extend ListItem and have it implement
> > > ILinkListener you can then add the onclick behavior through an
> > > attributemodifier or override oncomponenttag. To prevent having to
> > > make a subclass per page you should make the onLinkClicked method in
> > > your listitem redirect to a method in your listview.
> > >
> > > I could show you our code but it is cluttered with non relevant code,
> > > and the above really says it all.
> > >
> > > Maurice
> > >
> > > On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> > > > With a ListView is there a way to actually create a Link component
> > > > that encompasses the whole ListItem, such that when you click anywhere
> > > > on a row the onClick event is fired?  I know you can do this with Ajax
> > > > support, but I'm curious if you can do this using the traditional way,
> > > > i.e., with a full page refresh.  I don't want to add a "click here"
> > > > button to my row.
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Buy Wicket in Action: http://manning.com/dashorst
> Apache Wicket 1.3.0-beta3 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Adding a Link for a Whole ListItem

Posted by Martijn Dashorst <ma...@gmail.com>.
Yes, but odds are you already had to do that, to override populateItem().

Martijn

On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> Do you also have to subclass ListView (overriding newItem()) to create
> an object of the ListItem subclass?
>
> On 10/3/07, Maurice Marrink <ma...@gmail.com> wrote:
> > Yes you can, The trick is to extend ListItem and have it implement
> > ILinkListener you can then add the onclick behavior through an
> > attributemodifier or override oncomponenttag. To prevent having to
> > make a subclass per page you should make the onLinkClicked method in
> > your listitem redirect to a method in your listview.
> >
> > I could show you our code but it is cluttered with non relevant code,
> > and the above really says it all.
> >
> > Maurice
> >
> > On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> > > With a ListView is there a way to actually create a Link component
> > > that encompasses the whole ListItem, such that when you click anywhere
> > > on a row the onClick event is fired?  I know you can do this with Ajax
> > > support, but I'm curious if you can do this using the traditional way,
> > > i.e., with a full page refresh.  I don't want to add a "click here"
> > > button to my row.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/

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


Re: Adding a Link for a Whole ListItem

Posted by Christopher Gardner <ch...@gmail.com>.
Do you also have to subclass ListView (overriding newItem()) to create
an object of the ListItem subclass?

On 10/3/07, Maurice Marrink <ma...@gmail.com> wrote:
> Yes you can, The trick is to extend ListItem and have it implement
> ILinkListener you can then add the onclick behavior through an
> attributemodifier or override oncomponenttag. To prevent having to
> make a subclass per page you should make the onLinkClicked method in
> your listitem redirect to a method in your listview.
>
> I could show you our code but it is cluttered with non relevant code,
> and the above really says it all.
>
> Maurice
>
> On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> > With a ListView is there a way to actually create a Link component
> > that encompasses the whole ListItem, such that when you click anywhere
> > on a row the onClick event is fired?  I know you can do this with Ajax
> > support, but I'm curious if you can do this using the traditional way,
> > i.e., with a full page refresh.  I don't want to add a "click here"
> > button to my row.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Adding a Link for a Whole ListItem

Posted by Maurice Marrink <ma...@gmail.com>.
Yes you can, The trick is to extend ListItem and have it implement
ILinkListener you can then add the onclick behavior through an
attributemodifier or override oncomponenttag. To prevent having to
make a subclass per page you should make the onLinkClicked method in
your listitem redirect to a method in your listview.

I could show you our code but it is cluttered with non relevant code,
and the above really says it all.

Maurice

On 10/3/07, Christopher Gardner <ch...@gmail.com> wrote:
> With a ListView is there a way to actually create a Link component
> that encompasses the whole ListItem, such that when you click anywhere
> on a row the onClick event is fired?  I know you can do this with Ajax
> support, but I'm curious if you can do this using the traditional way,
> i.e., with a full page refresh.  I don't want to add a "click here"
> button to my row.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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