PDA

View Full Version : Combobox selection issue in gxt-2.1.1



lakshmiarun
9 Dec 2010, 10:25 PM
Im developing the project by using GXT-2.1.1. I want to display vehicle details for selected vehicleGroup in the grid with checked(checkbox). Im having vehicleGroup combobox it is displaying groupname. How to display the vehicles for selected groupname. Im using two store 1.storeVehicleFrom having all vehicle details and 2.storeTempVehicleFrom having only the under group vehicles. Here under i my sorce code. It will display error msg classcastException.How to solve this issue.





ComboBox<VehicleGroupModel> comboGroup = new ComboBox<VehicleGroupModel>();
ListStore<VehicleGroupModel> storeGroup = new ListStore<VehicleGroupModel>();
ListStore<VehicleGroupModel> storeVehicleFrom =new ListStore<VehicleGroupModel> ();
ListStore<VehicleGroupModel> storeTempVehicleFrom = new ListStore<VehicleGroupModel>();// Temp. store

// combolistener
SelectionChangedListener<VehicleGroupModel> comboListener =new SelectionChangedListener<VehicleGroupModel>(){
@Override
public void selectionChanged(SelectionChangedEvent<VehicleGroupModel> se) {

VehicleGroupModel vg = se.getSelectedItem();
Record record = storeGroup.getRecord(vg);
ProcessGroupSelection(record);
}

};

private void ProcessGroupSelection(Record record){
try{
int groupId = record.getModel().get("groupId");
disableFlag = false;

//if(groupDetailList == null || groupDetailList.size() <= 0) return;commented by meena

for(int i = 0; i < groupDetailList.size(); i++){ // all the vehicles are unchecked first
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
Integer vehicleId = new Integer(groupDetail.getVehicleId());
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));//getAt(0).get("vehicleId");
vehicleRecord.set("vehicleId", vehicleId.toString());
vehicleRecord.set("Add", false);

}
storeTempVehicleFrom.removeAll(); // store the checkbox checked for the selected group
for(int i = 0; i < groupDetailList.size(); i++){
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
if(groupId == groupDetail.getGroupId()){
Integer vehicleId = new Integer(groupDetail.getVehicleId());
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));
vehicleRecord.set("vehicleId", vehicleId.toString());
vehicleRecord.set("Add", true);
storeTempVehicleFrom.add(vehicleRecord);
}
disableFlag = true;
}


int[] existsInGroup = new int[storeGroup.getCount()] ;//All the below is for getting the ungrouped vehicles by
//storing the vehicle ids present in vehicle Group into array and then comparing with vehicle list and get the remaining ungrouped vehicles.
if (storeTempVehicleFrom.getCount() == 0)
{
disableFlag = false;
for(int i = 0; i < groupDetailList.size(); i++){
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
for(int j=0;j< AppContext.companyVehicles.length;j++)
{
Vehicle vehicle =AppContext.companyVehicles[j];
//System.out.println("vehicle id in List "+vehicle.getId().getVehicleId()+"total Group id "+groupDetail.getVehicleId());

if(vehicle.getId().getVehicleId() == groupDetail.getVehicleId())
{
existsInGroup[i] = vehicle.getId().getVehicleId() ;
continue;
}
}
}
int flag =0;
Integer vehicleId = null ;
for(int i = 0; i < AppContext.companyVehicles.length; i++){

//System.out.println("Exists in Group "+existsInGroup.length);
for(int k=0;k<existsInGroup.length;k++)
{
//System.out.println(" "+existsInGroup[k]+" "+AppContext.companyVehicles[i].getId().getVehicleId());
vehicleId = new Integer(AppContext.companyVehicles[i].getId().getVehicleId());
if (vehicleId == existsInGroup[k])
{
flag =1;
break;
}
}
//System.out.println("Flag :"+flag);
if(flag !=1){
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));
vehicleRecord.set("Add", true);
storeTempVehicleFrom.add(vehicleRecord);

}
flag =0;
}
}

storeVehicleFrom.commitChanges();
storeTempVehicleFrom.commitChanges();
}
catch(Exception e){
ExceptionHandler.performDefaultErrorHandling(e);
}
}

sven
10 Dec 2010, 6:08 AM
Here under i my sorce code. It will display error msg classcastException.How to solve this issue.
What is the stractrace? Where does it get thrown?

Have you tried to create a small, standalone testcase implementing EntryPoint so other people are able to debug your code?