jakarta-ecs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cvs commit: jakarta-ecs/example JSPTestBed.java VXMLTestBed.java WMLTestBed.java
Date Mon, 12 Mar 2001 18:32:22 GMT
snagy       01/03/12 10:32:22

  Added:       example  JSPTestBed.java VXMLTestBed.java WMLTestBed.java
  Log:
  PR: the new classes do not belong to a package (just like the original TestBed).
  i've replaced tabs with four spaces and tied them up so that they comply a
  little better with the current coding standard.
  i've tried to replace testN methods with more desciptive names and added a
  little documentation where i can.
  otherwise, they're just as they were before.
  
  1. i guess that these files need to be added into this new location (rather
  than patchs) so i've attached the new files. if it's patches that are needed,
  could somebody point me in the right direction...
  
  2. i don't think that anyone will be relying on the old classes so it should
  be safe to remove them. but i could submit deprecated versions if that's
  what's needed.
  
  3. the documentation for these isn't brilliant. what'd be great would be for
  somebody to volunteer to improve the examples documentation as a whole. (but
  i'm not volunteering...)
  
  4. i guess the examples/README.txt should be updated. i'm willing to submit a
  patch. on the other hand, if there's somebody who really fancies doing 3, then
  i'll leave it.
  
  - robert
  
  Submitted by: Robert Burrell Donkin robertdonkin@appleonline.net
  
  Revision  Changes    Path
  1.1                  jakarta-ecs/example/JSPTestBed.java
  
  Index: JSPTestBed.java
  ===================================================================
  /*
   * Copyright (c) 2000 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache 
   *    Project. <http://java.apache.org/>"
   *
   * 4. The names "Java Apache Element Construction Set", "Java Apache ECS" and 
   *    "Java Apache Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 5. Products derived from this software may not be called 
   *    "Java Apache Element Construction Set" nor "Java Apache ECS" appear 
   *    in their names without prior written permission of the 
   *    Java Apache Project.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache 
   *    Project. <http://java.apache.org/>"
   *    
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Java Apache Project. For more information
   * on the Java Apache Project please see <http://java.apache.org/>.
   *
   */
  import org.apache.ecs.jsp.*;
  import org.apache.ecs.Document;
  import org.apache.ecs.html.*;
  
  
  /**
      This class contains some simple tests of the jsp generation package
  
      @author Written by <a href="mailto:jcarol@us.ibm.com">Carol Jones</a>
  */
  public class JSPTestBed
  {
      /**
      this method prints a test jsp page which uses beans to standard out
      */
      public void jspBeanTest()
      {
          System.out.println("\n" + new org.apache.ecs.html.Comment("jspBeanTest"));
  
          Document doc = new Document();
          jsp_useBean bean = new jsp_useBean("bean1", "page", "Person");
          jsp_setProperty set = new jsp_setProperty("bean1", "last", "Jones");
          jsp_getProperty get = new jsp_getProperty("bean1", "first");
          bean.addElement(set);
          doc.appendBody(bean);
          doc.appendBody(new P());
          doc.appendBody(get);
          doc.appendBody(new jsp_scriptlet("out.println(\"hello\");"));
          IMG img = new IMG();
          jsp_expression expr = new jsp_expression("bean1.getPhoto()");
          img.setSrc(expr.toString());
          doc.appendBody(img);
  
          System.out.println(doc.toString());
      }
  
      /**
      this method prints a test jsp page which uses page forwarding and includes to standard
out
      */
      public void jspIncludeForwardingTest()
      {
          System.out.println("\n" + new org.apache.ecs.html.Comment("jspIncludeForwardingTest"));
  
          Document doc = new Document();
          jsp_page page= new jsp_page("java", "true", "16k", "true",
                                  "true", "false", "text/html", "iso");
          doc.appendBody(page);
      
          jsp_include inc = new jsp_include("anotherpage.jsp");
          jsp_forward fwd = new jsp_forward("anotherpage.jsp");
          doc.appendBody(inc);
          doc.appendBody(fwd);
          System.out.println(doc.toString());
      }
  
      /**
      this method prints a test jsp page which uses tsx data-access tags to standard out
      */
      public void jspTSXTest()
      {
          System.out.println("\n" + new org.apache.ecs.html.Comment("jspTSXTest"));
  
          Document doc = new Document();
          tsx_dbconnect conn = new tsx_dbconnect(
              "conn1", 
              "jdbc:db2:sample", 
              "com.ibm.db2.db2driver", 
              "wsdemo", 
              "wsdemo1");
          tsx_dbquery query = new tsx_dbquery("query1", "conn1", "10");
          query.addElement("select * from staff");
          tsx_dbmodify modify = new tsx_dbmodify("modify", "conn1");
          tsx_repeat rep = new tsx_repeat("i", "1", "10");
          tsx_getProperty getProp = new tsx_getProperty("query1", "lastname");
          rep.addElement(getProp);
          doc.appendBody(conn);
          doc.appendBody(query);
          doc.appendBody(rep);
      
          tsx_setProperty setProp = new tsx_setProperty("modify1", "lastname", "Jones");
          modify.addElement("delete from staff where lastname='Jones'");
          doc.appendBody(setProp);
          doc.appendBody(modify);
  
      
          System.out.println(doc.toString());
      }
  
      /**
      this application prints three jsp test pages to standard out
      */
      public static void main(String[] args)
      {
          JSPTestBed tb = new JSPTestBed();
      	System.out.println("\n" + new org.apache.ecs.html.Comment("JSPTestBed - JSP Test Pages
Follow"));
          tb.jspBeanTest();
          tb.jspIncludeForwardingTest ();
          tb.jspTSXTest();
      }
  }
  
  
  
  
  
  1.1                  jakarta-ecs/example/VXMLTestBed.java
  
  Index: VXMLTestBed.java
  ===================================================================
  /*
   * Copyright (c) 2000 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache 
   *    Project. <http://java.apache.org/>"
   *
   * 4. The names "Java Apache Element Construction Set", "Java Apache ECS" and 
   *    "Java Apache Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 5. Products derived from this software may not be called 
   *    "Java Apache Element Construction Set" nor "Java Apache ECS" appear 
   *    in their names without prior written permission of the 
   *    Java Apache Project.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache 
   *    Project. <http://java.apache.org/>"
   *    
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Java Apache Project. For more information
   * on the Java Apache Project please see <http://java.apache.org/>.
   *
   */
  import org.apache.ecs.vxml.*;
  import org.apache.ecs.html.Comment;
  
  /**
      This class contains some simple tests of the vxml generation package
  
      @author Written by <a href="mailto:jcarol@us.ibm.com">Carol Jones</a>
  */
  public class VXMLTestBed
  {
      
      public void HelloWorldTest() 
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("HelloWorld.vxml"));
   
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form();
          Block block = new Block();
          block.addElement("Hello World!");
          form.addElement(block);
          vxml.addElement(form);
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void DrinkTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Drink.vxml"));    
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form();
          Field field = new Field("drink");
          Prompt prompt = new Prompt();
          prompt.addElement("Would you like coffee, tea, milk, or nothing?");
          Grammar grammar = new Grammar("drink.gram", "application/x-jsgf");
          Block block = new Block();
          block.addElement(new Submit("http://www.drink.example/drink2.asp"));
          field.addElement(prompt);
          field.addElement(grammar);
          form.addElement(field); 
          form.addElement(block);
          vxml.addElement(form);
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      
      }
      
      public void MetaTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Meta.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          vxml.addElement(new Meta().setAuthor("John Doe"));
          vxml.addElement(new Meta().setMaintainer("hello-support@hi.example"));
          vxml.addElement(new Var("hi", "'Hello World!'"));
          Form form = new Form();
          Block block = new Block();
          block.addElement(new Value("hi"));
          block.addElement(new Goto("#say_goodbye"));
          form.addElement(block);
          vxml.addElement(form);
          Form form2 = new Form("say_goodbye");
          Block block2 = new Block();
          block2.addElement("Goodbye!");
          form2.addElement(block2);
          vxml.addElement(form2);
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void LinkTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Link.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Var  var = new Var("bye", "'Ciao'");
          Link link = new Link();
          link.setNext("operator_xfer.vxml");
          Grammar grammar = new Grammar();
          grammar.addElement(" operator ");
          link.addElement(grammar);
          vxml.addElement(var);
          vxml.addElement(link);
      
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void ExitTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Exit.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form("say_goodbye");
          Field field = new Field("answer", "boolean");
          Prompt prompt = new Prompt();
          prompt.addElement("Shall we say ");
          prompt.addElement(new Value("application.bye"));
          Filled filled = new Filled();
          If iftag = new If("answer");
          iftag.addElement(new Exit());
          filled.addElement(iftag);
          filled.addElement(new Clear("answer"));
      
          field.addElement(prompt);
          field.addElement(filled);
          form.addElement(field);
          vxml.addElement(form);
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void FilledTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Filled.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form("billing_adjustment");
          Var  var1 = new Var("account_number");
          Var  var2 = new Var("home_phone");
          Subdialog sub = new Subdialog();
          sub.setName("accountinfo");
          sub.setSrc("acct_info.vxml#basic");
          Filled filled = new Filled();
          filled.addElement (new Assign("account_number", "accountinfo.acctnum"));
          filled.addElement (new Assign("home_phone", "accountinfo.acctphone"));
          sub.addElement(filled);
          Field field = new Field();
          field.setName("adjustment_amount");
          field.setType("currency");
          Prompt prompt = new Prompt(" What is the value of your account adjustment?");
          Filled filled2 = new Filled();
          filled2.addElement(new Submit("/cgi-bin/updateaccount"));
          field.addElement(prompt);
          field.addElement(filled2);
      
          form.addElement(var1);
          form.addElement(var2);
          form.addElement(sub);
          form.addElement(field);
          vxml.addElement(form);
      
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void ReturnTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Return.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form("basic");
          form.addElement(
              new Field("acctnum", "digits").addElement(
                      new Prompt(" What is your account number?")));
          Field field = new Field("acctphone", "phone");
          field.addElement(new Prompt(" What is your home telephone number?"));
          Filled filled = new Filled();
          filled.addElement(new Return("acctnum acctphone"));
          field.addElement(filled);
          form.addElement(field);
          vxml.addElement(form);
      
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
  
      public void WeatherTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Weather.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form("weather_info");
          Block block = new Block();
          block.addElement("Welcome to the weather information service.");
          Field field = new Field("city");
          Prompt prompt = new Prompt("What city?");
          Grammar grammar = new Grammar("city.gram","application/x-jsgf");
          Catch catchtag = new Catch("help");
          catchtag.addElement("Please speak the city for which you want the weather.");
          field.addElement(prompt);
          field.addElement(grammar);
          field.addElement(catchtag);
  
          form.addElement(block);
          form.addElement(field);
          form.addElement(new Block().addElement(new Submit("/servlet/weather", "city")));
          vxml.addElement(form);
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void CreditCard()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("CreditCard.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Form form = new Form("get_card_info");
          Block block = new Block();
          block.addElement("We now need your credit card type, number, and expiration date.");
          form.addElement(block);
      
          Field field = new Field("card_type");
          Prompt prompt1 = new Prompt("What kind of credit card do you have?");
          Prompt prompt2 = new Prompt("Type of card?");
          prompt1.setBargein("false");
          prompt1.setCount("1");
          prompt2.setCount("2");
      
          Grammar grammar = new Grammar();
          grammar.addElement("visa {visa}");
          grammar.addElement("| master [card] {mastercard}");
          grammar.addElement("| amex {amex}");
          grammar.addElement("| american [express] {amex}");
          Help help = new Help("Please say Visa, Mastercard, or American Express.");
          field.addElement(prompt1);
          field.addElement(prompt2);
          field.addElement(grammar);
          field.addElement(help);
          form.addElement(field);
  
  
          vxml.addElement(form);
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
      
      public void MenuTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("MenuTest.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");
          Menu menu1 = new Menu();
          Property prop = new Property();
          prop.setInputmodes("dtmf");
          menu1.addElement(prop);
          Prompt prompt = new Prompt("For sports press 1, For weather press 2, For Stargazer
astrophysics press 3.");
          menu1.addElement(prompt);
          menu1.addElement(new Choice("1","http://www.sports.example/vxml/start.vxml"));
          menu1.addElement(new Choice("2","http://www.weather.example/intro.vxml"));
          menu1.addElement(new Choice("3","http://www.stargazer.example/voice/astronews.vxml"));
          vxml.addElement(menu1);
      
          Menu menu2 = new Menu("true");
          menu2.addElement(prop);
          menu2.addElement(prompt);
          menu2.addElement(new Choice("http://www.sports.example/vxml/start.vxml"));
          menu2.addElement(new Choice("http://www.weather.example/intro.vxml"));
          menu2.addElement(new Choice("http://www.stargazer.example/voice/astronews.vxml"));
          vxml.addElement(menu2);
      
          Menu menu3 = new Menu("true");
          Prompt prompt2 = new Prompt("Welcome Home");
          Enumerate enum = new Enumerate();
          enum.addElement("For ");
          enum.addElement(new Value("_prompt"));
          enum.addElement(", press ");
          enum.addElement(new Value("_dtmf"));
          prompt2.addElement(enum);
          menu3.addElement(prompt2);
          Choice choice1 = new Choice("http://www.sports.example/vxml/start.vxml");
          Choice choice2 = new Choice("http://www.weather.example/intro.vxml");
          Choice choice3 = new Choice("http://www.stargazer.example/voice/astronews.vxml");
          choice1.addElement("sports");
          choice2.addElement("weather");
          choice3.addElement("Stargazer astrophysics news");
          menu3.addElement(choice1);
          menu3.addElement(choice2);
          menu3.addElement(choice3);
  
          vxml.addElement(menu3);
  
          System.out.println(vxml.toString());    
      }
  
      public void RepromptTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("RepromptTest.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");    
  
          vxml.addElement(new Reprompt());
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
          
      public void EmptyElements()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("EmptyElements.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");    
  
          vxml.addElement(new Block());
          vxml.addElement(new Reprompt());
          vxml.addElement(new Disconnect());
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
  
      public void MiscElements()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("MiscElements.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");    
  
          Initial init = new Initial("bypass_init");
          init.addElement(new Audio("hello.wav"));
          init.addElement(new Break("medium"));
          vxml.addElement(init);
      
          Dtmf dtmf = new Dtmf("application/x-jsgf");
          dtmf.addElement("1 {van} | 2 {choc} | 3 {straw}");
          vxml.addElement(dtmf);
          vxml.addElement(new Div("sentence"));
          vxml.addElement(new Emp("Hello!"));
          vxml.addElement(new Sayas("currency", "$123.50"));
          vxml.addElement(new Noinput("I didn't hear anything, please try again"));
          vxml.addElement(new Nomatch("Nothing matched, try again.", "1"));
          vxml.addElement(new org.apache.ecs.vxml.Error("An Error has occurred"));
          vxml.addElement(new Throw("nomatch"));
          org.apache.ecs.vxml.Object obj = new org.apache.ecs.vxml.Object();
          obj.setName("debit");
          obj.setClassid("method://credit_card/gather_and_debit");
          obj.setData("http://www.recordings.example/prompts/credit/jesse.jar");
          obj.addElement (new Param("amount", "document.amt"));
          obj.addElement (new Param("vendor", "vendor_num"));
          vxml.addElement(obj);
  
  
          doc.addElement(vxml);
          System.out.println(doc.toString());
      }
  
      public void IfTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("IfTest.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");    
  
          If iftag = new If("city == 'LA'");
          iftag.addElement(new Assign("city", "Los Angeles"));
          iftag.addElement(new Elseif("city == 'Philly'"));
          iftag.addElement(new Assign("city", "Philadelphia"));
          iftag.addElement(new Else());
          iftag.addElement(new Assign("city", "Unknown"));
          vxml.addElement(iftag);    
  
          doc.addElement(vxml);
  
          System.out.println(doc.toString());
      }
  
      public void ScriptTest()
      {
          System.out.println("\n"  + new org.apache.ecs.html.Comment("Script.vxml"));
  
          VXMLDocument doc = new VXMLDocument();
          Vxml vxml = new Vxml("1.0");    
      
          Script script = new Script();
          script.addElement("<![CDATA[\n" + 
                        "function factorial(n) { return (n <= 1)? 1 : n * factorial(n-1);
}" + 
                        "]]>");
  
          vxml.addElement(script);
          doc.addElement(vxml);
  
          doc.output(System.out);
      }
      
      public static void main(String[] args)
      {
          VXMLTestBed tb = new VXMLTestBed();
          System.out.println("\n"  + new org.apache.ecs.html.Comment("VXML Test Bed"));  

          tb.WeatherTest();
          tb.CreditCard();
          tb.MenuTest();
          tb.RepromptTest();
          tb.HelloWorldTest();
          tb.DrinkTest();
          tb.MetaTest();
          tb.LinkTest();
          tb.ExitTest();
          tb.FilledTest();
          tb.ReturnTest();    
          tb.EmptyElements();
          tb.MiscElements();
          tb.IfTest();
          tb.ScriptTest();
      }
  }
  
  
  
  
  1.1                  jakarta-ecs/example/WMLTestBed.java
  
  Index: WMLTestBed.java
  ===================================================================
  /*
   * Copyright (c) 2000 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache 
   *    Project. <http://java.apache.org/>"
   *
   * 4. The names "Java Apache Element Construction Set", "Java Apache ECS" and 
   *    "Java Apache Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 5. Products derived from this software may not be called 
   *    "Java Apache Element Construction Set" nor "Java Apache ECS" appear 
   *    in their names without prior written permission of the 
   *    Java Apache Project.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache 
   *    Project. <http://java.apache.org/>"
   *    
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Java Apache Project. For more information
   * on the Java Apache Project please see <http://java.apache.org/>.
   *
   */
  import org.apache.ecs.wml.*;
  import org.apache.ecs.html.Comment;
  
  /**
      This class contains some simple tests of the wml generation package
  
      @author Written by <a href="mailto:Anders.Samuelson@aspiro.com">Anders.Samuelson</a>
      @author Modifications by <a href="mailto:Orjan.Petersson@ehpt.com">˜rjan Petersson</a>
  */
  public class WMLTestBed
  {
      
      public void firstTest() 
      {
          Card card = new Card("card1", "A_card");
          P p =  new P(Alignment.LEFT, Mode.WRAP);
          p.addElement("How many?");
          p.addElement(new Input("*N", "nbr", Type.TEXT));
          p.addElement(new Anchor("title", "click here", 
              new Go("test2.wml", new SetVar("nbrItems", "$(nbr)"))));
          p.addElement(new BR());
          p.addElement("more text...");
          Select sel = new Select("name", "");
          sel.addElement(new Option("ALIV").addElement("Sell 10000"));
          sel.addElement(new Option("ASPI").addElement("Buy 100"));
  
          p.addElement(sel);
      
          Do doTask = new Do(DoType.ACCEPT, "StockBroker");
          doTask.addElement(new Go("http://wml_test/test.wml", new SetVar("data", "data")));
          p.addElement(doTask);            
          card.addElement(p);
      
          WML wml = new WML(card);
          WMLDocument doc = new WMLDocument(wml);
      
          System.out.println(WMLOutRenderer.parse(doc.toString()));
      }
      
      public void secondTest() 
      {
          Card card = new Card("card1", "Hello");
          P p = new P(Alignment.LEFT, Mode.WRAP);
          p.addElement("Var nbrItems: $(nbrItems)");
          p.addElement(new BR());
          p.addElement("Click on a link!");
          p.addElement(new Anchor("titel", "Test1", 
              new Go("http://wml_test/test.wml", new SetVar("Namn:", "namn"))));
          Select sel = new Select("Select:", "");
          sel.addElement(new Option("ALIV").addElement("Sell 10000"));
          sel.addElement(new Option("ASPI").addElement("Buy 100"));
          p.addElement(sel);
          p.addElement("Newlink");
          p.addElement(new A("#card1", "emme"));
          card.addElement(p);
          WML wml = new WML();
          Template t = new Template();
          Do doTask = new Do(DoType.ACCEPT, "Back");
          doTask.addElement(new Prev());
          t.addElement(doTask);
          wml.addElement(t);
          wml.addElement(card);
          WMLDocument doc = new WMLDocument(wml);
      
          System.out.println(WMLOutRenderer.parse(doc.toString()));
  
      }
      
      
      public static void main(String[] args)
      {
          WMLTestBed tb = new WMLTestBed();
          System.out.println("");
          System.out.println(new org.apache.ecs.html.Comment("wml test pages - share dealing
examples "));    
          System.out.println(new org.apache.ecs.html.Comment("first wml test page"));
          tb.firstTest();
          System.out.println("");
          System.out.println(new org.apache.ecs.html.Comment("second wml test page"));
          tb.secondTest();
      }
  }
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-dev-help@jakarta.apache.org


Mime
View raw message