2
我有一個做了Navison查找並返回ObservableList或空任務。
無論如果,如果看起來是成功的,該列表填充與否任務總是調用失敗()和從來沒有成功()!
任何想法爲什麼發生這種情況?
這是我的任務:
是什麼讓一個JavaFX 2任務成功/失敗
public class LoadLocsTask extends Task<Void>{
Button button;
@Override protected Void call() throws Exception {
ObservableList<String> list = application.getValidator().getLocList(button.getText());
if(list != null){
locationList.setItems(list);
}else{
Dialogs.showErrorDialog(application.getPrimaryStage(),"An error occured while retrieving the loaction list from navision.", "Please contact IS department", "Unable To Populate Location List");
locationList.setItems(null);
}
return null;
}
@Override protected void succeeded() {
super.succeeded();
selectProgressIndicator.setVisible(false);
disableSelected(button);
}
@Override protected void failed() {
super.failed();
selectProgressIndicator.setVisible(false);
disableSelected(button);
}
@Override protected void scheduled() {
super.scheduled();
locationList.getSelectionModel().clearSelection();
locationList.setItems(null);
selectProgressIndicator.setVisible(true);
disableAll();
}
@Override protected void cancelled() {
super.cancelled();
logger.info("Cancelled");
locationList.setItems(null);
selectProgressIndicator.setVisible(true);
}
這裏是application.getValidator()getLocList(button.getText())
public ObservableList<String> getLocList(String selectedLoc) {
ObservableList<String> binsOL = null;
String warehouseCode = null;
if (selectedLoc.equalsIgnoreCase("location1")) {
warehouseCode = "LOCATION1";
} else if (selectedLoc.equalsIgnoreCase("location2")) {
warehouseCode = "LOCATION2";
} else if (selectedLoc.equalsIgnoreCase("location3")) {
warehouseCode = "LOCATION3";
} else if (selectedLoc.equalsIgnoreCase("location4")) {
warehouseCode = "LOCATION4";
} else if (selectedLoc.equalsIgnoreCase("location5")) {
warehouseCode = "LOCATION5";
}
if (warehouseCode != null) {
try {
binsOL = FXCollections.observableArrayList();
Bins[] bins = navWebservice.getBinsList(warehouseCode);
for (Bins bin : bins) {
binsOL.add(bin.getCode());
}
} catch (RemoteException e) {
logger.error("LocationSelectionController - processLocButton(): Could not generate list for " + warehouseCode + " button", e);
Dialogs.showErrorDialog(parentApp.getPrimaryStage(), e.getMessage(), "Please contact IS department", "Unable To Populate Location List");
}
}
return binsOL;
}
在此先感謝!
@jewelsea你爲什麼不把那作爲一個答案? – ConquerorsHaki