Ejemplo n.º 1
0
  private void genOutReference(PrintWriter out, UIPage uiPage) {
    String jsEntityName = entityName.replace('.', '_');

    out.write("\n    Form.initPageJs = ");
    out.print(jsEntityName);
    out.write("_initPageJs;\n\n    Form.finalizePageJs = ");
    out.print(jsEntityName);
    out.write("_finalizePageJs;\n");

    List<PageOutType> outs = uiPage.getOuts();
    for (PageOutType oType : outs) {
      String functionName = oType.getName() + "_OutFunctionName";

      out.write("\n    Form.");
      out.print(functionName);
      out.write(" = ");
      out.print(jsEntityName);
      out.write("_");
      out.print(functionName);
      out.write(";\n");
    }
  }
Ejemplo n.º 2
0
  private void generateJs(File rootPath, UIPage uipageData) {
    try {
      refJS = new ArrayList();
      entityName = uipageData.getEntityName();
      Map pageOuts = null;
      UIBaseType uiEntity = (UIBaseType) uipageData.getUIEntity();
      pageOuts = new HashMap();

      List<PageOutType> outs = uipageData.getOuts();
      for (PageOutType pageOut : outs) {
        pageOuts.put(pageOut.getFunctionName(), pageOut.getName());
      }

      if (uiEntity != null) {
        // Don't need the user js at this moment.
        // jsText = JSMerge.getSingleText(rootPath.getAbsolutePath(), jsName);
        refJS = new ArrayList();
        generateJsFile(out, uiEntity);
        genHandlerReference(out, uiEntity);
        genOutReference(out, uipageData);
        out.write("\n    Form.__AJAXSubmit = false;\n    ");

        out.write("\n    Form.__entityName=\"");
        out.print(uipageData.getEntityName());
        out.write("\";\n");

        genReturnJS(out);
        out.write("\n    /* EventHandler Functions */\n");
        genOtherFunc(out);
        genFunctionHead(out, pageOuts, uiEntity, referenceMap);
        generateAppJS(out, uipageData);
        JSMerge.clearFuncList();
      }
    } catch (Exception ex) {
      logger.error("Error generating JavaScript for UIEntity/UIPage " + entityName, ex);
    }
  }
Ejemplo n.º 3
0
  // BAJavaScriptGContext returned.
  public void generateAppJS(PrintWriter out, UIPage uiPage) throws Exception {
    // BAJavaScriptGContext generationContext = new BAJavaScriptGContext();
    String jsEntityName = entityName.replace('.', '_');
    String body = null;
    if (jsText != null) {
      body = JSMerge.getPartBody(entityName + ".initPageJs", jsText);
    }

    out.write("\n    function ");
    out.print(jsEntityName);
    out.write("_initPageJs(){/* Gen_First:");
    out.print(jsEntityName);
    out.write(
        "_initPageJs */\n        var constraint_result = true;\n        var UIEntity = this;\n");

    if (body != null && !body.equals("")) {
      out.write("\n        ");
      out.print(body);
      out.write("\n");
    } else {
      PageInType pageIn = uiPage.getIn();
      if (pageIn != null && pageIn.getClientAction() != null) {
        out.print(pageIn.getClientAction().getExpressionString());
      }
    }

    out.write("\n    }/* Gen_Last:");
    out.print(jsEntityName);
    out.write("_initPageJs */\n\n");

    body = null;
    if (jsText != null) {
      body = JSMerge.getPartBody(entityName + ".finalizePageJs", jsText);
    }

    out.write("\n    function ");
    out.print(jsEntityName);
    out.write("_finalizePageJs(){/* Gen_First:");
    out.print(jsEntityName);
    out.write("_finalizePageJs */\n");

    if (body != null && !body.equals("")) {

      out.write("\n        ");
      out.print(body);
      out.write("\n");

    } else {
      if (uiPage.getFinalize() != null) {
        out.print(uiPage.getFinalize().getExpressionString());
      }
    }

    out.write("\n    }/* Gen_Last:");
    out.print(jsEntityName);
    out.write("_finalizePageJs */\n\n");

    List<PageOutType> outs = uiPage.getOuts();
    for (PageOutType oType : outs) {
      String functionName = oType.getName() + "_OutFunctionName";

      out.write("\n    function ");
      out.print(jsEntityName);
      out.write("_");
      out.print(functionName);
      out.write("(eventsource) {/* Gen_First:");
      out.print(jsEntityName);
      out.write("_");
      out.print(functionName);
      out.write(
          " */\n        var constraint_result = true;\n        var myForm;\n        if (this.formName != undefined)\n        {\n            myForm = document.forms[this.formName];\n        }\n        else\n        {\n            var p = this.Form.parentNode;\n            while(p.tagName != \"FORM\")\n                p = p.parentNode;\n            myForm = p;//document.forms[0];\n        }\n");

      body = null;
      if (jsText != null) {
        body = JSMerge.getPartBody(entityName + "." + functionName, jsText);
      }
      if (body != null && !body.equals("")) {
        out.write("\n");
        out.print(body);
        out.write("\n");
      } else {
        out.write("\n        var UIEntity = this;\n");
        if (oType.isValidate()) {
          out.write("\n        constraint_result = this.Form.validate();\n");
        }

        if (oType.getClientAction() != null) {
          out.print(oType.getClientAction().getExpressionString());
        }

        String frameName = oType.getFrameName();
        if (frameName == null) {
          frameName = "_self";
        }

        out.write("        \n        myForm._outname.value = \"");
        out.print(oType.getName());
        out.write("\";\n        myForm.target = \"");
        out.print(frameName);
        out.write("\";\n");
      }
      out.write(
          "             \n        if ( (constraint_result == true || constraint_result == null) && (!ajax_execute_onerror) ) {\n");

      if (uiPage.isIsAjaxHandlingAllowed()) {
        out.write(
            "            UIMaster.trigger2PhaseSubmit(myForm.action,myForm._pagename.value,myForm._outname.value,myForm.getAttribute('_framePrefix'),myForm._portletId,myForm.target);\n");
      } else {
        out.write("          myForm.submit();\n");
      }

      out.write("        }\n        return constraint_result;\n    }/* Gen_Last:");
      out.print(jsEntityName);
      out.write("_");
      out.print(functionName);
      out.write(" */\n");
    }
    // return generationContext;
    /* importBA(out, clClient, generationContext); */
  }