var
comingBack = false; var bookmark = cocoon.createWebContinuation(ttl); // Attach the form to the continuation so that we can access by just knowing the continuation idbookmark.setAttribute(
"form", this.form); if (comingBack) { // We come back to the bookmark: process the form if (finished && cocoon.request.getParameter("cocoon-ajax-continue") != null) { // A request with this parameter is sent by the client upon receiving the indication // that Ajax interaction on the form is finished (see below). // We also check "finished" to ensure we won't exit showForm() because of some // faulty or hacked request. It's set to false, this will simply redisplay the form. return bookmark;}
if (this.restoreHook) { this.restoreHook(this);}
var formContext = new Packages.org.apache.cocoon.forms.FormContext(cocoon.request, this.locale); // Prematurely add the viewdata as in the object model so that event listeners can use it // (the same is done by cocoon.sendPage()) // FIXME : hack needed because FOM doesn't provide access to the object model var objectModel = org.apache.cocoon.components.ContextHelper.getObjectModel(this.avalonContext);org.apache.cocoon.components.flow.FlowHelper.setContextObject(objectModel, viewdata);
finished =
this.form.process(formContext); if (finished) { this.isValid = this.form.isValid(); var widget = this.form.getSubmitWidget(); // Can be null on "normal" submit this.submitId = widget == null ? null : widget.getId(); if (cocoon.request.getParameter("cocoon-ajax") != null) { // Ask the client to issue a new request reloading the whole page. // As we have nothing special to send back, so a header should be just what we need... // e.g. cocoon.response.setHeader("X-Cocoon-Ajax", "continue"); // cocoon.sendStatus(200); // ...but Safari doesn't consider empty responses (with content-length = 0) as // valid ones. So send a continue response by using directly the HttpResponse's // output stream. Avoiding this hack would require to put an additional pipeline // in the sitemap for just sending constant response, which isn't nice.cocoon.sendStatus(200);
var httpResponse = objectModel.get(org.apache.cocoon.environment.http.HttpEnvironment.HTTP_RESPONSE_OBJECT); if (httpResponse) {httpResponse.setContentType(
"text/xml"); var text = "<?xml version='1.0'?><bu:document xmlns:bu='" +org.apache.cocoon.ajax.BrowserUpdateTransformer.BU_NSURI +
"'><bu:continue/></bu:document>";httpResponse.setContentLength(text.length);
httpResponse.writer.print(text);
}
else { // Empty responsecocoon.response.setHeader(
"Content-Length", "0");}
FOM_Cocoon.suicide();
}
return bookmark;}
}
comingBack =
true;viewdata =
this.buildViewData(viewdata)cocoon.sendPage(uri, viewdata, bookmark);
// Clean up after sending the page if (this.cleanupHook) { this.cleanupHook(this);}
FOM_Cocoon.suicide();
--
Hippo
Oosteinde 11
1017WT Amsterdam
The
Netherlands
Tel +31 (0)20
5224466
-------------------------------------------------------------
[EMAIL PROTECTED]
/ http://www.hippo.nl
--------------------------------------------------------------
-----Original Message-----Ard,
From: Andrew Madu [mailto:[EMAIL PROTECTED]
Posted At: woensdag 5 juli 2006 18:44
Posted To: Cocoon User List
Conversation: Problem with continuation bookmark in flowscript/jxt
Subject: Re: Problem with continuation bookmark in flowscript/jxt
sorry, I still don't get it!! In the context of:
var bkm = cocoon.createWebContinuation();
......
cocoon.sendPageAndWait("orderFail.xml", {bookmark:bkm, "OrderDetails":neworder, "transaction_message": response.getCVV2Code()});
how do I implement :Form.prototype.sendFormAndWait = function(){regards
}
?
Andrew
On 05/07/06, Ard Schrijvers <[EMAIL PROTECTED]> wrote:Hello Andrew,take a look at Form.prototype.sendFormAndWait in Form.js in the cocoon code. Think you will get the idea if you look at that one,Regards ArdHi,
I am having some problems implementing a continuation bookmark. Basically a user enters some form details and submits the details:
function confirmStage() {
//2. Get card details.
var form = new Form("forms/CreditCardDetails.xml");
form.showForm("CreditCardDetails.xml", {"userGlobal":userGlobal});
var model = form.getModel();
var bizData = {"fname" : model.fname, "lname" : model.lname, "account_no" : model.account_no, "credit" : model.credit, "month" : model.month, "year" : model.year}
//2b. Create bookmark just incase users order is rejected
var bkm = cocoon.createWebContinuation ();
Later in the same function a check is done to determine whether a users details are valid. If not the user is redirected to a fail page informing them of the failed transaction and providing them with a link to go back to the page/state they were before they submitted their details:
//Credit card was not accepted. Direct user to enter another card.
cocoon.sendPageAndWait("orderFail.xml", {bookmark:bkm, "OrderDetails":neworder, "transaction_message": response.getCVV2Code()});
orderFail.xml:
<tr>
<td>
<form method="post" action=""http://bookmark.id" target=_blank>bookmark.id }.kont">
<input type="submit" />
</form>
</td>
</tr>
sitemap:
<map:match pattern="**.kont">
<map:select type="request-method">
<map:when test="POST">
<map:call continuation="{request-param:continuation-id}"/>
</map:when>
<map:otherwise/>
</map:select>
</map:match>
when I click the submit button I get the following trace read. What am I missing here?:org.apache.cocoon.ProcessingException: Sitemap: no function nor continuation given in <map:call function>
at <map:call> - file:/C:/Program%20Files/jboss-4.0.3
/server/default/./deploy/jbossweb- tomcat55.sar/ROOT.war/beyarecords/sitemap.xmap:817:66
at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:149)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:68)
at org.apache.cocoon.components.treeprocessor.sitemap.SelectNode.invoke(SelectNode.java:97)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:46)
at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:142)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process (
ConcreteTreeProcessor.java:234)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process( TreeProcessor.java
:248)
at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:117)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java
:46)
at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java
:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:142)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java
:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:248)
at org.apache.cocoon.Cocoon.process
(Cocoon.java:679)
at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)stacktrace[hide]
org.apache.cocoon.ProcessingException: Sitemap: no function nor continuation given in <map:call function>
at <map:call> - file:/C:/Program%20Files/jboss-4.0.3/server/default/./deploy/jbossweb-
tomcat55.sar/ROOT.war/beyarecords/sitemap.xmap:817:66
at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:149)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:68)
at org.apache.cocoon.components.treeprocessor.sitemap.SelectNode.invoke(SelectNode.java:97)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:46)
at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:142)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes
(AbstractParentProcessingNode.java:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process (
ConcreteTreeProcessor.java:234)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process( TreeProcessor.java
:248)
at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:117)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java
:46)
at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java
:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:142)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java
:68)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:248)
at org.apache.cocoon.Cocoon.process
(Cocoon.java:679)
at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
regards
Andrew