0
爲什麼此方法不保存新選定的類別。我的代碼有問題嗎?爲什麼TextField中的setText不起作用?
catCon = new TextField();
rowEditing.addEditor(catConfig, catCon);
這是用於設置catCon代碼:
TextButton save = new TextButton("Save");
save.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
selectedItems = new LinkedList<Short>();
for (int i = 0; i < toCat.size(); i++) {
selectedItems.add(toCat.get(i).getIDCategory());
}
Collections.sort(selectedItems);
newSelectedItems = selectedItems.toString().replace(",", "-").replace("[", "").replace("]", "").replace(" ", "");
msg = new MessageBox("SELECTED ITEMSSSSSSSSS: " + selectedItems.size() + " " + newSelectedItems);;
msg.show();
catCon.setText(newSelectedItems);
hide();
}
});
,這是其中的COMMITED改變保存:
rowEditing.getSaveButton().addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
store.commitChanges();
service.saveUserRights(store.get(index), new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
msg = new MessageBox("Error", caught.getMessage());
msg.show();
}
@Override
public void onSuccess(Boolean result) {
if (result) {
msg = new MessageBox("Information", "Changes saved.");
msg.show();
service.getURListGrid(new AsyncCallback<List<UserRights>>() {
@Override
public void onFailure(Throwable caught) {
MessageBox msg = new MessageBox("Error", caught.getMessage());
msg.show();
}
@Override
public void onSuccess(List<UserRights> result) {
store = new ListStore<UserRights>(properties.idRight());
store.addAll(result);
grid.reconfigure(store, cm);
}
});
} else {
msg = new MessageBox("Error", "Failed to save changes.");
msg.show();
}
}
});
}
});
當我要設置catCon有將不會改變數據,但當我手動輸入類別時,將會有變化。有人能幫助我嗎?
當您啓用自動提交時會發生什麼? store.setAutoCommit(true) – udeleng 2015-02-25 00:54:23
@udeleng我會嘗試這一行代碼。謝謝 – 2015-02-25 01:07:52
@udeleng我很抱歉,但它不起作用。它不保存新選擇的類別 – 2015-02-25 01:13:23