Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

we are getting a class cast exception while casting DirectorDTO into CompanyForm

 
Siddharth Maheshwari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are getting a class cast exception while casting DirectorDTO into CompanyForm

List DirectorList = companyform.getDirectorData(); // returns directorDTO

(CompanyForm)DirectorList.get(i).ischecked()==true //this line shows class cast exception.



please help me to get this resolved
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give the companyform.getDirectorData(); code..

How about if you change your code like this below..



Thanks..
 
Siddharth Maheshwari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Leonardo

i tried your code but it shows Cont convert from object to company form

i tried this also

CompanyForm cf=(CompanyForm)DirectorList.get(i);

it shows class cast exception

below is the companyform.getDirectorData(); code...

public List DirectorData()
{
List getrecordsList5=new ArrayList();
List mylist2=new ArrayList();
getrecordsList5 = companyService.fatchDirectorvalue();
if (getrecordsList5 != null && getrecordsList5.size() > 0)
{
Iterator itr = getrecordsList5.iterator();
while (itr.hasNext())
{
Director director=( Director) itr.next();
DirectorDTO directorDTO=new DirectorDTO();

directorDTO.setDirectorid(director.getDirectorid());
directorDTO.setCompanyid(director.getCompanyid());
directorDTO.setDchinesename(director.getDchinesename());
directorDTO.setDenglishname(director.getDenglishname());
directorDTO.setDcity(director.getDcity());
directorDTO.setDcompanyno(director.getDcompanyno());
directorDTO.setDcountry(director.getDcountry());
directorDTO.setDstate(director.getDstate());
directorDTO.setDaddress(director.getDaddress());
directorDTO.setDemail(director.getDemail());
directorDTO.setDzipcode(director.getDzipcode());

mylist2.add(directorDTO)
}
return mylist2;

}
else
{
mylist2=null;
return mylist2;


}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic