It's not a secret anymore!*
The moose likes JSF and the fly likes classcast exception  in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "classcast exception  in bean" Watch "classcast exception  in bean" New topic
Author

classcast exception in bean

swati cha
Ranch Hand

Joined: Jul 04, 2006
Posts: 40
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);

}
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1



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

Joined: Jul 04, 2006
Posts: 40
thanku i got it fixed by passing in to an onject.
 
 
subject: classcast exception in bean
 
Similar Threads
selectManyCheckbox
Trouble using Map with h:selectOneMenu...
Bean Value is always Null
selectOneMenu and custom converter
SelectItem Help needed