当前位置: 首页>>代码示例>>Java>>正文


Java Function.f方法代码示例

本文整理汇总了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;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:History.java

示例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]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:25,代码来源:GwtTestCoreCollection.java

示例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);
        }
    }
    ));
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:24,代码来源:GwtTestCoreCollection.java

示例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"));
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:GwtTestCoreModel.java

示例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());
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:GwtTestCoreModel.java

示例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;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:10,代码来源:Router.java

示例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);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:28,代码来源:GwtTestCoreCollection.java

示例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]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:31,代码来源:GwtTestCoreModel.java

示例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]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:34,代码来源:GwtTestCoreModel.java

示例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;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:10,代码来源:SimpleSyncModel.java

示例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);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:10,代码来源:ExtendedOptionsSyncModel.java

示例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();
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:55,代码来源:LocalStorageSyncStrategy.java


注:本文中的com.google.gwt.query.client.Function.f方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。