You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dlipski <da...@gmail.com> on 2008/10/28 11:33:45 UTC

DataTable cell link

Hi 

I have one short question:
How to make entire cell in a DataTable a link ?
I've read that Link component can be attached not only to &lt;a&gt; tags but
also to any other html elements (like <tr> and <td>) but I dont know how to
use it with DataTable API.

Regards Daniel
-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
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: DataTable cell link

Posted by Jeremy Thomerson <je...@wickettraining.com>.
You could use an attribute modifier to add the onclick.  If you need help
with what to generate in the onClick, see Link#onComponentTag for an
example.
-- 
Jeremy Thomerson
http://www.wickettraining.com

On Tue, Oct 28, 2008 at 8:42 AM, dlipski <da...@gmail.com> wrote:

>
> Hi
> I dont know wicketopia project (and any of its classes like FragmentColumn)
> so I can misunderstand your idea but as far as I am able to read that code
> It looks like you are adding a link to the table cell, not making a cell
> itself a link.
>
> If I understand your code it is familar to:
>
> <td>&lt;a&gt;text&lt;/a&gt;</td>
>
> but Im wondering how to achive:
> <td on click="xyz">text</td>
>
> where xyz is code generated by Wicket (like in Link component class)
>
> If I misundestood you could you give me some more details hot to make cell
> itself a link ? (not adding a link to the cell) ?
>
> Regards
> Daniel
>
>
>
> jwcarman wrote:
> >
> > Here's an example where I put a remove link in a DefaultDataTable cell:
> >
> >
> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
> >
> >
> > On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
> > wrote:
> >>
> >> Hi
> >>
> >> I have one short question:
> >> How to make entire cell in a DataTable a link ?
> >> I've read that Link component can be attached not only to &lt;a&gt; tags
> >> but
> >> also to any other html elements (like <tr> and <td>) but I dont know how
> >> to
> >> use it with DataTable API.
> >>
> >> Regards Daniel
> >> --
> >> View this message in context:
> >> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
> >> 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
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/DataTable-cell-link-tp20204702p20207438.html
>  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: DataTable cell link

Posted by James Carman <ja...@carmanconsulting.com>.
I apologize.  I must have misunderstood your question.

On Tue, Oct 28, 2008 at 9:42 AM, dlipski <da...@gmail.com> wrote:
>
> Hi
> I dont know wicketopia project (and any of its classes like FragmentColumn)
> so I can misunderstand your idea but as far as I am able to read that code
> It looks like you are adding a link to the table cell, not making a cell
> itself a link.
>
> If I understand your code it is familar to:
>
> <td>&lt;a&gt;text&lt;/a&gt;</td>
>
> but Im wondering how to achive:
> <td on click="xyz">text</td>
>
> where xyz is code generated by Wicket (like in Link component class)
>
> If I misundestood you could you give me some more details hot to make cell
> itself a link ? (not adding a link to the cell) ?
>
> Regards
> Daniel
>
>
>
> jwcarman wrote:
>>
>> Here's an example where I put a remove link in a DefaultDataTable cell:
>>
>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>
>>
>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
>> wrote:
>>>
>>> Hi
>>>
>>> I have one short question:
>>> How to make entire cell in a DataTable a link ?
>>> I've read that Link component can be attached not only to &lt;a&gt; tags
>>> but
>>> also to any other html elements (like <tr> and <td>) but I dont know how
>>> to
>>> use it with DataTable API.
>>>
>>> Regards Daniel
>>> --
>>> View this message in context:
>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>> 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
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20207438.html
> 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: DataTable cell link

Posted by dlipski <da...@gmail.com>.
That was the solution I was looking for.
I havent know that it is possible to do thinks that way !
I supose that I have to override newCellItem and newRowItem method in
DataTable class and return ClickableItem instead of Item. 

Good to know that it is possible to do this in standard Wicket way without
'magic code'. Although it works and all classes follows their contracts in
my opinion it would be more coherent and obvious if DataTable could work
with any somponent as cell/row but its only my notice...



igor.vaynberg wrote:
> 
> abstract class clickableitem extends item implements ilinklistener {
> 
>  protected oncomponenttag(tag) {
>    super....
>   
> tag.put("onclick","window.location='"+urlfor(ilinklistenerinterface.interface)+"';");
>  }
> 
> }
> 
> thats about all it takes
> 
> -igor
> 
> On Wed, Oct 29, 2008 at 4:20 AM, dlipski <da...@gmail.com>
> wrote:
>>
>> My colegue point out that for Ajax requests AjaxEventBehavior can be
>> used,
>> and it works fine. so now I need only solution for normal (non Ajax)
>> requests.
>>
>>
>> dlipski wrote:
>>>
>>> Because I havent found better solution then adding 'onclick' handler to
>>> cellItem I have to do it your way.
>>> I looked at urlFor methods in Component class and didnt found the one
>>> with
>>> Component attribute.
>>> How should I generate url for Link component, AjaxLink or
>>> AjaxFallbackLink
>>> ?
>>> Do I have to add this components to the page and set its visiblity to
>>> false ?
>>> I understand 'general concept' of this solution but dont know how to
>>> implement this in specific scenarion (ie. linking to Link, AjaxLink,
>>> AjaxFallbackLink).
>>>
>>> Using diffrent repeater could be a option but DataTable (or
>>> AjaxFallbackDefaultDataTable) provides a lot of functionality (sorting,
>>> paging, fallback links etc) so it would be a waste of time to implement
>>> its from scratch just because its hard to make a table cell (or row) a
>>> link. It must be a way to achive this... if not it serious limitation of
>>> DataTable component.
>>>
>>> Regards Daniel
>>>
>>>
>>> Jeremy Thomerson-5 wrote:
>>>>
>>>> Depending on what you are linking TO, it can be very simple.  You can
>>>> call
>>>> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone).  So, you
>>>> could
>>>> do:
>>>>
>>>> cellItem.add(new SimpleAttributeModifier("onclick", "location.href = '"
>>>> +
>>>> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone) + "'"));
>>>>
>>>> Of course, that JS could be better for triple click problems, etc.
>>>>
>>>> Really, you may just consider using another Repeater rather than
>>>> DataTable.
>>>> DataTable is for a very specific purpose, and it is often easier to
>>>> roll
>>>> your own than make DT fit your purpose.
>>>>
>>>>
>>>> --
>>>> Jeremy Thomerson
>>>> http://www.wickettraining.com
>>>>
>>>>
>>>> On Tue, Oct 28, 2008 at 2:05 PM, dlipski <da...@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>> All this solutions are correct but the problem is not in attaching
>>>>> some
>>>>> custom Javascript to <td> element (which can be done in multiple ways)
>>>>> but
>>>>> in making td element work as a link.
>>>>>
>>>>> What exactly should I do to achive this ? What components should I add
>>>>> at
>>>>> server side at what JavaScript should I render at markup ?
>>>>> If I have to copy-paste bunch of Link class code it looks like some
>>>>> design/implementation problem of DataTable (or one of components it
>>>>> has).
>>>>>
>>>>> Its really supprising that such common issue is such problematic.
>>>>> I hope there is some simple and intuitive solution(if I find one I'll
>>>>> post
>>>>> it here)
>>>>>
>>>>> Thanks for your help
>>>>> Regards Daniel
>>>>>
>>>>>
>>>>> Michael O'Cleirigh wrote:
>>>>> >
>>>>> > Hi Daniel,
>>>>> >
>>>>> > If you subclass DefaultDataTable there is a protected method call
>>>>> > newCellItem(...) that you can use to attach the onclick class onto
>>>>> the
>>>>> > <td>.
>>>>> >
>>>>> > like:
>>>>> >
>>>>> > class MyDataTable extends DefaultDataTable {
>>>>> >  /* (non-Javadoc)
>>>>> >      * @see
>>>>> >
>>>>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>>>>> > int, org.apache.wicket.model.IModel)
>>>>> >      */
>>>>> >     @Override
>>>>> >     protected Item newCellItem(String id, int index, IModel model) {
>>>>> >
>>>>> >
>>>>> >         Item cell = super.newCellItem(id, index, model);
>>>>> >
>>>>> >
>>>>> >         cell.add(new AttributeAppender("onclick", new Model
>>>>> > ("someJavascriptCall();"));
>>>>> >
>>>>> >         return cell;
>>>>> >     }
>>>>> > }
>>>>> >
>>>>> > Alternately you can use a custom column implementation like the
>>>>> > FragrementColumn and add the onclick when the cell is created like:
>>>>> >
>>>>> > class MyOnClickColumn extends AbstractColumn {
>>>>> > ...
>>>>> > public void populateItem(Item cellItem, String componentId, IModel
>>>>> > rowModel)
>>>>> >     {
>>>>> >        Label cell = new Label(componentId, new
>>>>> PropertyModel(rowModel,
>>>>> > property))
>>>>> >
>>>>> >         cell.add (new AttributeAppender("onclick", new Model
>>>>> > ("someJavascriptCall();"));
>>>>> >
>>>>> >         cellItem.add(cell);
>>>>> >     }
>>>>> > }
>>>>> >
>>>>> >
>>>>> > I think the second version would attach the onclick to the label
>>>>> within
>>>>> > the <td></td> of a cell.
>>>>> >
>>>>> > Regards,
>>>>> >
>>>>> > Mike
>>>>> >> I dont know wicketopia project (and any of its classes like
>>>>> >> FragmentColumn)
>>>>> >> so I can misunderstand your idea but as far as I am able to read
>>>>> that
>>>>> >> code
>>>>> >> It looks like you are adding a link to the table cell, not making a
>>>>> cell
>>>>> >> itself a link.
>>>>> >>
>>>>> >> If I understand your code it is familar to:
>>>>> >>
>>>>> >> <td>&lt;a&gt;text&lt;/a&gt;</td>
>>>>> >>
>>>>> >> but Im wondering how to achive:
>>>>> >> <td on click="xyz">text</td>
>>>>> >>
>>>>> >> where xyz is code generated by Wicket (like in Link component
>>>>> class)
>>>>> >>
>>>>> >> If I misundestood you could you give me some more details hot to
>>>>> make
>>>>> >> cell
>>>>> >> itself a link ? (not adding a link to the cell) ?
>>>>> >>
>>>>> >> Regards
>>>>> >> Daniel
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> jwcarman wrote:
>>>>> >>
>>>>> >>> Here's an example where I put a remove link in a DefaultDataTable
>>>>> cell:
>>>>> >>>
>>>>> >>>
>>>>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>>>> >>>
>>>>> >>>
>>>>> >>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski
>>>>> <da...@gmail.com>
>>>>> >>> wrote:
>>>>> >>>
>>>>> >>>> Hi
>>>>> >>>>
>>>>> >>>> I have one short question:
>>>>> >>>> How to make entire cell in a DataTable a link ?
>>>>> >>>> I've read that Link component can be attached not only to
>>>>> &lt;a&gt;
>>>>> >>>> tags
>>>>> >>>> but
>>>>> >>>> also to any other html elements (like <tr> and <td>) but I dont
>>>>> know
>>>>> >>>> how
>>>>> >>>> to
>>>>> >>>> use it with DataTable API.
>>>>> >>>>
>>>>> >>>> Regards Daniel
>>>>> >>>> --
>>>>> >>>> View this message in context:
>>>>> >>>>
>>>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>>>> >>>> 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
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>
>>>>> >>
>>>>> >
>>>>> >
>>>>> >
>>>>> ---------------------------------------------------------------------
>>>>> > 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/DataTable-cell-link-tp20204702p20213839.html
>>>>>  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
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/DataTable-cell-link-tp20204702p20225048.html
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20230579.html
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: DataTable cell link

Posted by Igor Vaynberg <ig...@gmail.com>.
abstract class clickableitem extends item implements ilinklistener {

 protected oncomponenttag(tag) {
   super....
   tag.put("onclick","window.location='"+urlfor(ilinklistenerinterface.interface)+"';");
 }

}

thats about all it takes

-igor

On Wed, Oct 29, 2008 at 4:20 AM, dlipski <da...@gmail.com> wrote:
>
> My colegue point out that for Ajax requests AjaxEventBehavior can be used,
> and it works fine. so now I need only solution for normal (non Ajax)
> requests.
>
>
> dlipski wrote:
>>
>> Because I havent found better solution then adding 'onclick' handler to
>> cellItem I have to do it your way.
>> I looked at urlFor methods in Component class and didnt found the one with
>> Component attribute.
>> How should I generate url for Link component, AjaxLink or AjaxFallbackLink
>> ?
>> Do I have to add this components to the page and set its visiblity to
>> false ?
>> I understand 'general concept' of this solution but dont know how to
>> implement this in specific scenarion (ie. linking to Link, AjaxLink,
>> AjaxFallbackLink).
>>
>> Using diffrent repeater could be a option but DataTable (or
>> AjaxFallbackDefaultDataTable) provides a lot of functionality (sorting,
>> paging, fallback links etc) so it would be a waste of time to implement
>> its from scratch just because its hard to make a table cell (or row) a
>> link. It must be a way to achive this... if not it serious limitation of
>> DataTable component.
>>
>> Regards Daniel
>>
>>
>> Jeremy Thomerson-5 wrote:
>>>
>>> Depending on what you are linking TO, it can be very simple.  You can
>>> call
>>> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone).  So, you
>>> could
>>> do:
>>>
>>> cellItem.add(new SimpleAttributeModifier("onclick", "location.href = '" +
>>> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone) + "'"));
>>>
>>> Of course, that JS could be better for triple click problems, etc.
>>>
>>> Really, you may just consider using another Repeater rather than
>>> DataTable.
>>> DataTable is for a very specific purpose, and it is often easier to roll
>>> your own than make DT fit your purpose.
>>>
>>>
>>> --
>>> Jeremy Thomerson
>>> http://www.wickettraining.com
>>>
>>>
>>> On Tue, Oct 28, 2008 at 2:05 PM, dlipski <da...@gmail.com>
>>> wrote:
>>>
>>>>
>>>> All this solutions are correct but the problem is not in attaching some
>>>> custom Javascript to <td> element (which can be done in multiple ways)
>>>> but
>>>> in making td element work as a link.
>>>>
>>>> What exactly should I do to achive this ? What components should I add
>>>> at
>>>> server side at what JavaScript should I render at markup ?
>>>> If I have to copy-paste bunch of Link class code it looks like some
>>>> design/implementation problem of DataTable (or one of components it
>>>> has).
>>>>
>>>> Its really supprising that such common issue is such problematic.
>>>> I hope there is some simple and intuitive solution(if I find one I'll
>>>> post
>>>> it here)
>>>>
>>>> Thanks for your help
>>>> Regards Daniel
>>>>
>>>>
>>>> Michael O'Cleirigh wrote:
>>>> >
>>>> > Hi Daniel,
>>>> >
>>>> > If you subclass DefaultDataTable there is a protected method call
>>>> > newCellItem(...) that you can use to attach the onclick class onto the
>>>> > <td>.
>>>> >
>>>> > like:
>>>> >
>>>> > class MyDataTable extends DefaultDataTable {
>>>> >  /* (non-Javadoc)
>>>> >      * @see
>>>> >
>>>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>>>> > int, org.apache.wicket.model.IModel)
>>>> >      */
>>>> >     @Override
>>>> >     protected Item newCellItem(String id, int index, IModel model) {
>>>> >
>>>> >
>>>> >         Item cell = super.newCellItem(id, index, model);
>>>> >
>>>> >
>>>> >         cell.add(new AttributeAppender("onclick", new Model
>>>> > ("someJavascriptCall();"));
>>>> >
>>>> >         return cell;
>>>> >     }
>>>> > }
>>>> >
>>>> > Alternately you can use a custom column implementation like the
>>>> > FragrementColumn and add the onclick when the cell is created like:
>>>> >
>>>> > class MyOnClickColumn extends AbstractColumn {
>>>> > ...
>>>> > public void populateItem(Item cellItem, String componentId, IModel
>>>> > rowModel)
>>>> >     {
>>>> >        Label cell = new Label(componentId, new PropertyModel(rowModel,
>>>> > property))
>>>> >
>>>> >         cell.add (new AttributeAppender("onclick", new Model
>>>> > ("someJavascriptCall();"));
>>>> >
>>>> >         cellItem.add(cell);
>>>> >     }
>>>> > }
>>>> >
>>>> >
>>>> > I think the second version would attach the onclick to the label
>>>> within
>>>> > the <td></td> of a cell.
>>>> >
>>>> > Regards,
>>>> >
>>>> > Mike
>>>> >> I dont know wicketopia project (and any of its classes like
>>>> >> FragmentColumn)
>>>> >> so I can misunderstand your idea but as far as I am able to read that
>>>> >> code
>>>> >> It looks like you are adding a link to the table cell, not making a
>>>> cell
>>>> >> itself a link.
>>>> >>
>>>> >> If I understand your code it is familar to:
>>>> >>
>>>> >> <td>&lt;a&gt;text&lt;/a&gt;</td>
>>>> >>
>>>> >> but Im wondering how to achive:
>>>> >> <td on click="xyz">text</td>
>>>> >>
>>>> >> where xyz is code generated by Wicket (like in Link component class)
>>>> >>
>>>> >> If I misundestood you could you give me some more details hot to make
>>>> >> cell
>>>> >> itself a link ? (not adding a link to the cell) ?
>>>> >>
>>>> >> Regards
>>>> >> Daniel
>>>> >>
>>>> >>
>>>> >>
>>>> >> jwcarman wrote:
>>>> >>
>>>> >>> Here's an example where I put a remove link in a DefaultDataTable
>>>> cell:
>>>> >>>
>>>> >>>
>>>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>>> >>>
>>>> >>>
>>>> >>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski
>>>> <da...@gmail.com>
>>>> >>> wrote:
>>>> >>>
>>>> >>>> Hi
>>>> >>>>
>>>> >>>> I have one short question:
>>>> >>>> How to make entire cell in a DataTable a link ?
>>>> >>>> I've read that Link component can be attached not only to &lt;a&gt;
>>>> >>>> tags
>>>> >>>> but
>>>> >>>> also to any other html elements (like <tr> and <td>) but I dont
>>>> know
>>>> >>>> how
>>>> >>>> to
>>>> >>>> use it with DataTable API.
>>>> >>>>
>>>> >>>> Regards Daniel
>>>> >>>> --
>>>> >>>> View this message in context:
>>>> >>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>>> >>>> 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
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> > ---------------------------------------------------------------------
>>>> > 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/DataTable-cell-link-tp20204702p20213839.html
>>>>  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
>>>>
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20225048.html
> 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: DataTable cell link

Posted by dlipski <da...@gmail.com>.
My colegue point out that for Ajax requests AjaxEventBehavior can be used,
and it works fine. so now I need only solution for normal (non Ajax)
requests.


dlipski wrote:
> 
> Because I havent found better solution then adding 'onclick' handler to
> cellItem I have to do it your way.
> I looked at urlFor methods in Component class and didnt found the one with
> Component attribute. 
> How should I generate url for Link component, AjaxLink or AjaxFallbackLink
> ?
> Do I have to add this components to the page and set its visiblity to
> false ?
> I understand 'general concept' of this solution but dont know how to
> implement this in specific scenarion (ie. linking to Link, AjaxLink,
> AjaxFallbackLink).
> 
> Using diffrent repeater could be a option but DataTable (or
> AjaxFallbackDefaultDataTable) provides a lot of functionality (sorting,
> paging, fallback links etc) so it would be a waste of time to implement
> its from scratch just because its hard to make a table cell (or row) a
> link. It must be a way to achive this... if not it serious limitation of
> DataTable component.
> 
> Regards Daniel
> 
> 
> Jeremy Thomerson-5 wrote:
>> 
>> Depending on what you are linking TO, it can be very simple.  You can
>> call
>> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone).  So, you
>> could
>> do:
>> 
>> cellItem.add(new SimpleAttributeModifier("onclick", "location.href = '" +
>> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone) + "'"));
>> 
>> Of course, that JS could be better for triple click problems, etc.
>> 
>> Really, you may just consider using another Repeater rather than
>> DataTable.
>> DataTable is for a very specific purpose, and it is often easier to roll
>> your own than make DT fit your purpose.
>> 
>> 
>> -- 
>> Jeremy Thomerson
>> http://www.wickettraining.com
>> 
>> 
>> On Tue, Oct 28, 2008 at 2:05 PM, dlipski <da...@gmail.com>
>> wrote:
>> 
>>>
>>> All this solutions are correct but the problem is not in attaching some
>>> custom Javascript to <td> element (which can be done in multiple ways)
>>> but
>>> in making td element work as a link.
>>>
>>> What exactly should I do to achive this ? What components should I add
>>> at
>>> server side at what JavaScript should I render at markup ?
>>> If I have to copy-paste bunch of Link class code it looks like some
>>> design/implementation problem of DataTable (or one of components it
>>> has).
>>>
>>> Its really supprising that such common issue is such problematic.
>>> I hope there is some simple and intuitive solution(if I find one I'll
>>> post
>>> it here)
>>>
>>> Thanks for your help
>>> Regards Daniel
>>>
>>>
>>> Michael O'Cleirigh wrote:
>>> >
>>> > Hi Daniel,
>>> >
>>> > If you subclass DefaultDataTable there is a protected method call
>>> > newCellItem(...) that you can use to attach the onclick class onto the
>>> > <td>.
>>> >
>>> > like:
>>> >
>>> > class MyDataTable extends DefaultDataTable {
>>> >  /* (non-Javadoc)
>>> >      * @see
>>> >
>>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>>> > int, org.apache.wicket.model.IModel)
>>> >      */
>>> >     @Override
>>> >     protected Item newCellItem(String id, int index, IModel model) {
>>> >
>>> >
>>> >         Item cell = super.newCellItem(id, index, model);
>>> >
>>> >
>>> >         cell.add(new AttributeAppender("onclick", new Model
>>> > ("someJavascriptCall();"));
>>> >
>>> >         return cell;
>>> >     }
>>> > }
>>> >
>>> > Alternately you can use a custom column implementation like the
>>> > FragrementColumn and add the onclick when the cell is created like:
>>> >
>>> > class MyOnClickColumn extends AbstractColumn {
>>> > ...
>>> > public void populateItem(Item cellItem, String componentId, IModel
>>> > rowModel)
>>> >     {
>>> >        Label cell = new Label(componentId, new PropertyModel(rowModel,
>>> > property))
>>> >
>>> >         cell.add (new AttributeAppender("onclick", new Model
>>> > ("someJavascriptCall();"));
>>> >
>>> >         cellItem.add(cell);
>>> >     }
>>> > }
>>> >
>>> >
>>> > I think the second version would attach the onclick to the label
>>> within
>>> > the <td></td> of a cell.
>>> >
>>> > Regards,
>>> >
>>> > Mike
>>> >> I dont know wicketopia project (and any of its classes like
>>> >> FragmentColumn)
>>> >> so I can misunderstand your idea but as far as I am able to read that
>>> >> code
>>> >> It looks like you are adding a link to the table cell, not making a
>>> cell
>>> >> itself a link.
>>> >>
>>> >> If I understand your code it is familar to:
>>> >>
>>> >> <td>&lt;a&gt;text&lt;/a&gt;</td>
>>> >>
>>> >> but Im wondering how to achive:
>>> >> <td on click="xyz">text</td>
>>> >>
>>> >> where xyz is code generated by Wicket (like in Link component class)
>>> >>
>>> >> If I misundestood you could you give me some more details hot to make
>>> >> cell
>>> >> itself a link ? (not adding a link to the cell) ?
>>> >>
>>> >> Regards
>>> >> Daniel
>>> >>
>>> >>
>>> >>
>>> >> jwcarman wrote:
>>> >>
>>> >>> Here's an example where I put a remove link in a DefaultDataTable
>>> cell:
>>> >>>
>>> >>>
>>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>> >>>
>>> >>>
>>> >>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski
>>> <da...@gmail.com>
>>> >>> wrote:
>>> >>>
>>> >>>> Hi
>>> >>>>
>>> >>>> I have one short question:
>>> >>>> How to make entire cell in a DataTable a link ?
>>> >>>> I've read that Link component can be attached not only to &lt;a&gt;
>>> >>>> tags
>>> >>>> but
>>> >>>> also to any other html elements (like <tr> and <td>) but I dont
>>> know
>>> >>>> how
>>> >>>> to
>>> >>>> use it with DataTable API.
>>> >>>>
>>> >>>> Regards Daniel
>>> >>>> --
>>> >>>> View this message in context:
>>> >>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>> >>>> 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
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > 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/DataTable-cell-link-tp20204702p20213839.html
>>>  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
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20225048.html
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: DataTable cell link

Posted by dlipski <da...@gmail.com>.
Because I havent found better solution then adding 'onclick' handler to
cellItem I have to do it your way.
I looked at urlFor methods in Component class and didnt found the one with
Component attribute. 
How should I generate url for Link component, AjaxLink or AjaxFallbackLink ?
Do I have to add this components to the page and set its visiblity to false
?
I understand 'general concept' of this solution but dont know how to
implement this in specific scenarion (ie. linking to Link, AjaxLink,
AjaxFallbackLink).

Using diffrent repeater could be a option but DataTable (or
AjaxFallbackDefaultDataTable) provides a lot of functionality (sorting,
paging, fallback links etc) so it would be a waste of time to implement its
from scratch just because its hard to make a table cell (or row) a link. It
must be a way to achive this... if not it serious limitation of DataTable
component.

Regards Daniel


Jeremy Thomerson-5 wrote:
> 
> Depending on what you are linking TO, it can be very simple.  You can call
> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone).  So, you could
> do:
> 
> cellItem.add(new SimpleAttributeModifier("onclick", "location.href = '" +
> urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone) + "'"));
> 
> Of course, that JS could be better for triple click problems, etc.
> 
> Really, you may just consider using another Repeater rather than
> DataTable.
> DataTable is for a very specific purpose, and it is often easier to roll
> your own than make DT fit your purpose.
> 
> 
> -- 
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> On Tue, Oct 28, 2008 at 2:05 PM, dlipski <da...@gmail.com>
> wrote:
> 
>>
>> All this solutions are correct but the problem is not in attaching some
>> custom Javascript to <td> element (which can be done in multiple ways)
>> but
>> in making td element work as a link.
>>
>> What exactly should I do to achive this ? What components should I add at
>> server side at what JavaScript should I render at markup ?
>> If I have to copy-paste bunch of Link class code it looks like some
>> design/implementation problem of DataTable (or one of components it has).
>>
>> Its really supprising that such common issue is such problematic.
>> I hope there is some simple and intuitive solution(if I find one I'll
>> post
>> it here)
>>
>> Thanks for your help
>> Regards Daniel
>>
>>
>> Michael O'Cleirigh wrote:
>> >
>> > Hi Daniel,
>> >
>> > If you subclass DefaultDataTable there is a protected method call
>> > newCellItem(...) that you can use to attach the onclick class onto the
>> > <td>.
>> >
>> > like:
>> >
>> > class MyDataTable extends DefaultDataTable {
>> >  /* (non-Javadoc)
>> >      * @see
>> >
>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>> > int, org.apache.wicket.model.IModel)
>> >      */
>> >     @Override
>> >     protected Item newCellItem(String id, int index, IModel model) {
>> >
>> >
>> >         Item cell = super.newCellItem(id, index, model);
>> >
>> >
>> >         cell.add(new AttributeAppender("onclick", new Model
>> > ("someJavascriptCall();"));
>> >
>> >         return cell;
>> >     }
>> > }
>> >
>> > Alternately you can use a custom column implementation like the
>> > FragrementColumn and add the onclick when the cell is created like:
>> >
>> > class MyOnClickColumn extends AbstractColumn {
>> > ...
>> > public void populateItem(Item cellItem, String componentId, IModel
>> > rowModel)
>> >     {
>> >        Label cell = new Label(componentId, new PropertyModel(rowModel,
>> > property))
>> >
>> >         cell.add (new AttributeAppender("onclick", new Model
>> > ("someJavascriptCall();"));
>> >
>> >         cellItem.add(cell);
>> >     }
>> > }
>> >
>> >
>> > I think the second version would attach the onclick to the label within
>> > the <td></td> of a cell.
>> >
>> > Regards,
>> >
>> > Mike
>> >> I dont know wicketopia project (and any of its classes like
>> >> FragmentColumn)
>> >> so I can misunderstand your idea but as far as I am able to read that
>> >> code
>> >> It looks like you are adding a link to the table cell, not making a
>> cell
>> >> itself a link.
>> >>
>> >> If I understand your code it is familar to:
>> >>
>> >> <td>&lt;a&gt;text&lt;/a&gt;</td>
>> >>
>> >> but Im wondering how to achive:
>> >> <td on click="xyz">text</td>
>> >>
>> >> where xyz is code generated by Wicket (like in Link component class)
>> >>
>> >> If I misundestood you could you give me some more details hot to make
>> >> cell
>> >> itself a link ? (not adding a link to the cell) ?
>> >>
>> >> Regards
>> >> Daniel
>> >>
>> >>
>> >>
>> >> jwcarman wrote:
>> >>
>> >>> Here's an example where I put a remove link in a DefaultDataTable
>> cell:
>> >>>
>> >>>
>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>> >>>
>> >>>
>> >>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
>> >>> wrote:
>> >>>
>> >>>> Hi
>> >>>>
>> >>>> I have one short question:
>> >>>> How to make entire cell in a DataTable a link ?
>> >>>> I've read that Link component can be attached not only to &lt;a&gt;
>> >>>> tags
>> >>>> but
>> >>>> also to any other html elements (like <tr> and <td>) but I dont know
>> >>>> how
>> >>>> to
>> >>>> use it with DataTable API.
>> >>>>
>> >>>> Regards Daniel
>> >>>> --
>> >>>> View this message in context:
>> >>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>> >>>> 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
>> >>>
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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/DataTable-cell-link-tp20204702p20213839.html
>>  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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20222494.html
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: DataTable cell link

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Depending on what you are linking TO, it can be very simple.  You can call
urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone).  So, you could
do:

cellItem.add(new SimpleAttributeModifier("onclick", "location.href = '" +
urlFor(YourBookmarkablePage.class, pageParamsOrNullIfNone) + "'"));

Of course, that JS could be better for triple click problems, etc.

Really, you may just consider using another Repeater rather than DataTable.
DataTable is for a very specific purpose, and it is often easier to roll
your own than make DT fit your purpose.


-- 
Jeremy Thomerson
http://www.wickettraining.com


On Tue, Oct 28, 2008 at 2:05 PM, dlipski <da...@gmail.com> wrote:

>
> All this solutions are correct but the problem is not in attaching some
> custom Javascript to <td> element (which can be done in multiple ways) but
> in making td element work as a link.
>
> What exactly should I do to achive this ? What components should I add at
> server side at what JavaScript should I render at markup ?
> If I have to copy-paste bunch of Link class code it looks like some
> design/implementation problem of DataTable (or one of components it has).
>
> Its really supprising that such common issue is such problematic.
> I hope there is some simple and intuitive solution(if I find one I'll post
> it here)
>
> Thanks for your help
> Regards Daniel
>
>
> Michael O'Cleirigh wrote:
> >
> > Hi Daniel,
> >
> > If you subclass DefaultDataTable there is a protected method call
> > newCellItem(...) that you can use to attach the onclick class onto the
> > <td>.
> >
> > like:
> >
> > class MyDataTable extends DefaultDataTable {
> >  /* (non-Javadoc)
> >      * @see
> >
> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
> > int, org.apache.wicket.model.IModel)
> >      */
> >     @Override
> >     protected Item newCellItem(String id, int index, IModel model) {
> >
> >
> >         Item cell = super.newCellItem(id, index, model);
> >
> >
> >         cell.add(new AttributeAppender("onclick", new Model
> > ("someJavascriptCall();"));
> >
> >         return cell;
> >     }
> > }
> >
> > Alternately you can use a custom column implementation like the
> > FragrementColumn and add the onclick when the cell is created like:
> >
> > class MyOnClickColumn extends AbstractColumn {
> > ...
> > public void populateItem(Item cellItem, String componentId, IModel
> > rowModel)
> >     {
> >        Label cell = new Label(componentId, new PropertyModel(rowModel,
> > property))
> >
> >         cell.add (new AttributeAppender("onclick", new Model
> > ("someJavascriptCall();"));
> >
> >         cellItem.add(cell);
> >     }
> > }
> >
> >
> > I think the second version would attach the onclick to the label within
> > the <td></td> of a cell.
> >
> > Regards,
> >
> > Mike
> >> I dont know wicketopia project (and any of its classes like
> >> FragmentColumn)
> >> so I can misunderstand your idea but as far as I am able to read that
> >> code
> >> It looks like you are adding a link to the table cell, not making a cell
> >> itself a link.
> >>
> >> If I understand your code it is familar to:
> >>
> >> <td>&lt;a&gt;text&lt;/a&gt;</td>
> >>
> >> but Im wondering how to achive:
> >> <td on click="xyz">text</td>
> >>
> >> where xyz is code generated by Wicket (like in Link component class)
> >>
> >> If I misundestood you could you give me some more details hot to make
> >> cell
> >> itself a link ? (not adding a link to the cell) ?
> >>
> >> Regards
> >> Daniel
> >>
> >>
> >>
> >> jwcarman wrote:
> >>
> >>> Here's an example where I put a remove link in a DefaultDataTable cell:
> >>>
> >>>
> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
> >>>
> >>>
> >>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
> >>> wrote:
> >>>
> >>>> Hi
> >>>>
> >>>> I have one short question:
> >>>> How to make entire cell in a DataTable a link ?
> >>>> I've read that Link component can be attached not only to &lt;a&gt;
> >>>> tags
> >>>> but
> >>>> also to any other html elements (like <tr> and <td>) but I dont know
> >>>> how
> >>>> to
> >>>> use it with DataTable API.
> >>>>
> >>>> Regards Daniel
> >>>> --
> >>>> View this message in context:
> >>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
> >>>> 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
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > 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/DataTable-cell-link-tp20204702p20213839.html
>  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: DataTable cell link

Posted by dlipski <da...@gmail.com>.
Hi,
Thanks for help but the problem with your solution is that it doesnt work in
IE (when I have multiple columns with such links only links in first column
'fills' entire cells) in Firefox that works.


Jeremy Thomerson-5 wrote:
> 
> If that's your problem, I'd suggest using CSS, something like:
> 
> TD A {
> display: block;
> }
> 
> This is much better because the anchor will fill the box (fixing your
> problem), and you are more compatible (if JS is off, etc).
> 
> 
> -- 
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> On Tue, Oct 28, 2008 at 2:42 PM, dlipski <da...@gmail.com>
> wrote:
> 
>>
>> Exaclty, problem is with 'consuming' td element by Item object.
>>
>> The problem is that if you have wide column but short text in it some
>> users
>> have problem with hitting the text (which is a link) .The idea is to make
>> whole td element 'clickable'(or linkable).
>> The solution would be if table could have any component as row or cell
>> element not only Item object.
>> But I know that this is a big change in DataTable class (or one of its
>> child
>> component class) .
>>
>>
>>
>> jwcarman wrote:
>> >
>> > On Tue, Oct 28, 2008 at 3:05 PM, dlipski <da...@gmail.com>
>> > wrote:
>> >>
>> >> All this solutions are correct but the problem is not in attaching
>> some
>> >> custom Javascript to <td> element (which can be done in multiple ways)
>> >> but
>> >> in making td element work as a link.
>> >>
>> >
>> > Right, the <td> element is already consumed by the Item object, so you
>> > can't attach your link to it.
>> >
>> >> What exactly should I do to achive this ? What components should I add
>> at
>> >> server side at what JavaScript should I render at markup ?
>> >> If I have to copy-paste bunch of Link class code it looks like some
>> >> design/implementation problem of DataTable (or one of components it
>> has).
>> >>
>> >
>> > What is your requirement exactly?  Is there going to be any text (or
>> > image) in your cell?  If so, why can't it be a link?
>> >
>> >> Its really supprising that such common issue is such problematic.
>> >> I hope there is some simple and intuitive solution(if I find one I'll
>> >> post
>> >> it here)
>> >>
>> >> Thanks for your help
>> >> Regards Daniel
>> >>
>> >>
>> >> Michael O'Cleirigh wrote:
>> >>>
>> >>> Hi Daniel,
>> >>>
>> >>> If you subclass DefaultDataTable there is a protected method call
>> >>> newCellItem(...) that you can use to attach the onclick class onto
>> the
>> >>> <td>.
>> >>>
>> >>> like:
>> >>>
>> >>> class MyDataTable extends DefaultDataTable {
>> >>>  /* (non-Javadoc)
>> >>>      * @see
>> >>>
>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>> >>> int, org.apache.wicket.model.IModel)
>> >>>      */
>> >>>     @Override
>> >>>     protected Item newCellItem(String id, int index, IModel model) {
>> >>>
>> >>>
>> >>>         Item cell = super.newCellItem(id, index, model);
>> >>>
>> >>>
>> >>>         cell.add(new AttributeAppender("onclick", new Model
>> >>> ("someJavascriptCall();"));
>> >>>
>> >>>         return cell;
>> >>>     }
>> >>> }
>> >>>
>> >>> Alternately you can use a custom column implementation like the
>> >>> FragrementColumn and add the onclick when the cell is created like:
>> >>>
>> >>> class MyOnClickColumn extends AbstractColumn {
>> >>> ...
>> >>> public void populateItem(Item cellItem, String componentId, IModel
>> >>> rowModel)
>> >>>     {
>> >>>        Label cell = new Label(componentId, new
>> PropertyModel(rowModel,
>> >>> property))
>> >>>
>> >>>         cell.add (new AttributeAppender("onclick", new Model
>> >>> ("someJavascriptCall();"));
>> >>>
>> >>>         cellItem.add(cell);
>> >>>     }
>> >>> }
>> >>>
>> >>>
>> >>> I think the second version would attach the onclick to the label
>> within
>> >>> the <td></td> of a cell.
>> >>>
>> >>> Regards,
>> >>>
>> >>> Mike
>> >>>> I dont know wicketopia project (and any of its classes like
>> >>>> FragmentColumn)
>> >>>> so I can misunderstand your idea but as far as I am able to read
>> that
>> >>>> code
>> >>>> It looks like you are adding a link to the table cell, not making a
>> >>>> cell
>> >>>> itself a link.
>> >>>>
>> >>>> If I understand your code it is familar to:
>> >>>>
>> >>>> <td>&lt;a&gt;text&lt;/a&gt;</td>
>> >>>>
>> >>>> but Im wondering how to achive:
>> >>>> <td on click="xyz">text</td>
>> >>>>
>> >>>> where xyz is code generated by Wicket (like in Link component class)
>> >>>>
>> >>>> If I misundestood you could you give me some more details hot to
>> make
>> >>>> cell
>> >>>> itself a link ? (not adding a link to the cell) ?
>> >>>>
>> >>>> Regards
>> >>>> Daniel
>> >>>>
>> >>>>
>> >>>>
>> >>>> jwcarman wrote:
>> >>>>
>> >>>>> Here's an example where I put a remove link in a DefaultDataTable
>> >>>>> cell:
>> >>>>>
>> >>>>>
>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>> >>>>>
>> >>>>>
>> >>>>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski
>> <daniel.lipski.pl@gmail.com
>> >
>> >>>>> wrote:
>> >>>>>
>> >>>>>> Hi
>> >>>>>>
>> >>>>>> I have one short question:
>> >>>>>> How to make entire cell in a DataTable a link ?
>> >>>>>> I've read that Link component can be attached not only to
>> &lt;a&gt;
>> >>>>>> tags
>> >>>>>> but
>> >>>>>> also to any other html elements (like <tr> and <td>) but I dont
>> know
>> >>>>>> how
>> >>>>>> to
>> >>>>>> use it with DataTable API.
>> >>>>>>
>> >>>>>> Regards Daniel
>> >>>>>> --
>> >>>>>> View this message in context:
>> >>>>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>> >>>>>> 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
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> 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/DataTable-cell-link-tp20204702p20213839.html
>> >> 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
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/DataTable-cell-link-tp20204702p20214540.html
>>  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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20222321.html
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: DataTable cell link

Posted by Jeremy Thomerson <je...@wickettraining.com>.
If that's your problem, I'd suggest using CSS, something like:

TD A {
display: block;
}

This is much better because the anchor will fill the box (fixing your
problem), and you are more compatible (if JS is off, etc).


-- 
Jeremy Thomerson
http://www.wickettraining.com


On Tue, Oct 28, 2008 at 2:42 PM, dlipski <da...@gmail.com> wrote:

>
> Exaclty, problem is with 'consuming' td element by Item object.
>
> The problem is that if you have wide column but short text in it some users
> have problem with hitting the text (which is a link) .The idea is to make
> whole td element 'clickable'(or linkable).
> The solution would be if table could have any component as row or cell
> element not only Item object.
> But I know that this is a big change in DataTable class (or one of its
> child
> component class) .
>
>
>
> jwcarman wrote:
> >
> > On Tue, Oct 28, 2008 at 3:05 PM, dlipski <da...@gmail.com>
> > wrote:
> >>
> >> All this solutions are correct but the problem is not in attaching some
> >> custom Javascript to <td> element (which can be done in multiple ways)
> >> but
> >> in making td element work as a link.
> >>
> >
> > Right, the <td> element is already consumed by the Item object, so you
> > can't attach your link to it.
> >
> >> What exactly should I do to achive this ? What components should I add
> at
> >> server side at what JavaScript should I render at markup ?
> >> If I have to copy-paste bunch of Link class code it looks like some
> >> design/implementation problem of DataTable (or one of components it
> has).
> >>
> >
> > What is your requirement exactly?  Is there going to be any text (or
> > image) in your cell?  If so, why can't it be a link?
> >
> >> Its really supprising that such common issue is such problematic.
> >> I hope there is some simple and intuitive solution(if I find one I'll
> >> post
> >> it here)
> >>
> >> Thanks for your help
> >> Regards Daniel
> >>
> >>
> >> Michael O'Cleirigh wrote:
> >>>
> >>> Hi Daniel,
> >>>
> >>> If you subclass DefaultDataTable there is a protected method call
> >>> newCellItem(...) that you can use to attach the onclick class onto the
> >>> <td>.
> >>>
> >>> like:
> >>>
> >>> class MyDataTable extends DefaultDataTable {
> >>>  /* (non-Javadoc)
> >>>      * @see
> >>>
> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
> >>> int, org.apache.wicket.model.IModel)
> >>>      */
> >>>     @Override
> >>>     protected Item newCellItem(String id, int index, IModel model) {
> >>>
> >>>
> >>>         Item cell = super.newCellItem(id, index, model);
> >>>
> >>>
> >>>         cell.add(new AttributeAppender("onclick", new Model
> >>> ("someJavascriptCall();"));
> >>>
> >>>         return cell;
> >>>     }
> >>> }
> >>>
> >>> Alternately you can use a custom column implementation like the
> >>> FragrementColumn and add the onclick when the cell is created like:
> >>>
> >>> class MyOnClickColumn extends AbstractColumn {
> >>> ...
> >>> public void populateItem(Item cellItem, String componentId, IModel
> >>> rowModel)
> >>>     {
> >>>        Label cell = new Label(componentId, new PropertyModel(rowModel,
> >>> property))
> >>>
> >>>         cell.add (new AttributeAppender("onclick", new Model
> >>> ("someJavascriptCall();"));
> >>>
> >>>         cellItem.add(cell);
> >>>     }
> >>> }
> >>>
> >>>
> >>> I think the second version would attach the onclick to the label within
> >>> the <td></td> of a cell.
> >>>
> >>> Regards,
> >>>
> >>> Mike
> >>>> I dont know wicketopia project (and any of its classes like
> >>>> FragmentColumn)
> >>>> so I can misunderstand your idea but as far as I am able to read that
> >>>> code
> >>>> It looks like you are adding a link to the table cell, not making a
> >>>> cell
> >>>> itself a link.
> >>>>
> >>>> If I understand your code it is familar to:
> >>>>
> >>>> <td>&lt;a&gt;text&lt;/a&gt;</td>
> >>>>
> >>>> but Im wondering how to achive:
> >>>> <td on click="xyz">text</td>
> >>>>
> >>>> where xyz is code generated by Wicket (like in Link component class)
> >>>>
> >>>> If I misundestood you could you give me some more details hot to make
> >>>> cell
> >>>> itself a link ? (not adding a link to the cell) ?
> >>>>
> >>>> Regards
> >>>> Daniel
> >>>>
> >>>>
> >>>>
> >>>> jwcarman wrote:
> >>>>
> >>>>> Here's an example where I put a remove link in a DefaultDataTable
> >>>>> cell:
> >>>>>
> >>>>>
> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
> >>>>>
> >>>>>
> >>>>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <daniel.lipski.pl@gmail.com
> >
> >>>>> wrote:
> >>>>>
> >>>>>> Hi
> >>>>>>
> >>>>>> I have one short question:
> >>>>>> How to make entire cell in a DataTable a link ?
> >>>>>> I've read that Link component can be attached not only to &lt;a&gt;
> >>>>>> tags
> >>>>>> but
> >>>>>> also to any other html elements (like <tr> and <td>) but I dont know
> >>>>>> how
> >>>>>> to
> >>>>>> use it with DataTable API.
> >>>>>>
> >>>>>> Regards Daniel
> >>>>>> --
> >>>>>> View this message in context:
> >>>>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
> >>>>>> 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
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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/DataTable-cell-link-tp20204702p20213839.html
> >> 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
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/DataTable-cell-link-tp20204702p20214540.html
>  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: DataTable cell link

Posted by dlipski <da...@gmail.com>.
Exaclty, problem is with 'consuming' td element by Item object.

The problem is that if you have wide column but short text in it some users
have problem with hitting the text (which is a link) .The idea is to make
whole td element 'clickable'(or linkable). 
The solution would be if table could have any component as row or cell
element not only Item object. 
But I know that this is a big change in DataTable class (or one of its child
component class) .



jwcarman wrote:
> 
> On Tue, Oct 28, 2008 at 3:05 PM, dlipski <da...@gmail.com>
> wrote:
>>
>> All this solutions are correct but the problem is not in attaching some
>> custom Javascript to <td> element (which can be done in multiple ways)
>> but
>> in making td element work as a link.
>>
> 
> Right, the <td> element is already consumed by the Item object, so you
> can't attach your link to it.
> 
>> What exactly should I do to achive this ? What components should I add at
>> server side at what JavaScript should I render at markup ?
>> If I have to copy-paste bunch of Link class code it looks like some
>> design/implementation problem of DataTable (or one of components it has).
>>
> 
> What is your requirement exactly?  Is there going to be any text (or
> image) in your cell?  If so, why can't it be a link?
> 
>> Its really supprising that such common issue is such problematic.
>> I hope there is some simple and intuitive solution(if I find one I'll
>> post
>> it here)
>>
>> Thanks for your help
>> Regards Daniel
>>
>>
>> Michael O'Cleirigh wrote:
>>>
>>> Hi Daniel,
>>>
>>> If you subclass DefaultDataTable there is a protected method call
>>> newCellItem(...) that you can use to attach the onclick class onto the
>>> <td>.
>>>
>>> like:
>>>
>>> class MyDataTable extends DefaultDataTable {
>>>  /* (non-Javadoc)
>>>      * @see
>>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>>> int, org.apache.wicket.model.IModel)
>>>      */
>>>     @Override
>>>     protected Item newCellItem(String id, int index, IModel model) {
>>>
>>>
>>>         Item cell = super.newCellItem(id, index, model);
>>>
>>>
>>>         cell.add(new AttributeAppender("onclick", new Model
>>> ("someJavascriptCall();"));
>>>
>>>         return cell;
>>>     }
>>> }
>>>
>>> Alternately you can use a custom column implementation like the
>>> FragrementColumn and add the onclick when the cell is created like:
>>>
>>> class MyOnClickColumn extends AbstractColumn {
>>> ...
>>> public void populateItem(Item cellItem, String componentId, IModel
>>> rowModel)
>>>     {
>>>        Label cell = new Label(componentId, new PropertyModel(rowModel,
>>> property))
>>>
>>>         cell.add (new AttributeAppender("onclick", new Model
>>> ("someJavascriptCall();"));
>>>
>>>         cellItem.add(cell);
>>>     }
>>> }
>>>
>>>
>>> I think the second version would attach the onclick to the label within
>>> the <td></td> of a cell.
>>>
>>> Regards,
>>>
>>> Mike
>>>> I dont know wicketopia project (and any of its classes like
>>>> FragmentColumn)
>>>> so I can misunderstand your idea but as far as I am able to read that
>>>> code
>>>> It looks like you are adding a link to the table cell, not making a
>>>> cell
>>>> itself a link.
>>>>
>>>> If I understand your code it is familar to:
>>>>
>>>> <td>&lt;a&gt;text&lt;/a&gt;</td>
>>>>
>>>> but Im wondering how to achive:
>>>> <td on click="xyz">text</td>
>>>>
>>>> where xyz is code generated by Wicket (like in Link component class)
>>>>
>>>> If I misundestood you could you give me some more details hot to make
>>>> cell
>>>> itself a link ? (not adding a link to the cell) ?
>>>>
>>>> Regards
>>>> Daniel
>>>>
>>>>
>>>>
>>>> jwcarman wrote:
>>>>
>>>>> Here's an example where I put a remove link in a DefaultDataTable
>>>>> cell:
>>>>>
>>>>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>>>>
>>>>>
>>>>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I have one short question:
>>>>>> How to make entire cell in a DataTable a link ?
>>>>>> I've read that Link component can be attached not only to &lt;a&gt;
>>>>>> tags
>>>>>> but
>>>>>> also to any other html elements (like <tr> and <td>) but I dont know
>>>>>> how
>>>>>> to
>>>>>> use it with DataTable API.
>>>>>>
>>>>>> Regards Daniel
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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/DataTable-cell-link-tp20204702p20213839.html
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20214540.html
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: DataTable cell link

Posted by James Carman <ja...@carmanconsulting.com>.
On Tue, Oct 28, 2008 at 3:05 PM, dlipski <da...@gmail.com> wrote:
>
> All this solutions are correct but the problem is not in attaching some
> custom Javascript to <td> element (which can be done in multiple ways) but
> in making td element work as a link.
>

Right, the <td> element is already consumed by the Item object, so you
can't attach your link to it.

> What exactly should I do to achive this ? What components should I add at
> server side at what JavaScript should I render at markup ?
> If I have to copy-paste bunch of Link class code it looks like some
> design/implementation problem of DataTable (or one of components it has).
>

What is your requirement exactly?  Is there going to be any text (or
image) in your cell?  If so, why can't it be a link?

> Its really supprising that such common issue is such problematic.
> I hope there is some simple and intuitive solution(if I find one I'll post
> it here)
>
> Thanks for your help
> Regards Daniel
>
>
> Michael O'Cleirigh wrote:
>>
>> Hi Daniel,
>>
>> If you subclass DefaultDataTable there is a protected method call
>> newCellItem(...) that you can use to attach the onclick class onto the
>> <td>.
>>
>> like:
>>
>> class MyDataTable extends DefaultDataTable {
>>  /* (non-Javadoc)
>>      * @see
>> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String,
>> int, org.apache.wicket.model.IModel)
>>      */
>>     @Override
>>     protected Item newCellItem(String id, int index, IModel model) {
>>
>>
>>         Item cell = super.newCellItem(id, index, model);
>>
>>
>>         cell.add(new AttributeAppender("onclick", new Model
>> ("someJavascriptCall();"));
>>
>>         return cell;
>>     }
>> }
>>
>> Alternately you can use a custom column implementation like the
>> FragrementColumn and add the onclick when the cell is created like:
>>
>> class MyOnClickColumn extends AbstractColumn {
>> ...
>> public void populateItem(Item cellItem, String componentId, IModel
>> rowModel)
>>     {
>>        Label cell = new Label(componentId, new PropertyModel(rowModel,
>> property))
>>
>>         cell.add (new AttributeAppender("onclick", new Model
>> ("someJavascriptCall();"));
>>
>>         cellItem.add(cell);
>>     }
>> }
>>
>>
>> I think the second version would attach the onclick to the label within
>> the <td></td> of a cell.
>>
>> Regards,
>>
>> Mike
>>> I dont know wicketopia project (and any of its classes like
>>> FragmentColumn)
>>> so I can misunderstand your idea but as far as I am able to read that
>>> code
>>> It looks like you are adding a link to the table cell, not making a cell
>>> itself a link.
>>>
>>> If I understand your code it is familar to:
>>>
>>> <td>&lt;a&gt;text&lt;/a&gt;</td>
>>>
>>> but Im wondering how to achive:
>>> <td on click="xyz">text</td>
>>>
>>> where xyz is code generated by Wicket (like in Link component class)
>>>
>>> If I misundestood you could you give me some more details hot to make
>>> cell
>>> itself a link ? (not adding a link to the cell) ?
>>>
>>> Regards
>>> Daniel
>>>
>>>
>>>
>>> jwcarman wrote:
>>>
>>>> Here's an example where I put a remove link in a DefaultDataTable cell:
>>>>
>>>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>>>
>>>>
>>>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I have one short question:
>>>>> How to make entire cell in a DataTable a link ?
>>>>> I've read that Link component can be attached not only to &lt;a&gt;
>>>>> tags
>>>>> but
>>>>> also to any other html elements (like <tr> and <td>) but I dont know
>>>>> how
>>>>> to
>>>>> use it with DataTable API.
>>>>>
>>>>> Regards Daniel
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>>>> 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
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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/DataTable-cell-link-tp20204702p20213839.html
> 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: DataTable cell link

Posted by dlipski <da...@gmail.com>.
All this solutions are correct but the problem is not in attaching some
custom Javascript to <td> element (which can be done in multiple ways) but
in making td element work as a link.

What exactly should I do to achive this ? What components should I add at
server side at what JavaScript should I render at markup ? 
If I have to copy-paste bunch of Link class code it looks like some
design/implementation problem of DataTable (or one of components it has).

Its really supprising that such common issue is such problematic.
I hope there is some simple and intuitive solution(if I find one I'll post
it here)

Thanks for your help
Regards Daniel


Michael O'Cleirigh wrote:
> 
> Hi Daniel,
> 
> If you subclass DefaultDataTable there is a protected method call 
> newCellItem(...) that you can use to attach the onclick class onto the
> <td>.
> 
> like:
> 
> class MyDataTable extends DefaultDataTable {
>  /* (non-Javadoc)
>      * @see 
> org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String, 
> int, org.apache.wicket.model.IModel)
>      */
>     @Override
>     protected Item newCellItem(String id, int index, IModel model) {
> 
>  
>         Item cell = super.newCellItem(id, index, model);
> 
> 
>         cell.add(new AttributeAppender("onclick", new Model 
> ("someJavascriptCall();"));
> 
>         return cell;
>     }
> }
> 
> Alternately you can use a custom column implementation like the 
> FragrementColumn and add the onclick when the cell is created like:
> 
> class MyOnClickColumn extends AbstractColumn {
> ...
> public void populateItem(Item cellItem, String componentId, IModel
> rowModel)
>     {
>        Label cell = new Label(componentId, new PropertyModel(rowModel, 
> property))
> 
>         cell.add (new AttributeAppender("onclick", new Model 
> ("someJavascriptCall();"));
> 
>         cellItem.add(cell);
>     }
> }
> 
> 
> I think the second version would attach the onclick to the label within 
> the <td></td> of a cell.
> 
> Regards,
> 
> Mike
>> I dont know wicketopia project (and any of its classes like
>> FragmentColumn)
>> so I can misunderstand your idea but as far as I am able to read that
>> code
>> It looks like you are adding a link to the table cell, not making a cell
>> itself a link.
>>
>> If I understand your code it is familar to:
>>
>> <td>&lt;a&gt;text&lt;/a&gt;</td>
>>
>> but Im wondering how to achive:
>> <td on click="xyz">text</td>
>>
>> where xyz is code generated by Wicket (like in Link component class)
>>
>> If I misundestood you could you give me some more details hot to make
>> cell
>> itself a link ? (not adding a link to the cell) ?
>>
>> Regards 
>> Daniel
>>
>>
>>
>> jwcarman wrote:
>>   
>>> Here's an example where I put a remove link in a DefaultDataTable cell:
>>>
>>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>>
>>>
>>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
>>> wrote:
>>>     
>>>> Hi
>>>>
>>>> I have one short question:
>>>> How to make entire cell in a DataTable a link ?
>>>> I've read that Link component can be attached not only to &lt;a&gt;
>>>> tags
>>>> but
>>>> also to any other html elements (like <tr> and <td>) but I dont know
>>>> how
>>>> to
>>>> use it with DataTable API.
>>>>
>>>> Regards Daniel
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>>> 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
>>>
>>>
>>>
>>>     
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> 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/DataTable-cell-link-tp20204702p20213839.html
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: DataTable cell link

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Hi Daniel,

If you subclass DefaultDataTable there is a protected method call 
newCellItem(...) that you can use to attach the onclick class onto the <td>.

like:

class MyDataTable extends DefaultDataTable {
 /* (non-Javadoc)
     * @see 
org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String, 
int, org.apache.wicket.model.IModel)
     */
    @Override
    protected Item newCellItem(String id, int index, IModel model) {

 
        Item cell = super.newCellItem(id, index, model);


        cell.add(new AttributeAppender("onclick", new Model 
("someJavascriptCall();"));

        return cell;
    }
}

Alternately you can use a custom column implementation like the 
FragrementColumn and add the onclick when the cell is created like:

class MyOnClickColumn extends AbstractColumn {
...
public void populateItem(Item cellItem, String componentId, IModel rowModel)
    {
       Label cell = new Label(componentId, new PropertyModel(rowModel, 
property))

        cell.add (new AttributeAppender("onclick", new Model 
("someJavascriptCall();"));

        cellItem.add(cell);
    }
}


I think the second version would attach the onclick to the label within 
the <td></td> of a cell.

Regards,

Mike
> I dont know wicketopia project (and any of its classes like FragmentColumn)
> so I can misunderstand your idea but as far as I am able to read that code
> It looks like you are adding a link to the table cell, not making a cell
> itself a link.
>
> If I understand your code it is familar to:
>
> <td>&lt;a&gt;text&lt;/a&gt;</td>
>
> but Im wondering how to achive:
> <td on click="xyz">text</td>
>
> where xyz is code generated by Wicket (like in Link component class)
>
> If I misundestood you could you give me some more details hot to make cell
> itself a link ? (not adding a link to the cell) ?
>
> Regards 
> Daniel
>
>
>
> jwcarman wrote:
>   
>> Here's an example where I put a remove link in a DefaultDataTable cell:
>>
>> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
>>
>>
>> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
>> wrote:
>>     
>>> Hi
>>>
>>> I have one short question:
>>> How to make entire cell in a DataTable a link ?
>>> I've read that Link component can be attached not only to &lt;a&gt; tags
>>> but
>>> also to any other html elements (like <tr> and <td>) but I dont know how
>>> to
>>> use it with DataTable API.
>>>
>>> Regards Daniel
>>> --
>>> View this message in context:
>>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>>> 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
>>
>>
>>
>>     
>
>   


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


Re: DataTable cell link

Posted by dlipski <da...@gmail.com>.
Hi
I dont know wicketopia project (and any of its classes like FragmentColumn)
so I can misunderstand your idea but as far as I am able to read that code
It looks like you are adding a link to the table cell, not making a cell
itself a link.

If I understand your code it is familar to:

<td>&lt;a&gt;text&lt;/a&gt;</td>

but Im wondering how to achive:
<td on click="xyz">text</td>

where xyz is code generated by Wicket (like in Link component class)

If I misundestood you could you give me some more details hot to make cell
itself a link ? (not adding a link to the cell) ?

Regards 
Daniel



jwcarman wrote:
> 
> Here's an example where I put a remove link in a DefaultDataTable cell:
> 
> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java
> 
> 
> On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com>
> wrote:
>>
>> Hi
>>
>> I have one short question:
>> How to make entire cell in a DataTable a link ?
>> I've read that Link component can be attached not only to &lt;a&gt; tags
>> but
>> also to any other html elements (like <tr> and <td>) but I dont know how
>> to
>> use it with DataTable API.
>>
>> Regards Daniel
>> --
>> View this message in context:
>> http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20207438.html
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: DataTable cell link

Posted by James Carman <ja...@carmanconsulting.com>.
Here's an example where I put a remove link in a DefaultDataTable cell:

https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java


On Tue, Oct 28, 2008 at 6:33 AM, dlipski <da...@gmail.com> wrote:
>
> Hi
>
> I have one short question:
> How to make entire cell in a DataTable a link ?
> I've read that Link component can be attached not only to &lt;a&gt; tags but
> also to any other html elements (like <tr> and <td>) but I dont know how to
> use it with DataTable API.
>
> Regards Daniel
> --
> View this message in context: http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
> 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