• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

classcast exception in bean

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
List<SelectItem> sList = (List<SelectItem>)getExpSessionObj().getExpTypeList();
Iterator<SelectItem> iter = (Iterator<SelectItem>)sList.iterator();
While( iter.hasNext();) {
object item = iter.next().;
log.debug("** item value:"+ item.getClass());
String value = item.getDescription();
// log.debug("** item value:"+ value.getClass());
if (value .equals(Constants.RENT)){
RentalExpense rentType = new RentalExpense();
rentType.setLandlord(new ContactInformation());
//getExpSessionObj().setCurrentExpenseType(rentType);
((List<AbstractExpense>)answer.getAnswer()).add(rentType);
}else{
Expense expense = new RentalExpense();
//getExpSessionObj().setCurrentExpenseType(expense);
((List<AbstractExpense>)answer.getAnswer()).add(expense);

}
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


getExpSessionObj().getExpTypeList() is not returning a list of SelectItems, so you're getting a class-cast exception.

Once you stop sending non SelectItem objects to the List of SelectItems, you will stop getting a ClassCastException.

I could guess something else. Of course, if you told us which classes were causing the ClassCastException, it'd be more than a guess.

-Cameron McKenzie
 
swati cha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanku i got it fixed by passing in to an onject.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic