1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import org.apache.cocoon.components.flow.java.AbstractContinuable; import org.apache.cocoon.components.flow.java.VarMap; public class PosFlow extends AbstractContinuable { public void doSellItem() { double rate, amount, total, savings; double discount, discrate; int qty, delCost; String zone, delOpt; String url = "page/getRateAmt"; sendPageAndWait(url); rate = Float.parseFloat(getRequest().getParameter("rate")); qty = Integer.parseInt(getRequest().getParameter("qty")); amount = rate*qty; url="page/getZone"; sendPageAndWait(url, new VarMap().add("rate",rate).add("qty",qty)); zone = getRequest().getParameter("zone"); discount=0.02; if (zone.equals("A")) { if (qty >= 100) { discount=0.1; } } else if (zone.equals("B")) { if (qty >= 200) { discount=0.2; } } discrate = 100*discount; savings = discount*amount; delCost=0; delOpt = getRequest().getParameter("delOpt"); if (delOpt.equals("S")) { url="page/getShipOpt"; sendPageAndWait(url); delCost = Integer.parseInt(getRequest().getParameter("delCost")); } total = amount + delCost - savings; url="page/displayResult"; sendPageAndWait(url, new VarMap() .add("discrate",discrate) .add("total",total) .add("savings",savings) .add("delCost",delCost) .add("amount", amount) .add("discount", discount) .add("zone", zone)); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?xml version="1.0"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <map:flow language="java"> <map:script src="PosFlow"/> </map:flow> <map:pipelines> <map:pipeline> <map:match pattern="page/*"> <map:generate type="jx" src="screens/{1}.xml"/> <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl"> <map:parameter name="servletPath" value="{request:servletPath}"/> <map:parameter name="sitemapURI" value="{request:sitemapURI}"/> <map:parameter name="contextPath" value="{request:contextPath}"/> <map:parameter name="file" value="/samples/flow/jxrate/screens/{1}.xml"/> <map:parameter name="remove" value="{0}"/> </map:transform> <map:serialize/> </map:match> </map:pipeline> <map:pipeline> <map:match pattern="continue.*"> <map:call continuation="{1}"/> </map:match> <map:match pattern=""> <map:call function="sellItem"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> |
1 2 3 4 5 6 7 8 9 10 11 | <?xml version="1.0"?> <page> <title>Get Rate and Quantity of item to be purchased</title> <content> <form method="post" action="continue.#{$continuation/id}"> <para>Enter Rate: <input type="text" name="rate"/></para> <para>Enter Quantity: <input type="text" name="qty"/></para> <input type="submit" name="submit" value="Next"/> </form> </content> </page> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |