Hi, I have a DefaultDataTable with 5 columns, I want to be able to register to an onclick method that fires when the user will click a specific row\cell in the table. In other words, I need to be able to open an edit screen when the user clicks the row he wants to edit, and for that I need the row to be clickable (or just the name cell) and I need to be able to be able to hook up to that event.
My Code: *Please bear in mind that I've only started developing in wicket a week ago so if you see anything that doesn't make sense, please let me know so I can fix it.* *WebPage.java:* > locationsEntityFacade = > LookupHelper.getInstance().lookupLocationsEntityFacade(); > List locations = locationsEntityFacade.findAll(); > int count = locations.size(); > > add(new Label("locationsCount", String.valueOf(count))); > > LocationsProvider locationsProvider = new LocationsProvider(); > > IColumn[] columns = new IColumn[5]; > columns[0] = new PropertyColumn(new Model("Name"), "name", "name"); > columns[1] = new PropertyColumn(new Model("Address 1"), > "streetAddress1", "streetAddress1"); > columns[2] = new PropertyColumn(new Model("Address 2"), > "streetAddress2", "streetAddress2"); > columns[3] = new PropertyColumn(new Model("City"), "city", "city"); > columns[4] = new PropertyColumn(new Model("State"), "usState", > "usState"); > > DefaultDataTable table = new DefaultDataTable("datatable", columns, > locationsProvider, 10); > add(table); * Location Provider:* public class LocationsProvider extends SortableDataProvider{ > > List list = new ArrayList(); > LocationsEntityFacadeLocal locationsEntityFacade; > > public LocationsProvider() { > setSort("id", true); > locationsEntityFacade = > LookupHelper.getInstance().lookupLocationsEntityFacade(); > list = locationsEntityFacade.findAll(); > } > > public Iterator iterator(int first, int count) { > List newList = new ArrayList(); > newList.addAll(list.subList(first, first + count)); > final String sortColumn = this.getSort().getProperty(); > final boolean ascending = this.getSort().isAscending(); > Collections.sort(newList, new Comparator() { > > public int compare(Object obj1, Object obj2) { > PropertyModel model1 = new PropertyModel(obj1, sortColumn); > PropertyModel model2 = new PropertyModel(obj2, sortColumn); > > Object modelObject1 = model1.getObject(); > Object modelObject2 = model2.getObject(); > > int compare = ((Comparable) > modelObject1).compareTo(modelObject2); > > if (!ascending) > compare *= -1; > > return compare; > } > }); > > return newList.iterator(); > } > > public int size() { > return list.size(); > > } > > public IModel model(final Object object) { > return new CompoundPropertyModel((LocationsEntity)object); > } *webpage.html: * > > ... <table wicket:id="datatable"></table> > ... > Thanks, Elad