Package org.mozilla.javascript

Examples of org.mozilla.javascript.Function


    /* (non-Javadoc)
     * @see org.apache.cocoon.forms.validation.ValidatorBuilder#build(org.apache.cocoon.forms.formmodel.WidgetDefinition, org.w3c.dom.Element)
     */
    public WidgetValidator build(Element element, WidgetDefinition definition) throws Exception {
            Function function = JavaScriptHelper.buildFunction(element, "validate", ARG_NAMES);

            return new JavaScriptValidator(this.avalonContext, function);
    }
View Full Code Here


       
        String jsText = buffer.toString();
        String sourceName = DomHelper.getSystemIdLocation(element);

        Context ctx = Context.enter();
        Function func;
        try {
            func = ctx.compileFunction(
                getRootScope(null), //scope
                jsText, // in
                sourceName == null ? "<unknown>" : sourceName, // sourceName
View Full Code Here

        /*
         * process the request by invoking the controller "process()" function
         */
        private Object process(Context context, Scriptable scope) {
            _scope = scope; // save this for the didRespond() method above;
            Function function = getFunction("process", scope, context);
            Object[] args = new Object[] {
                Context.javaToJS(_path, scope),
                Context.javaToJS(_request, scope),
                Context.javaToJS(_response, scope)
            };
            return function.call(context, scope, scope, args);
        }
View Full Code Here

    private ProcessInfoProvider processInfoProvider;
    /* (non-Javadoc)
     * @see org.apache.cocoon.forms.validation.ValidatorBuilder#build(org.apache.cocoon.forms.formmodel.WidgetDefinition, org.w3c.dom.Element)
     */
    public WidgetValidator build(Element element, WidgetDefinition definition) throws Exception {
            Function function = JavaScriptHelper.buildFunction(element, "validate", ARG_NAMES);

            return new JavaScriptValidator(this.processInfoProvider, function);
    }
View Full Code Here

                    path = otherBinding.getPath();
                }
            }

            // Build load script
            Function loadScript = null;
            if (commonAtts.loadEnabled) {
                if (otherBinding != null) {
                    loadScript = otherBinding.getLoadScript();
                }

                Element loadElem = DomHelper.getChildElement(element, BindingManager.NAMESPACE, "load-form");
                if (loadElem != null) {
                  loadScript = JavaScriptHelper.buildFunction(loadElem, "loadForm", JavaScriptJXPathBinding.LOAD_PARAMS);
                }
            }

            // Build save script
            Function saveScript = null;
            if (commonAtts.saveEnabled) {
              if (otherBinding != null) {
                    saveScript = otherBinding.getSaveScript();
                }
View Full Code Here

       
        String jsText = buffer.toString();
        String sourceName = DomHelper.getSystemIdLocation(element);

        Context ctx = Context.enter();
        Function func;
        try {
            func = ctx.compileFunction(
                getRootScope(null), //scope
                jsText, // in
                sourceName == null ? "<unknown>" : sourceName, // sourceName
View Full Code Here

    private ProcessInfoProvider processInfoProvider;

    public WidgetListener buildListener(Element element, Class listenerClass) throws Exception {

        Function func = JavaScriptHelper.buildFunction(element, "handleEvent", new String[]{"widget", "event"});

        if (listenerClass == ActionListener.class) {
            return new JavaScriptWidgetListener.JSActionListener(func, processInfoProvider);
        } else if (listenerClass == CreateListener.class) {
            return new JavaScriptWidgetListener.JSCreateListener(func, processInfoProvider);
View Full Code Here

        while (stok.hasMoreTokens()) {
            String fname = stok.nextToken();
            ret.addTriggerWidget(fname);
        }

        Function func = JavaScriptHelper.buildFunction(algorithmElement, "calculate", new String[]{"form", "parent"});
        ret.setJsfunction(func);

        return ret;
    }
View Full Code Here

  /**
   * ECMA 11.4.3 says that typeof on host object is Implementation-dependent
   */
  public void test0() throws Exception
  {
        final Function f = new BaseFunction()
        {
          @Override
          public Object call(Context _cx, Scriptable _scope, Scriptable _thisObj,
              Object[] _args)
          {
View Full Code Here

      try {
          cx.setOptimizationLevel(-1); // must use interpreter mode
          cx.evaluateString(globalScope,
                  "function f(a) { return myObject.f(a); }",
                  "function test source", 1, null);
          Function f = (Function) globalScope.get("f", globalScope);
          Object[] args = { 7 };
          cx.callFunctionWithContinuations(f, globalScope, args);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          Object applicationState = pending.getApplicationState();
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Function

Copyright © 2018 www.massapicom. 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.