Examples of TemplateScript


Examples of com.cosmo.ui.templates.TemplateScript

    * @throws PageRenderException
    */
   @Override
   public String render(Workspace workspace, PageContext page, String uuid) throws TemplateUnavailableException, PageRenderException
   {
      TemplateScript script;
      TemplateLink link;
      TemplateControl tctrl;
      StringBuilder xhtml = new StringBuilder();

      Template template = workspace.getTemplate();

      try
      {
         // Confecciona la cabecera
         xhtml.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">").append("\n");
         xhtml.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"es\" lang=\"es\">").append("\n");
         xhtml.append("<head>").append("\n");
         xhtml.append(TAB_SEPARATOR + "<title>").append(page.getTitle()).append("</title>").append("\n");
         xhtml.append(TAB_SEPARATOR + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=").append(page.getCharset()).append("\"></meta>").append("\n");
         xhtml.append(TAB_SEPARATOR + "<meta name=\"generator\" content=\"" + Cosmo.COSMO_NAME + "\"></meta>").append("\n");
         xhtml.append(TAB_SEPARATOR + "<meta name=\"uuid\" content=\"" + uuid + "\"></meta>").append("\n");

         // Inserta Scripts y Links de la p�gina
         Iterator<TemplateLink> itl = template.getLinks();
         while (itl.hasNext())
         {
            link = itl.next();
            xhtml.append(TAB_SEPARATOR + link.render());
         }

         Iterator<TemplateScript> its = template.getScripts();
         while (its.hasNext())
         {
            script = its.next();
            xhtml.append(TAB_SEPARATOR + script.render());
         }

         // Inserta Scripts y Links de los controles
         for (Control ctrl : page.getCenterContents())
         {
View Full Code Here

Examples of org.jostraca.TemplateScript

  }


  public void testByPath() {
   
    TemplateScript bts = null;
    PropertySet    ps  = new PropertySet();

    try {
      bts = BasicTemplateScript.defineByPath( null );
      fail();
    } catch( Exception e) {
      //e.printStackTrace();
      assertTrue( true );
    }

    try {
      bts = BasicTemplateScript.defineByPath( "foo.jtm" );
      assertTrue( "".equals( bts.getOriginalScriptName() ) );
      assertTrue( "".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }

    try {
      bts.setByPath( null );
      fail();
    } catch( Exception e) {
      //e.printStackTrace();
      assertTrue( true );
    }
   
    try {
      bts.setByPath( "foo.jtm" );
      assertTrue( "".equals( bts.getOriginalScriptName() ) );
      assertTrue( "".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }

    try {
      bts.setByPath( "foo_bar.jtm" );
      assertTrue( "bar".equals( bts.getOriginalScriptName() ) );
      assertTrue( "bar".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }


    try {
      ps.set( Property.PREFIX_jostraca_TemplateScript_CanonicalName + "br", "bar" );
      bts.setByPath( "foo_br.jtm" );
      assertTrue( "br".equals( bts.getOriginalScriptName() ) );
      assertTrue( "bar".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }
View Full Code Here

Examples of org.jostraca.TemplateScript



  public void testByProperty() {
   
    TemplateScript bts = null;
    PropertySet    ps  = new PropertySet();

    try {
      bts = BasicTemplateScript.defineByProperty( null );
      fail();
    } catch( Exception e) {
      //e.printStackTrace();
      assertTrue( true );
    }

    try {
      bts = BasicTemplateScript.defineByProperty( ps );
      assertTrue( "".equals( bts.getOriginalScriptName() ) );
      assertTrue( "".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }

    try {
      ps.set( Property.main_TemplateScript, "bar" );
      bts = BasicTemplateScript.defineByProperty( ps );
      assertTrue( "bar".equals( bts.getOriginalScriptName() ) );
      assertTrue( "bar".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }


    try {
      bts.setByProperty( null );
      fail();
    } catch( Exception e) {
      //e.printStackTrace();
      assertTrue( true );
    }
   
    try {
      ps  = new PropertySet();
      bts = BasicTemplateScript.defineByProperty( ps );
      bts.setByProperty( ps );
      assertTrue( "".equals( bts.getOriginalScriptName() ) );
      assertTrue( "".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }


    try {
      ps.set( Property.main_TemplateScript, "bar" );
      bts.setByProperty( ps );
      assertTrue( "bar".equals( bts.getOriginalScriptName() ) );
      assertTrue( "bar".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }


    try {
      ps.set( Property.main_TemplateScript, "br" );
      ps.set( Property.PREFIX_jostraca_TemplateScript_CanonicalName + "br", "bar" );
      bts.setByProperty( ps );
      assertTrue( "br".equals( bts.getOriginalScriptName() ) );
      assertTrue( "bar".equals( bts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }
View Full Code Here

Examples of org.jostraca.TemplateScript

  /** existing definition is not deleted by undefined main.TemplateScript property */
  public void testOverride() {
    try {
      PropertySet    ps  = new PropertySet();
      TemplateScript ts = BasicTemplateScript.defineByProperty( ps );
      ts.setByPath( "foo_bar.jtm" );
      ts.setByProperty( ps );
      assertTrue( "bar".equals( ts.getOriginalScriptName() ) );
      assertTrue( "bar".equals( ts.getCanonicalScriptName( ps ) ) );

    } catch( Exception e) {
      e.printStackTrace();
      fail();
    }
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.