I want to share with you what I took from the example. and to show how I implemented it. The example that Igor gave shows how to toggle a row. I needed a single selection. So: public class HighlitableDataItem extends Item { private static final long serialVersionUID = -1637144139412425548L;
private boolean highlite = false; public HighlitableDataItem(String id, int index, IModel model) { super(id, index, model); setOutputMarkupId(true); add(new AttributeAppender("class", true, new Model("highlightItem"), " ") { private static final long serialVersionUID = 1L; @Override public boolean isEnabled(Component component) { return isHighlite(); } }); } public void setHighlite(boolean highlite) { this.highlite = highlite; } public boolean isHighlite() { return highlite; } } In the table: /** * Enable the user to have rows that can be highlighted */ @Override protected Item newCellItem(String cellItemId, int index, IModel model) { return new HighlitableDataItem(cellItemId, index, model); } And here's the method that is called when the AjaxLink (in the table) is clicked: private void itemClicked(final HighlitableDataItem clickedItem, final AjaxRequestTarget target) { ownersTable.visitChildren(HighlitableDataItem.class, new IVisitor() { public Object component(Component component) { HighlitableDataItem traveresedItem = (HighlitableDataItem) component; if (traveresedItem.isHighlite()) { traveresedItem.setHighlite(false); target.addComponent(traveresedItem); return traveresedItem; } return null; } }); clickedItem.setHighlite(true); target.addComponent(clickedItem); } I think I will create a visitor class exactly for that... Eyal Golan egola...@gmail.com Visit: http://jvdrums.sourceforge.net/ LinkedIn: http://www.linkedin.com/in/egolan74 P Save a tree. Please don't print this e-mail unless it's really necessary On Mon, Nov 16, 2009 at 6:18 PM, Eyal Golan <egola...@gmail.com> wrote: > got it :) > > thanks > > > Eyal Golan > egola...@gmail.com > > Visit: http://jvdrums.sourceforge.net/ > LinkedIn: http://www.linkedin.com/in/egolan74 > > P Save a tree. Please don't print this e-mail unless it's really necessary > > > On Mon, Nov 16, 2009 at 5:43 PM, Igor Vaynberg <igor.vaynb...@gmail.com>wrote: > >> this will get you most of the way there >> >> >> http://wicketstuff.org/wicket14/repeater/?wicket:bookmarkablePage=:org.apache.wicket.examples.repeater.OIRPage >> >> -igor >> >> On Mon, Nov 16, 2009 at 7:04 AM, Eyal Golan <egola...@gmail.com> wrote: >> > Hello, >> > we have a DataTable with one column that holds a fragment. >> > In that fragment we put an AjaxLink: >> > @Override >> > public void populateItem(Item item, String componentId, >> IModel >> > model) { >> > CampaignEntity entity = (CampaignEntity) >> model.getObject(); >> > Fragment frag = new OwnerLinkFragment(componentId, >> > FirstEntitiesListInnerPanel.this,entity); >> > item.add(frag); >> > } >> > >> > private final class OwnerLinkFragment extends Fragment { >> > private static final long serialVersionUID = >> 6949616729209808580L; >> > >> > public OwnerLinkFragment(String id, MarkupContainer >> markupProvider, >> > final CampaignEntity entity) { >> > super(id, "linkFragment", markupProvider); >> > AjaxLink link = new AjaxLink("link", new >> > Model(entity.getDisplayName())) { >> > private static final long serialVersionUID = 1L; >> > >> > @Override >> > public void onClick(AjaxRequestTarget target) { >> > itemClickProducer.itemClicked(entity, target); >> > } >> > }; >> > add(link); >> > } >> > >> > } >> > >> > I want that when the user clicks on the link, the row will be >> highlighted >> > and the previous selected (if there was) will be un-highlighted. >> > >> > I know that it is with CSS playing (changing classes), but how do I do >> that? >> > And I guess that if I add this table to the ajaxTarget, then the >> previous >> > line will not be highlighted. >> > >> > Thanks >> > >> > >> > Eyal Golan >> > egola...@gmail.com >> > >> > Visit: http://jvdrums.sourceforge.net/ >> > LinkedIn: http://www.linkedin.com/in/egolan74 >> > >> > P Save a tree. Please don't print this e-mail unless it's really >> necessary >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> >