本文整理汇总了Java中com.google.gwt.query.client.Function.f方法的典型用法代码示例。如果您正苦于以下问题:Java Function.f方法的具体用法?Java Function.f怎么用?Java Function.f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.query.client.Function
的用法示例。
在下文中一共展示了Function.f方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadUrl
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
private boolean loadUrl(String fragmentOverride) {
// If the root doesn't match, no routes can match either.
if(!matchRoot()) return false;
String fragment = this.fragment = this.getFragment(fragmentOverride);
for (int i = 0; i < handlers.length(); i++) {
Properties handler = handlers.get(i);
RegExp route = handler.get("route");
Function callback = handler.getFunction("callback");
if (route.test(fragment)) {
callback.f(fragment);
return true;
}
}
return false;
}
示例2: testFetchWithAnErrorResponseTriggersAnErrorEvent
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testFetchWithAnErrorResponseTriggersAnErrorEvent() {
class LocalCollection extends Collection<Model> {
@Override
public Promise sync(String method, Options options) {
Function error = options.get("error");
error.f();
return null;
}
}
final int[] counter = {0};
LocalCollection collection = new LocalCollection();
collection.on("error", new Function() {
@Override
public void f() {
counter[0]++;
}
});
collection.fetch();
assertEquals(1, counter[0]);
}
示例3: testCollectionCreateSuccessArguments
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testCollectionCreateSuccessArguments() {
Collection collection = new Collection() {
@Override
public Model create(Options attrs, Options options) {
Model model = super.create(attrs, options);
Function success = options.get("success");
success.f(model, "response", options);
return model;
}
};
collection.setUrl("test");
collection.create(O(), O(
"success", new Function() {
@Override
public void f() {
String response = getArgument(1);
assertEquals("response", response);
}
}
));
}
示例4: testSaveInPositionalStyle
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testSaveInPositionalStyle() {
class TestSyncModel extends Model {
public TestSyncModel() {
super();
}
@Override
public Promise sync(String method, Options options) {
Function success = options.get("success");
success.f();
return null;
}
}
Model model = new TestSyncModel();
model.saveKV("title", "Twelfth Night");
assertEquals("Twelfth Night", model.get("title"));
}
示例5: testSaveWithWaitAndSuppliedId
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testSaveWithWaitAndSuppliedId() {
class TestSyncModel extends Model {
public TestSyncModel() {
super();
}
@Override
public Promise sync(String method, Options options) {
Function success = options.get("success");
success.f(null, options);
return null;
}
}
final Model model = new TestSyncModel();
model.setUrlRoot("/collection");
model.save(O("id", 42), O("wait", true));
assertEquals("/collection/42", model.getUrl());
}
示例6: if
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
/**execute: function(callback, args, name) {
if (callback) callback.apply(this, args);
},*/
protected boolean execute(Function callback, String[] args, String name) {
if(callback != null) {
callback.f(args);
}
return true;
}
示例7: testModelDestroyRemovesFromAllCollections
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testModelDestroyRemovesFromAllCollections() {
class LocalModel extends Model {
public LocalModel(Options attributes) {
super(attributes);
}
@Override
public Promise sync(String method, Options options) {
Function success = options.get("success");
success.f();
return null;
}
}
LocalModel e = new LocalModel(O("id", 5, "title", "Othello"));
Collection<LocalModel> colE = new Collection<LocalModel>(e);
Collection<LocalModel> colF = new Collection<LocalModel>(e);
e.destroy();
assertEquals(0, colE.length());
assertEquals(0, colF.length());
assertEquals(e.getCollection(), null);
}
示例8: testSaveFetchDestroyTriggersErrorEventWhenAnErrorOccurs
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testSaveFetchDestroyTriggersErrorEventWhenAnErrorOccurs() {
final int[] count = {0};
class TestSyncErrorModel extends Model {
public TestSyncErrorModel() {
super();
}
@Override
public Promise sync(String method, Options options) {
Function error = options.get("error");
error.f();
return null;
}
}
TestSyncErrorModel model = new TestSyncErrorModel();
model.on("error", new Function() {
@Override
public void f() {
count[0]++;
}
});
model.save(O("data", 2, "id", 1));
model.fetch();
model.destroy();
assertEquals(3, count[0]);
}
示例9: testOptionsIsPassedToSuccessCallbacks
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
public void testOptionsIsPassedToSuccessCallbacks() {
final int[] count = {0};
class SyncModel extends Model {
public SyncModel() {
super();
}
@Override
public Promise sync(String method, final Options options) {
Function success = options.get("success");
success.f();
return null;
}
}
Model model = new SyncModel();
Options opts = O(
"success", new Function() {
@Override
public void f() {
count[0]++;
}
}
);
model.save(O("id", 1), opts);
model.fetch(opts);
model.destroy(opts);
assertEquals(3, count[0]);
}
示例10: sync
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
@Override
public Promise sync(String method, Options options) {
options.extend(new Options("specialSync", true));
Function success = options.get("success");
success.f(this, null, options);
return null;
}
示例11: sync
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
@Override
public Promise sync(String method, Options options) {
options.extend(new Options("specialSync", true));
Function success = options.get("success");
success.f(this, null, options);
return super.sync(method, options);
}
示例12: sync
import com.google.gwt.query.client.Function; //导入方法依赖的package包/类
@Override
public Promise sync(String method, Synchronized syncModel, Options options) {
JSONValue response = null;
String errorMessage = null;
Deferred syncDfd = new Deferred();
try {
if(method.equals("read")) {
if(syncModel instanceof Model) {
Model model = (Model) syncModel;
response = find(model.getId()).toJsonValue();
} else if(syncModel instanceof Collection) {
response = findAll().toJsonValue();
}
} else if(method.equals("create")) {
response = create((Options) syncModel.toJSON()).toJsonValue();
} else if(method.equals("update")) {
response = update((Options) syncModel.toJSON()).toJsonValue();
} else if(method.equals("delete")) {
response = destroy((Options) syncModel.toJSON()).toJsonValue();
}
} catch (Exception e) {
errorMessage = e.getMessage();
}
if(response != null) {
syncModel.trigger("sync", syncModel, response, options);
if(options != null && options.containsKey("success")) {
Function success = options.get("success");
success.f(response);
}
syncDfd.resolve(response);
} else {
errorMessage = errorMessage != null ? errorMessage : "Record Not Found";
if(options != null && options.containsKey("error")) {
Function error = options.get("error");
error.f(errorMessage);
}
syncDfd.reject(errorMessage);
}
// add compatibility with $.ajax
// always execute callback for success and error
if(options != null && options.containsKey("complete")) {
Function complete = options.get("complete");
complete.f(response);
}
return syncDfd.promise();
}