我使用GXT-2.1.1开发项目。我想通过选中(复选框)在网格中显示所选车辆组的车辆详细信息。我有vehicleGroup组合框,它显示组名。如何显示所选组名的车辆。我使用两个商店1.storeVehicleFrom拥有所有车辆细节和2.storeTempVehicleFrom只有下组车辆。在我的下面我的代码。它将显示错误msg classcastException。如何解决此问题。
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);
}
}