cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ovi...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/schecoon/webapp/examples/calc calc.js displayResult.xsp getNumberA.xsp getNumberB.xsp getOperator.xsp
Date Sun, 24 Mar 2002 07:30:40 GMT
ovidiu      02/03/23 23:30:40

  Added:       src/scratchpad/schecoon/webapp/examples/calc calc.js
                        displayResult.xsp getNumberA.xsp getNumberB.xsp
                        getOperator.xsp
  Log:
  Added.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/scratchpad/schecoon/webapp/examples/calc/calc.js
  
  Index: calc.js
  ===================================================================
  function calculator()
  {
    print ("cocoon = " + cocoon);
  
    var a = getNumber("a");
    var b = getNumber("b", a);
    var op = getOperator(a, b);
  
    function getNumber(name, a, b)
    {
      sendPage("xsp",
               { "source" : "examples/calc/getNumber" + name.toUpperCase() + ".xsp" },
               { "a" : a, "b" : b });
      return parseFloat(cocoon.request.getParameter(name));
    }
  
    function getOperator(a, b)
    {
      sendPage("xsp",
               { "source" : "examples/calc/getOperator.xsp" },
               { "a" : a, "b" : b });
      return cocoon.request.getParameter("operator");
    }
  
    function sendResult(result)
    {
      sendPage("xsp",
               { "source" : "examples/calc/displayResult.xsp" },
               { "a" : a, "b" : b, "operator" : op, "result" : result });
      return cocoon.request.getParameter("operator");
    }
  
    switch (op) {
    case "+":
      sendResult(a + b);
      break;
    case "-":
      sendResult(a - b);
      break;
    case "*":
      sendResult(a * b);
      break;
    case "/":
      sendResult(a / b);
      break;
    default:
      sendResult("Error: Unkown operator!");
    }
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/schecoon/webapp/examples/calc/displayResult.xsp
  
  Index: displayResult.xsp
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    Author: Ovidiu Predescu "ovidiu@cup.hp.com"
  
    Date: March 23, 2002
   -->
  
  <xsp:page
    language="java"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:jpath="http://apache.org/xsp/jpath/1.0"
    >
    
    <html>
  
      <form action="/calc">
  
        <p><b>a</b> = <jpath:value-of select="a"/></p><br/>
        <p><b>b</b> = <jpath:value-of select="b"/></p><br/>
        <p>Operator = <b><jpath:value-of select="operator"/></b></p><br/>
        <p>Result = <b><jpath:value-of select="result"/></b></p><br/>
        <input type="submit" name="submit" value="Do it again!"/>
  
      </form>
  
    </html>
  
  </xsp:page>
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/schecoon/webapp/examples/calc/getNumberA.xsp
  
  Index: getNumberA.xsp
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    Author: Ovidiu Predescu "ovidiu@cup.hp.com"
  
    Date: March 23, 2002
   -->
  
  <xsp:page
    language="java"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:jpath="http://apache.org/xsp/jpath/1.0"
    >
    
    <html>
  
      <form><xsp:attribute name="action"><xsp:expr>"kont/" + <jpath:continuation/></xsp:expr></xsp:attribute>
  
        <p>Enter value of <b>a</b>: <input type="text" name="a"/></p><br/>
        <input type="submit" name="submit" value="Enter"/>
      </form>
  
    </html>
  
  </xsp:page>
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/schecoon/webapp/examples/calc/getNumberB.xsp
  
  Index: getNumberB.xsp
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    Author: Ovidiu Predescu "ovidiu@cup.hp.com"
  
    Date: March 23, 2002
   -->
  
  <xsp:page
    language="java"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:jpath="http://apache.org/xsp/jpath/1.0"
    >
    
    <html>
  
      <form><xsp:attribute name="action">/kont/<jpath:continuation/></xsp:attribute>
  
        <p><b>a</b> = <jpath:value-of select="a"/></p><br/>
        <p>Enter value of <b>b</b>: <input type="text" name="b"/></p><br/>
        <input type="submit" name="submit" value="Enter"/>
  
      </form>
  
    </html>
  
  </xsp:page>
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/schecoon/webapp/examples/calc/getOperator.xsp
  
  Index: getOperator.xsp
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    Author: Ovidiu Predescu "ovidiu@cup.hp.com"
  
    Date: March 23, 2002
   -->
  
  <xsp:page
    language="java"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:jpath="http://apache.org/xsp/jpath/1.0"
    >
    
    <html>
  
      <form><xsp:attribute name="action">/kont/<jpath:continuation/></xsp:attribute>
  
        <p><b>a</b> = <jpath:value-of select="a"/></p><br/>
        <p><b>b</b> = <jpath:value-of select="b"/></p><br/>
        <p>Enter operator
          <select name="operator">
            <option>+</option>
            <option>-</option>
            <option>*</option>
            <option>/</option>
          </select>
        </p><br/>
        <input type="submit" name="submit" value="Do it"/>
  
      </form>
  
    </html>
  
  </xsp:page>
  
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message