Hi, I'm trying to implement a simple sortable datatable with Wicket, and I'm struggling with an issue I can't find a way to solve : how to build a sortable column when the data to be sorted is also to be translated and comes from the property files (not from the model directly) ?
I've done this : - I build an AjaxDefaultDataTable with a sortable dataprovider containing a country ZoneCode - this ZoneCode is a key in the property files that provides the display ZoneLabel So I thought this kind of code would do the trick : List<IColumn<CountryDetails>> columns = new ArrayList<IColumn<CountryDetails>>(); columns.add(new PropertyColumn<CountryDetails>(new Model<String>("Zone"), "zoneLabel", "zoneCode") { @Override public void populateItem(Item<ICellPopulator<CountryDetails>> item, String componentId, IModel<CountryDetails> rowModel) { CountryDetails detail = rowModel.getObject(); StringResourceModel srm = new StringResourceModel(detail.getZoneCode(), item, rowModel); item.add(new Label(componentId, srm)); detail.setZoneLabel(srm.getString()); } }); but all I got is a NullPointerException because a ZoneLabel is empty at some point in the sort and and a lot of warnings in the logs : - WARN org.apache.wicket.Localizer - Tried to retrieve a localized string for a component that has not yet been added to the page. This can sometimes lead to an invalid or no localized resource returned. Make sure you are not calling Component#getString() inside your Component's constructor. Offending component: [MarkupContainer [Component id = 1]] Any ideas ? thanks in advance, Olivier.