本文整理汇总了Java中com.google.web.bindery.requestfactory.shared.ServerFailure类的典型用法代码示例。如果您正苦于以下问题:Java ServerFailure类的具体用法?Java ServerFailure怎么用?Java ServerFailure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerFailure类属于com.google.web.bindery.requestfactory.shared包,在下文中一共展示了ServerFailure类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
@Override
public void save() {
CharacterRequest request = (CharacterRequest) driver.flush();
request.persist(character).fire(new Receiver<Void>() {
@Override
public void onFailure(ServerFailure error) {
view.showErrorMessage("An error occurred");
}
@Override
public void onSuccess(Void response) {
view.hideErrorMessage();
refreshCharacter();
}
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
StringBuilder builder = new StringBuilder();
for (ConstraintViolation<?> violation : violations) {
builder.append(violation.getMessage());
}
view.showErrorMessage(builder.toString());
}
});
}
示例2: onRangeChanged
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
@Override
protected void onRangeChanged(HasData<DudeProxy> display) {
final int length;
if (cursor == 0) length = listRange;
else length = incrementSize;
DudeRequestFactory.DudeRequestContext context = createFactory().context();
context.getSortedListByRange(cursor, cursor + length, sortColName, isAscending)
.fire(new Receiver<List<DudeProxy>>() {
@Override
public void onSuccess(List<DudeProxy> dudeProxyList) {
updateRowData(cursor, dudeProxyList);
cursor = cursor + length;
}
@Override
public void onFailure(ServerFailure error) {
debugLabel.setText(error.getMessage());
}
});
}
示例3: doDeleteTask
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
/**
* Delete the current task.
*/
private void doDeleteTask() {
if (editTask == null) {
return;
}
// Delete the task in the data store.
final TaskProxy toDelete = this.editTask;
clientFactory.getRequestFactory().taskRequest().remove().using(toDelete).fire(
new Receiver<Void>() {
@Override
public void onFailure(ServerFailure error) {
Window.alert("An error occurred on the server while deleting this task: \"."
+ error.getMessage() + "\".");
}
@Override
public void onSuccess(Void response) {
onTaskDeleted();
}
});
}
示例4: TransportEntry
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
public TransportEntry(RequestContext requestContext, Receiver recv) {
QosRequestTransport transport = (QosRequestTransport) requestContext.getRequestFactory().getRequestTransport();
transport.startBatch();
transport.setNextReceiverForEntry(QosRequestTransport.CAPTURE);
if (recv == null) {
requestContext.fire();
} else {
requestContext.fire(recv);
}
List<BatchedRequest> b = transport.flushBatch();
payload = b.get(0).payload;
receiver = b.get(0).receiver;
// close the RequestContext so can be re-used.
try {
receiver.onTransportFailure(new ServerFailure("GOO"));
} catch (Throwable th) {
}
}
示例5: processPayload
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
@Override
public void processPayload(final Receiver<Void> receiver, final String payload) {
final Splittable raw = StringQuoter.split(payload);
@SuppressWarnings("unchecked")
final Receiver<Object> callback =
(Receiver<Object>) AbstractRequestContext.this.state.invocations.get(0).getReceiver();
if (!raw.isNull("error")) {
final Splittable error = raw.get("error");
final ServerFailure failure = new ServerFailure(error.get("message").asString(),
error.get("code").asString(), payload, true);
AbstractRequestContext.this.fail(receiver, failure);
return;
}
final Splittable result = raw.get("result");
@SuppressWarnings("unchecked")
final Class<BaseProxy> target =
(Class<BaseProxy>) AbstractRequestContext.this.state.invocations.get(0).getRequestData()
.getReturnType();
final SimpleProxyId<BaseProxy> id =
AbstractRequestContext.this.getRequestFactory().allocateId(target);
final AutoBean<BaseProxy> bean = AbstractRequestContext.this.createProxy(target, id, true);
// XXX expose this as a proper API
((AbstractAutoBean<?>) bean).setData(result);
// AutoBeanCodex.decodeInto(result, bean);
if (callback != null) {
callback.onSuccess(bean.as());
}
if (receiver != null) {
receiver.onSuccess(null);
}
}
示例6: refreshTaskList
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
/**
* Refresh the task list.
*/
private void refreshTaskList() {
clientFactory.getRequestFactory().taskRequest().findAllTasks().fire(
new Receiver<List<TaskProxy>>() {
@Override
public void onFailure(ServerFailure error) {
// ignore
}
@Override
public void onSuccess(List<TaskProxy> response) {
// Early exit if this activity has already been canceled.
if (eventBus == null) {
return;
}
// Display the tasks in the view.
if (response == null) {
response = Collections.<TaskProxy> emptyList();
}
setTasks(response);
// save the response to storage
clientFactory.getTaskProxyLocalStorage().setTasks(response);
// Restart the timer.
refreshTimer.schedule(REFRESH_DELAY);
}
});
}
示例7: startEdit
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
private void startEdit() {
isEditing = true;
getView().setEditing(true);
// Lock the display until the task is loaded.
getView().setLocked(true);
clientFactory.getRequestFactory().taskRequest().findTask(this.taskId).fire(
new Receiver<TaskProxy>() {
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
getView().setLocked(false);
getView().getEditorDriver().setConstraintViolations(violations);
}
@Override
public void onFailure(ServerFailure error) {
getView().setLocked(false);
doCancelTask();
super.onFailure(error);
}
@Override
public void onSuccess(TaskProxy response) {
// Early exit if we have already stopped.
if (eventBus == null) {
return;
}
// Task not found.
if (response == null) {
Window.alert("The task with id '" + taskId + "' could not be found."
+ " Please select a different task from the task list.");
doCancelTask();
return;
}
// Show the task.
editTask = response;
getView().getEditorDriver().edit(response,
clientFactory.getRequestFactory().taskRequest());
getView().setLocked(false);
}
});
}
示例8: onTransportFailure
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
@Override
public void onTransportFailure(ServerFailure failure) {
setState(State.FAILED);
notifyChange();
}
示例9: onTransportFailure
import com.google.web.bindery.requestfactory.shared.ServerFailure; //导入依赖的package包/类
@Override
public void onTransportFailure(ServerFailure failure) {
}