【问题标题】:Wicket-select2 dropdown is not update after provide new modelobject提供新模型对象后,Wicket-select2 下拉列表未更新
【发布时间】:2018-01-05 14:57:50
【问题描述】:

我有国家/地区的 wicket-select2 下拉菜单。

Select2Choice<Country> country = new Select2Choice<Country>("country", new PropertyModel<Country>(params, "selectedCountry"),new CountriesProvider(params));

点击添加国家按钮后使用popupPanel添加新国家,下面是功能。

Country addCountry = new Country();
//provide data of country for setter and add in db and setting countrydropdown Model Object by using below code:
country.setModelObject(addCountry);
param.setCountry(countrylistUpdated);
country.setprovider(new CountryProvider);
target.add(addCountry);

页面被重定向到主页,但出现以下错误

org.apache.wicket.WicketRuntimeException: Exception in rendering component: [DropDownChoice [Component id = qualityDropDown]]
at org.apache.wicket.Component.internalRenderComponent(Component.java:2589)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1698)
at org.apache.wicket.Component.internalRender(Component.java:2380)
at org.apache.wicket.Component.render(Component.java:2308)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1524)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1759)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1734)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1657)


........



//some more logs...
......
Caused by: java.lang.NullPointerException: List of choices is null - Was the supplied 'Choices' model empty?
at org.apache.wicket.markup.html.form.AbstractChoice.getChoices(AbstractChoice.java:233)
at org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:376)
at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:70)
at org.apache.wicket.Component.internalRenderComponent(Component.java:2565)
... 103 more

如果我选择任何国家然后点击添加按钮并保存新国家然后它会在下拉列表中显示新添加的国家。

【问题讨论】:

  • 关于这个问题的任何想法
  • list 为 null 不填充任何内容
  • 列表不为空。我已经设置列表抱歉没有提到更新列表代码
  • 我提供了一组列表。
  • 你检查列表或设置是否包含任何项目?当然列表是空的,这就是你收到错误的原因

标签: java wicket jquery-select2 wicketstuff


【解决方案1】:

我得到了答案,需要在数据库中保存国家后设置选定的国家而不是设置模型对象。见以下代码:

Country addCountry = new Country();
//provide data of country for setter and add in db and setting countrydropdown Model Object by using below code:
country.setSelectedCountry(addCountry);
param.setCountry(countrylistUpdated);
country.setprovider(new CountryProvider);
target.add(addCountry);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-14
    • 2014-04-12
    • 2019-06-14
    • 1970-01-01
    相关资源
    最近更新 更多