Re: LoadableDetachableModel and Attempt to set model object on null model of component
Ok I eventually made it work. I have to use a Model for *both* the provided values, AND the selected object (sorry, I'm a Wicket newbie). Thus, by adding a field to the page: public CompanyConfiguration selectedCompany; And then: ChoiceRendererCompanyConfiguration choiceRenderer = new ChoiceRendererCompanyConfiguration(name, id); DropDownChoiceCompanyConfiguration ddc = new DropDownChoiceCompanyConfiguration(companiesList, new PropertyModelCompanyConfiguration(this, selectedCompany), new LoadableDetachableModelListlt;CompanyConfiguration() { @Override protected ListCompanyConfiguration load() { final ListCompanyConfiguration configs = getCompaniesList(); Collections.sort((ListCompanyConfiguration) configs, new ComparatorCompanyConfiguration() { @Override public int compare(CompanyConfiguration o1, CompanyConfiguration o2) { return o1.getName().compareTo(o2.getName()); } }); return configs; } @Override public void detach() { } }, choiceRenderer); But in my case, this leads to a serialization issue, so again we have to use a LoadableDetachableModel: DropDownChoiceCompanyConfiguration ddc = new DropDownChoiceCompanyConfiguration(companiesList, new LoadableDetachableModelCompanyConfiguration() { @Override protected CompanyConfiguration load() { return null; } }, new LoadableDetachableModelListlt;CompanyConfiguration() { @Override protected ListCompanyConfiguration load() { final ListCompanyConfiguration configs = getCompaniesList(); Collections.sort((ListCompanyConfiguration) configs, new ComparatorCompanyConfiguration() { @Override public int compare(CompanyConfiguration o1, CompanyConfiguration o2) { return o1.getName().compareTo(o2.getName()); } }); return configs; } @Override public void detach() { } }, choiceRenderer); -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-and-Attempt-to-set-model-object-on-null-model-of-component-tp4659453p4659500.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
LoadableDetachableModel and Attempt to set model object on null model of component
I got a /Unexpected RuntimeException Last cause: Attempt to set model object on null model of component: form:companiesList/ whenever I select an item in my DropDownChoice. I read somewhere that it was because there is no Model set, but there *is* one (a LoadableDetachableModel) : ChoiceRendererCompanyConfiguration choiceRenderer = new ChoiceRendererCompanyConfiguration(name, id); DropDownChoiceCompanyConfiguration ddc = new DropDownChoiceCompanyConfiguration(companiesList, new LoadableDetachableModelListlt;CompanyConfiguration() { private static final long serialVersionUID = 8752933117323402630L; @Override protected ListCompanyConfiguration load() { final ListCompanyConfiguration configs = getCompaniesList(); Collections.sort((ListCompanyConfiguration) configs, new ComparatorCompanyConfiguration() { @Override public int compare(CompanyConfiguration o1, CompanyConfiguration o2) { return o1.getName().compareTo(o2.getName()); } }); return configs; } }, choiceRenderer) { protected boolean wantOnSelectionChangedNotifications() { return true; } protected void onSelectionChanged(final CompanyConfiguration newSelection) { logger.debug(Selected base: + newSelection.getId()); } }; Has anyone an idea about what I'm doing wrong? Note: I cannot serialize my CompanyConfiguration list. BTW, second question: there is a DataView with a ListDataProvider elsewhere in the page. How can I update its values from the method onSelectionChanged() above? Thanks a lot! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-and-Attempt-to-set-model-object-on-null-model-of-component-tp4659453.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
DataTable and unserializable data
Is it possible to use an implementation of DataTable (like AjaxFallbackDefaultDataTable) with unserializable data? My page throws the usual NotSerializableException, in spite of using LoadableDetachableModel everywhere I can. I am tearing my hair out to understand where the problem comes from. Can someone please help? Thanks. I want to precise that I use a LoadableDetachableModel in the method model() of my DataProvider: @Override public IModelApplication model(final Contact object) { return new LoadableDetachableModelContact() { @Override protected Contact load() { return object; } }; } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DataTable and unserializable data
A thousand thanks, Sebastian! Your sample did it! Juste a last question, out of curiosity (if you have a clue): Did this exception occur because DataTable, after retrieving the user objects from the provider, *stores* them somewhere in an inner component? And so when the Page is serialized, the DataTable is too, and my objects Contact as well? Because then I am wondering the point for a DataTable to memorize the user data... I would expect it to iterate on them, display, and then get rid of them, transiently... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659p4659678.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org