Note that there are some explanatory texts on larger screens.

plurals
  1. POAttempt to set model object on null model of component
    text
    copied!<p>I'm new to Wicket, but googling this problem didn't give me anything that made sense. So I'm hoping someone in SO can help.</p> <p>I have a SiteChoice object that extends Form, and a SiteList object that extends DropDownChoice. My SiteChoice class looks like:</p> <pre><code> public class SiteChoice extends Form { public SiteChoice(String id) { super(id); addSiteDropDown(); } private void addSiteDropDown() { ArrayList&lt;DomainObj&gt; siteList = new ArrayList&lt;DomainObj&gt;(); // add objects to siteList ChoiceRenderer choiceRenderer = new ChoiceRenderer&lt;DomainObj&gt;("name", "URL"); this.add(new SiteList("siteid",siteList,choiceRenderer)); } } </code></pre> <p>Then I simply add my SiteChoice object to my Page object a la:</p> <pre><code> SiteChoice form = new SiteChoice("testform"); add(form); </code></pre> <p>My Wicket template has: </p> <p>When I bring up the page, it renders fine -- the drop-down list is correctly rendered. When I hit Submit, I get this strange error:</p> <pre><code>WicketMessage: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = fittest]] threw an exception Root cause: java.lang.IllegalStateException: Attempt to set model object on null model of component: testform:siteid at org.apache.wicket.Component.setDefaultModelObject(Component.java:3033) at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168) at [snip] </code></pre> <p>I can't figure out what is null. It rendered fine, so it found the objects. What am I missing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload