I have a blackberry app that essentially does a select query on information I enter so if I enter "5" it does a select * from table where id=5
so I get back results. However the else statement of this clause is supposed to return "no results found". Code posted below:
public void onResponse(String data, int code) {
final Vector vehicleInfo = jasonParser.parseVechicleResponse(data);
if(vehicleInfo.size() > 0 ){
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
removeLoader();
UiApplication.getUiApplication().pushScreen(new VehicleSearchResultScreen(etfVehicleInfo.getText(),vehicleInfo));
}
});
}else{
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
removeLoader();
Dialog.alert("No Results found.");
}
});
}
}
The problem with this code is if vehicleinfo.size() = 0
this else statement does not run.
The code that runs is the code posted below which is my error code. Which is supposed to get called when collection errors occur. So basicallly, when a record is not found its displaying the string for connection errors, and I cannot at all figure why this else statement is not running; or does it run, and is over run by the following statment?
public void onError(final String data, int code) {
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
removeLoader();
Dialog.alert("No Results Found!");
}
});
}
Parse Code
public Vector parseVehicleResponse(String response){
Vector vector = new Vector();
try{
JSONObject jsonVehicleObject = new JSONObject(response);
VehicleObject vehicle = new VehicleObject();
vehicle.setChassisNum(jsonVehicleObject.getString("chassis_no"));//chassis_num
vehicle.setEngineNum(jsonVehicleObject.getString("engine_no"));//engine_num
vector.addElement(vehicle);
}catch(Exception e){
System.out.println("JSONResponseParser.parseNewsHeadlines() " + e );
}
return vector;
}
}
Json
// Return encoded with JSON
$result = array(
"chassis_no"=>$chassis_no,
"engine_no"=>$engine_no,
);