[ https://issues.apache.org/jira/browse/WICKET-2442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833760#action_12833760 ]
Juergen Donnerstag commented on WICKET-2442: -------------------------------------------- Looking at the code 97: IChoiceRenderer<T> renderer = getPalette().getChoiceRenderer(); 98: StringBuffer modelStringBuffer = new StringBuffer(); 99: Iterator<T> selection = getPalette().getModelCollection().iterator(); <<<< NPE getPalette() obviously return a non-null value since it works in line 97. Thus the problem must be getModelCollection() not returning a not null value. The NPE can't be inside getModelCollection() since NPE would tell you. ... getModelCollection() { return (Collection<T>)getDefaultModelObject(); } Consequently your model object is null. > Palette, NullPointer > -------------------- > > Key: WICKET-2442 > URL: https://issues.apache.org/jira/browse/WICKET-2442 > Project: Wicket > Issue Type: Bug > Components: wicket-extensions > Affects Versions: 1.4.1 > Reporter: Ulrik Hagberg > > When I try to add a Palette to a Page, I get an NullPointerException. > Stacktrace: > WicketMessage: Error attaching this container for rendering: [MarkupContainer > [Component id = palette]] > Root cause: > java.lang.NullPointerException > at > org.apache.wicket.extensions.markup.html.form.palette.component.Recorder.initIds(Recorder.java:99) > at > org.apache.wicket.extensions.markup.html.form.palette.component.Recorder.onBeforeRender(Recorder.java:86) > at org.apache.wicket.Component.internalBeforeRender(Component.java:1061) > at org.apache.wicket.Component.beforeRender(Component.java:1095) > at > org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1751) > at org.apache.wicket.Component.onBeforeRender(Component.java:3863) > at > org.apache.wicket.extensions.markup.html.form.palette.Palette.onBeforeRender(Palette.java:191) > at org.apache.wicket.Component.internalBeforeRender(Component.java:1061) > at org.apache.wicket.Component.beforeRender(Component.java:1095) > at > org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1751) > at org.apache.wicket.Component.onBeforeRender(Component.java:3863) > at org.apache.wicket.Component.internalBeforeRender(Component.java:1061) > at org.apache.wicket.Component.beforeRender(Component.java:1095) > at > org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1751) > at org.apache.wicket.Component.onBeforeRender(Component.java:3863) > at org.apache.wicket.Page.onBeforeRender(Page.java:1501) > at org.apache.wicket.Component.internalBeforeRender(Component.java:1061) > at org.apache.wicket.Component.beforeRender(Component.java:1095) > at org.apache.wicket.Component.prepareForRender(Component.java:2232) > at org.apache.wicket.Component.prepareForRender(Component.java:2269) > at org.apache.wicket.Page.renderPage(Page.java:893) > at > org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:262) > at > org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) > at > org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258) > at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) > at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) > at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) > at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) > at > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) > at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) > at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) > at java.lang.Thread.run(Thread.java:619) > Code: > public class HomePage extends WebPage { > public HomePage() { > Form _form = new Form("form"); > add(_form); > List<ChoiceModelObject> _availableChoices = new > ArrayList<ChoiceModelObject>(); > _availableChoices.add(new ChoiceModelObject(0, "a")); > _availableChoices.add(new ChoiceModelObject(1, "b")); > _availableChoices.add(new ChoiceModelObject(2, "c")); > _availableChoices.add(new ChoiceModelObject(3, "d")); > ChoiceRenderer<ChoiceModelObject> _choiceRenderer = new > ChoiceRenderer<ChoiceModelObject>() { > @Override > public Object getDisplayValue(ChoiceModelObject > choiceModelObject) { > return choiceModelObject.getName(); > } > @Override > public String getIdValue(ChoiceModelObject modelObject, int i) { > return String.valueOf(modelObject.getId()); > } > }; > _form.add(new Palette("palette", new ListModel(), new > CollectionModel(_availableChoices), _choiceRenderer, 10, true)); > } > class ChoiceModelObject implements Serializable { > private int id; > private String name; > public ChoiceModelObject() { > } > private ChoiceModelObject(int id, String name) { > this.id = id; > this.name = name; > } > public int getId() { > return id; > } > public void setId(int id) { > this.id = id; > } > public String getName() { > return name; > } > public void setName(String name) { > this.name = name; > } > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.