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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> >>> 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><a>text</a></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 >>>> <[EMAIL PROTECTED]> >>>> >>> 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 <a> >>>> >>>> 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: [EMAIL PROTECTED] >>>> >>>> For additional commands, e-mail: [EMAIL PROTECTED] >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> >>>> --------------------------------------------------------------------- >>>> >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>>> >>> For additional commands, e-mail: [EMAIL PROTECTED] >>>> >>> >>>> >>> >>>> >>> >>>> >>> >>>> >> >>>> >> >>>> > >>>> > >>>> > --------------------------------------------------------------------- >>>> > To unsubscribe, e-mail: [EMAIL PROTECTED] >>>> > For additional commands, e-mail: [EMAIL PROTECTED] >>>> > >>>> > >>>> > >>>> >>>> -- >>>> 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: [EMAIL PROTECTED] >>>> For additional commands, e-mail: [EMAIL PROTECTED] >>>> >>>> >>> >>> >> >> > > -- > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]