本文整理汇总了Java中com.google.web.bindery.requestfactory.shared.Receiver类的典型用法代码示例。如果您正苦于以下问题:Java Receiver类的具体用法?Java Receiver怎么用?Java Receiver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Receiver类属于com.google.web.bindery.requestfactory.shared包,在下文中一共展示了Receiver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fire
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
/**
* Make sure there's a default receiver so errors don't get dropped. This behavior should be
* revisited when chaining is supported, depending on whether or not chained invocations can fail
* independently.
*/
@Override
public void fire() {
boolean needsReceiver = true;
for (final AbstractRequest<?, ?> request : this.state.invocations) {
if (request.hasReceiver()) {
needsReceiver = false;
break;
}
}
if (needsReceiver) {
this.doFire(new Receiver<Void>() {
@Override
public void onSuccess(final Void response) {
// Don't care
}
});
} else {
this.doFire(null);
}
}
示例2: save
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的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());
}
});
}
示例3: onRangeChanged
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的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());
}
});
}
示例4: doDeleteTask
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的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();
}
});
}
示例5: toggleInUse
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
public void toggleInUse(WeekDay day) {
final TimeSlotKey key = new TimeSlotKey(day, hour);
if (currentSchedule.contains(key)) {
currentSchedule.remove(key);
table.redraw();
} else if (!existingSlots.containsKey(key)) {
acceptClicks = false;
ScheduleRequest context = factory.scheduleRequest();
context.createTimeSlot(day.ordinal(), hour * 60, hour * 60 + 50).fire(
new Receiver<TimeSlotProxy>() {
@Override
public void onSuccess(TimeSlotProxy slot) {
existingSlots.put(key, slot);
backing.add(slot);
currentSchedule.add(key);
table.redraw();
acceptClicks = true;
}
});
} else {
currentSchedule.add(key);
table.redraw();
}
}
示例6: fetch
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
private void fetch(final int start) {
lastFetch = start;
requestFactory.schoolCalendarRequest().getPeople(start, numRows, filter).fire(
new Receiver<List<PersonProxy>>() {
@Override
public void onSuccess(List<PersonProxy> response) {
if (lastFetch != start) {
return;
}
int responses = response.size();
table.setRowData(start, response);
pager.setPageStart(start);
if (start == 0 || !table.isRowCountExact()) {
table.setRowCount(start + responses, responses < numRows);
}
}
});
}
示例7: TransportEntry
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的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) {
}
}
示例8: processPayload
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的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);
}
}
示例9: refreshCharacter
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
private void refreshCharacter() {
requestFactory.getCharacterRequest().get(characterId).fire(new Receiver<CharacterProxy>() {
@Override
public void onSuccess(CharacterProxy response) {
if (response == null) {
goToCharacterNotFoundPlace();
} else {
editCharacter(response);
}
}
});
}
示例10: refreshCharacterList
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
private void refreshCharacterList() {
requestFactory.getCharacterRequest().get(0, 1000).fire(new Receiver<List<CharacterProxy>>() {
@Override
public void onSuccess(List<CharacterProxy> response) {
driver.edit(response, requestFactory.getCharacterRequest());
}
});
}
示例11: createCharacter
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
@Override
public void createCharacter() {
CharacterRequest request = requestFactory.getCharacterRequest();
CharacterProxy newCharacter = request.create(CharacterProxy.class);
request.persist(newCharacter).fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
refreshCharacterList();
}
});
}
示例12: onCharacterDeletion
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
@Override
public void onCharacterDeletion(CharacterDeletionEvent event) {
requestFactory.getCharacterRequest().delete(event.getId()).fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
refreshCharacterList();
}
});
}
示例13: onRangeChanged
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
@Override
protected void onRangeChanged(final HasData<EventProxy> display) {
EventRequest request = factory.eventRequest();
request.findAll().fire(new Receiver<List<EventProxy>>() {
@Override
public void onSuccess(List<EventProxy> response) {
display.setRowData(0, response);
}
});
}
示例14: loadSubject
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
@Override
public void loadSubject(Long subjectId) {
SubjectRequest request = factory.subjectRequest();
request.findById(subjectId).fire(new Receiver<SubjectProxy>() {
@Override
public void onSuccess(SubjectProxy response) {
view.loadSubject(response);
}
});
}
示例15: saveTask
import com.google.web.bindery.requestfactory.shared.Receiver; //导入依赖的package包/类
public void saveTask() {
// Flush the changes into the editable task.
TaskRequest context = (TaskRequest) clientFactory.getTaskEditView().getEditorDriver().flush();
/*
* Create a persist request the first time we try to save this task. If a
* request already exists, reuse it.
*/
if (taskPersistRequest == null) {
taskPersistRequest = context.persist().using(editTask);
}
// Fire the request.
taskPersistRequest.fire(new Receiver<Void>() {
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
handleConstraintViolations(violations);
}
@Override
public void onSuccess(Void response) {
editTask = null;
// Notify the user that the task was updated.
TaskEditPresenter.this.notify("Task Saved");
// Return to the task list.
ActionEvent.fire(eventBus, ActionNames.TASK_SAVED);
}
});
}