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
Re: Attempt to set model object on null model of component
You need to find if the component who throw the exception is the same agent constructed with lines you report and on what moment the component lost his model. On Mon, Sep 28, 2009 at 11:28 PM, Sam Barrow s...@sambarrow.com wrote: I'm getting this exception: java.lang.IllegalStateException: Attempt to set model object on null model of component: form:agent The only reason i can find is that the field has a null model, but i added a new Model() to the field and im still getting it DropDownChoiceAgent agent = new DropDownChoiceAgent(agent, new ModelAgent(), agentList); - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos
Attempt to set model object on null model of component
I'm getting this exception: java.lang.IllegalStateException: Attempt to set model object on null model of component: form:agent The only reason i can find is that the field has a null model, but i added a new Model() to the field and im still getting it DropDownChoiceAgent agent = new DropDownChoiceAgent(agent, new ModelAgent(), agentList); - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Attempt to set model object on null model of component when submitting a form
Hi, I've the following code: private static final ListString SEARCH_DOMAINS = Arrays.asList(AA, BB); ... private void addSearchForm() { Form searchForm = new Form(searchForm); searchForm.add(new DropDownChoice(searchDomain, SEARCH_DOMAINS)); searchForm.add(new TextField(areaCode, new Model(), Integer.class)); Button submiButton = new Button(submiButton) { private static final long serialVersionUID = 1L; public void onSubmit() { info(submiButton executed); } }; searchForm.add(submiButton); add(searchForm); } When I hit the submit button I get this error: Attempt to set model object on null model of component. Could you please tell me what am I doing wrong? Gr. Azzeddine
AW: Attempt to set model object on null model of component when submitting a form
Your DropDownChoice element has no Model so the submit code does not know where to store your selection. Add a new ModelString() to it's constructor. -Ursprüngliche Nachricht- Von: Azzeddine Daddah [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 16. September 2008 15:01 An: users@wicket.apache.org Betreff: Attempt to set model object on null model of component when submitting a form Hi, I've the following code: private static final ListString SEARCH_DOMAINS = Arrays.asList(AA, BB); ... private void addSearchForm() { Form searchForm = new Form(searchForm); searchForm.add(new DropDownChoice(searchDomain, SEARCH_DOMAINS)); searchForm.add(new TextField(areaCode, new Model(), Integer.class)); Button submiButton = new Button(submiButton) { private static final long serialVersionUID = 1L; public void onSubmit() { info(submiButton executed); } }; searchForm.add(submiButton); add(searchForm); } When I hit the submit button I get this error: Attempt to set model object on null model of component. Could you please tell me what am I doing wrong? Gr. Azzeddine - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Attempt to set model object on null model of component when submitting a form
Thanks Stefan :) On Tue, Sep 16, 2008 at 3:04 PM, Stefan Lindner [EMAIL PROTECTED] wrote: Your DropDownChoice element has no Model so the submit code does not know where to store your selection. Add a new ModelString() to it's constructor. -Ursprüngliche Nachricht- Von: Azzeddine Daddah [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 16. September 2008 15:01 An: users@wicket.apache.org Betreff: Attempt to set model object on null model of component when submitting a form Hi, I've the following code: private static final ListString SEARCH_DOMAINS = Arrays.asList(AA, BB); ... private void addSearchForm() { Form searchForm = new Form(searchForm); searchForm.add(new DropDownChoice(searchDomain, SEARCH_DOMAINS)); searchForm.add(new TextField(areaCode, new Model(), Integer.class)); Button submiButton = new Button(submiButton) { private static final long serialVersionUID = 1L; public void onSubmit() { info(submiButton executed); } }; searchForm.add(submiButton); add(searchForm); } When I hit the submit button I get this error: Attempt to set model object on null model of component. Could you please tell me what am I doing wrong? Gr. Azzeddine - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Azzeddine Daddah www.hbiloo.com