Examples of JavaScript


Examples of booton.translator.Javascript

     * @param scriptable A target scriptable source.
     */
    final Object executeAsJavascript(Method method) {
        Class source = method.getDeclaringClass();
        String sourceName = source.getSimpleName();
        Javascript script = Javascript.getScript(source);

        try {
            // compile as Javascript
            String compiled = script.write(defined);

            // script engine read it
            engine.execute(html, compiled, sourceName, 1);

            // write test script
            String wraped = Javascript.writeMethodCode(Throwable.class, "wrap", Object.class, "e");
            String encode = Javascript.writeMethodCode(ClientStackTrace.class, "encode", Throwable.class, wraped);
            String invoker = "try {" + Javascript.writeMethodCode(source, method.getName()) + ";} catch(e) {" + encode + ";}";

            // invoke test script
            Object result = engine.execute(html, invoker, sourceName, 1);

            if (result == null || result instanceof Undefined || result instanceof UniqueTag) {
                return null; // success
            } else {
                // fail (AssertionError) or error

                // decode as Java's error and rethrow it
                Source code = new Source(sourceName, compiled.length() != 0 ? compiled : script.write());
                Throwable throwable = ClientStackTrace.decode((String) result, code);

                if (throwable instanceof AssertionError || throwable instanceof InternalError) {
                    dumpCode(code);

                    throwable = new PowerAssertOffError(throwable);
                }
                throw I.quiet(throwable);
            }
        } catch (ScriptException e) {
            dumpCode(source);
            // script parse error (translation fails) or runtime error
            Source code = new Source(sourceName, script.write());

            if (e.getScriptSourceCode() == null) {
                Throwable cause = e.getCause();

                if (cause instanceof EcmaError) {
View Full Code Here

Examples of com.vaadin.annotations.JavaScript

            List<String> scriptDependencies = new ArrayList<String>();
            List<String> styleDependencies = new ArrayList<String>();

            for (Class<? extends ClientConnector> class1 : newConnectorTypes) {
                JavaScript jsAnnotation = class1
                        .getAnnotation(JavaScript.class);
                if (jsAnnotation != null) {
                    for (String uri : jsAnnotation.value()) {
                        scriptDependencies.add(manager.registerDependency(uri,
                                class1));
                    }
                }
View Full Code Here

Examples of com.vaadin.annotations.JavaScript

            List<String> scriptDependencies = new ArrayList<String>();
            List<String> styleDependencies = new ArrayList<String>();

            for (Class<? extends ClientConnector> class1 : newConnectorTypes) {
                JavaScript jsAnnotation = class1
                        .getAnnotation(JavaScript.class);
                if (jsAnnotation != null) {
                    for (String uri : jsAnnotation.value()) {
                        scriptDependencies.add(manager.registerDependency(uri,
                                class1));
                    }
                }
View Full Code Here

Examples of com.vaadin.annotations.JavaScript

            List<String> scriptDependencies = new ArrayList<String>();
            List<String> styleDependencies = new ArrayList<String>();

            for (Class<? extends ClientConnector> class1 : newConnectorTypes) {
                JavaScript jsAnnotation = class1
                        .getAnnotation(JavaScript.class);
                if (jsAnnotation != null) {
                    for (String uri : jsAnnotation.value()) {
                        scriptDependencies.add(registerDependency(uri, class1));
                    }
                }

                StyleSheet styleAnnotation = class1
View Full Code Here

Examples of com.vaadin.ui.JavaScript

    }

    public JavaScript getJavaScript() {
        if (javaScript == null) {
            // Create and attach on first use
            javaScript = new JavaScript();
            javaScript.extend(uI);
        }
        return javaScript;
    }
View Full Code Here

Examples of com.vaadin.ui.JavaScript

    private Log log = new Log(5);

    @Override
    protected void setup(VaadinRequest request) {
        addComponent(log);
        final JavaScript js = JavaScript.getCurrent();
        js.addFunction("testing.doTest", new JavaScriptFunction() {
            @Override
            public void call(JsonArray arguments) {
                log.log("Got " + arguments.length() + " arguments");
                log.log("Argument 1 as a number: " + (int) arguments.getNumber(0));
                log.log("Argument 2 as a string: " + arguments.getString(1));
                log.log("Argument 3.p as a boolean: "
                        + arguments.getObject(2).getBoolean("p"));
                log.log("Argument 4 is JSONObject.NULL: "
                        + (arguments.get(3) instanceof JsonNull));
                js.removeFunction("testing.doTest");
            }
        });
        js.execute("window.testing.doTest(42, 'text', {p: true}, null)");
    }
View Full Code Here

Examples of com.vaadin.ui.JavaScript

    }

    public JavaScript getJavaScript() {
        if (javaScript == null) {
            // Create and attach on first use
            javaScript = new JavaScript();
            javaScript.extend(uI);
        }
        return javaScript;
    }
View Full Code Here

Examples of com.vaadin.ui.JavaScript

    }

    public JavaScript getJavaScript() {
        if (javaScript == null) {
            // Create and attach on first use
            javaScript = new JavaScript();
            javaScript.extend(uI);
        }

        return javaScript;
    }
View Full Code Here

Examples of de.undercouch.bson4jackson.types.JavaScript

    o.put("Code1", new CodeWScope("alert('test');", scope));
    o.put("Code2", new Code("alert('Hello');"));
   
    Map<?, ?> data = parseBsonObject(o);
    assertEquals(2, data.size());
    JavaScript c1 = (JavaScript)data.get("Code1");
    JavaScript c2 = (JavaScript)data.get("Code2");
    assertEquals("alert('test');", c1.getCode());
    assertEquals("alert('Hello');", c2.getCode());
    Map<String, Object> c1scope = c1.getScope();
    assertEquals(5, c1scope.get("Int32"));
  }
View Full Code Here

Examples of org.jboss.arquillian.ajocado.encapsulated.JavaScript

   }

   private void loadCustomLocationStrategies(AjaxSelenium selenium)
   {
      // jQuery location strategy
      JavaScript strategySource = JavaScript.fromResource("javascript/selenium-location-strategies/jquery-location-strategy.js");
      selenium.addLocationStrategy(ElementLocationStrategy.JQUERY, strategySource);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.