I have a Wicket dropdown which is showing country list in page, below is code in java file
new DropDownChoice("CountryList",
new PropertyModel(Country, "site"),
params.getPopCountryList(),
new ChoiceRenderer("countryName", "countryId")
).add(new AjaxFormComponentUpdatingBehavior("onchange"){
@Override
protected void onUpdate(AjaxRequestTarget target) {
//do some code here
}
});
and Country.java is like
public class Country{
private Site site = null;
public Site getSite() {
if (site == null) {
site = new Site();
site.setSiteName("Expired ID");
site.setSiteId(siteId);
}
return site;
}
public void setSite(Site site) {
this.site = site;
}
}
and Site is having countryName and countryId setter and getter. Now when I changes the dropdown value then getting below error :
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
... 36 more
Caused by: org.apache.wicket.util.convert.ConversionException: Could not convert value: Armenia to type: com....model.Site. Could not find compatible converter.
at org.apache.wicket.ConverterLocator$DefaultConverter.convertToObject(ConverterLocator.java:121)
at org.apache.wicket.core.util.lang.PropertyResolverConverter.convert(PropertyResolverConverter.java:95)
at org.apache.wicket.core.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1194)
at org.apache.wicket.core.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:651)
at org.apache.wicket.core.util.lang.PropertyResolver.setValue(PropertyResolver.java:151)
at org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:131)
at org.apache.wicket.Component.setDefaultModelObject(Component.java:3082)
at org.apache.wicket.markup.html.form.FormComponent.setModelObject(FormComponent.java:1579)
at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1097)
at org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.onEvent(AjaxFormComponentUpdatingBehavior.java:151)
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:155)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:593)
I have also debug this issue, error comes before onupdate method of Ajax. Please suggest.
UPDATE : below is the code for getPopCountryList in parameters POJO.
public List<Site> getPopCountryList() {
return popCountryList;
}
public void setPopCountryList(List<Site> popCountryList) {
this.popCountryList = popCountryList;
}
and also below code for setting countryList.
List<Site> countryList;
countryList = dao.getcoutryList();
params.setPopCountryList(countryList);