0

I have wicket-select2 dropdown for country.

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

adding new country using popupPanel after click on add country button and below is functionality.

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);

page is redirect to home page but I am getting below error

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

while if i select any country then click on add button and save new country then it shows newly added country in dropdown.

nitin
  • 83
  • 1
  • 9
  • Any idea about the problem – nitin Jan 06 '18 at 04:30
  • list is null does not populate anything – soorapadman Jan 08 '18 at 03:37
  • List is not null. Ihave set list sorry for not mentioned the updating list code – nitin Jan 08 '18 at 05:48
  • I have provide set of list. – nitin Jan 08 '18 at 06:12
  • Did you check list or set contains any items ? surely list is empty thats's why you are getting the error – soorapadman Jan 08 '18 at 06:13
  • @soorapadman I am using wicket-select2.jar for implementing dropdown not wicket dropdown. so i am using countryprovider class which is calling query method and in this method is calling list of choices but in my case when i am not selecting any data from country dropdown, query method is not calling after save new country while if i select any country from dropdown and then try to add new country then it will call query method of countryprovider. Now I hope my query is clear. – nitin Jan 08 '18 at 06:57

1 Answers1

0

I got the answer and need to set selected country instead of setting modelObject after save country in db. see below code:

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);
nitin
  • 83
  • 1
  • 9