Esempio n. 1
0
  public WebProgram createWebProgram(List asps, JavaProgram jp) throws Exception {
    WebProgram wp = new WebProgram(asps, jp);

    for (Iterator itr = asps.iterator(); itr.hasNext(); ) {
      ASP asp = (ASP) itr.next();
      asp.translate();
    }

    // do the WebForm initialisation code
    List javaWebForms = wp.getWebForms();
    Library library = jp.getLibrary();
    for (Iterator itr = javaWebForms.iterator(); itr.hasNext(); ) {
      JavaClass jc = (JavaClass) itr.next();
      WebTranslator.addJavaComponentInitialisation(jc, library);
      doExposePageLoadMethod(jc);
    }

    // do event hookups
    List hookups = jp.getEventHookupClasses();
    for (Iterator itr = hookups.iterator(); itr.hasNext(); ) {
      EventSupport es = (EventSupport) itr.next();
      // System.out.println(es.getVBSender());
      for (Iterator itrr = asps.iterator(); itrr.hasNext(); ) {
        ASP asp = (ASP) itrr.next();
        DNVariable v = asp.getComponent(es.getVBSender().getName());
        if (v != null) {
          asp.addActionListenerFor(v, es.getName());
        }
      }
    }

    return wp;
  }
Esempio n. 2
0
  public int writeWebProgram(WebProgram wp, String webRoot, String classpath) throws Exception {
    String javaClassesDir = webRoot + File.separator + "WEB-INF" + File.separator + "classes";
    JavaProgram jp = wp.getJavaProgram();
    int i = this.writeAndCompileJavaProgram(jp, javaClassesDir, classpath);

    for (Iterator itr = wp.getASPs().iterator(); itr.hasNext(); ) {
      ASP asp = (ASP) itr.next();
      String aspFilename = Util.replaceString(asp.getName(), "aspx", "jsp");
      FileOutputStream fos = new FileOutputStream(new File(webRoot, aspFilename));
      asp.write(fos);
      // asp.write(System.out);
    }
    return i;
  }