java - LazyList.decorate - InstantiateFactory: The constructor must exist and be public exception -
i have code:
public class user ... private list<country> countries = lazylist.decorate(new arraylist(), factoryutils.instantiatefactory(country.class)); private string country; ... public void setcountries(list<country> countries) { this.countries = countries; } public list<country> getcountries() { return countries; } ... in country class:
public class country { private int countryid; private string countryname; public country(int countryid, string countryname) { this.countryid = countryid; this.countryname = countryname; } public int getcountryid() { return countryid; } public void setcountryid(int countryid) { this.countryid = countryid; } public string getcountryname() { return countryname; } public void setcountryname(string countryname) { this.countryname = countryname; } } when create new user object give exception:
java.lang.illegalargumentexception: instantiatefactory: constructor must exist , public
anyone know why?
seems constructor have is:
public country(int countryid, string countryname) while factory expects find no-arg constructor (common requirement):
public country() add country class , you'll fine.
Comments
Post a Comment