You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Michael Lucas-Smith <mi...@wizardis.com.au> on 2003/12/22 02:05:07 UTC

Flowscript and POST's

Hi,

I'm new to this crowd and I'm no Cocoon expert.
I've just started to play with the flowscript part of Cocoon and have
found it very interesting.

I've got an immediate use I can put it to in one of my company's
projects, but my lack of understanding has left me with a problem.

I have a situation where Cocoon is the web front end to a backend
system. Cocoon requests XML from the backend system.
I have some XSLT that outputs input forms against the XML's original
data and allows the user to POST in changes to the document.

I'd like to use flowscript to switch which page the user sees
depending on the success/failure of the backend operation.

Thus far I have:

<match pattern="**/*.form">
       <call function="submit">
             <parameter name="actionurl"
             value="resource/{1}/{2}.server"/>
             <parameter name="success" value="success.html"/>
             <parameter name="failure" value="../{1}/{2}.html"/>
       </call>
</match>

function submit() {
         var result = new Packages.java.io.byteArrayOutputStream();
         cocoon.processPipelineTo(cocoon.parameters.actionurl, {},
         result);
         result = result.toString();
         cocoon.redirectTo(cocoon.paramters.failure);
}

The POST goes to the .form match which then calls the flowscript.
Unfortunately, there doesn't appear to be an obvious way to POST on
this POST to the backend pipeline, which I was hoping to do using
processPipelineTo with my actionurl parameter.

Has any one got any idea how I can 'push' that POST on to my backend
easily?

-- 

Michael Lucas-Smith
Research and Development
Wizard Information Services, Australia



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[4]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
I have that working now. Thanks, it works very well!

Cheers,
Michael.

GC> With the latest CVS you can do something like:

GC> var util =
GC> cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipe
GC> lineUtil);
GC> var doc = util.processToDOM(cocoon.parameters.actionurl, {});
GC> var result  =
GC> Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOf(doc,
GC> XPathExpression, "default");



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[4]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
>> The ?? is the question. The result I'm getting back from that process
>> is XML. What is the easiest way to then parse that XML and act on its
>> contents inside the flowscript?

GC> With the latest CVS you can do something like:

GC> var util =
GC> cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipe
GC> lineUtil);
GC> var doc = util.processToDOM(cocoon.parameters.actionurl, {});
GC> var result  =
GC> Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOf(doc,
GC> XPathExpression, "default");

Nice. I'll grab the latest CVS and give it a go.

Cheers,
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Wrong .class files (was: Flowscript and POST's)

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
Monday, December 29, 2003, 10:23:26 AM, you wrote:

MLS> I believe I'm missing something very very obvious with the build.

Very obvious indeed. I was hitting the wrong URL!!

Back to trying out the new FOM functions now.. :)

Cheers,
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Wrong .class files (was: Flowscript and POST's)

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
Monday, December 29, 2003, 9:59:18 AM, you wrote:

I believe I'm missing something very very obvious with the build.

After running ./build.sh, the build/ directory contains a
cocoon-2.1.4-dev directory. I moved this directory out of the build
directory and started up again and everything continued to run.

This indicates that those class files were not being used, even though
COCOON_HOME is set to the directory that has the build directory in
it.

What step am I missing to have Cocoon use the correct, newly built
.class files?

Cheers,
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[2]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
Monday, December 29, 2003, 9:49:15 AM, you wrote:

Cheers Chris,

The default was set to JavaScript, but the actual flow entry was using
javascript, so that appears not to be my problem.

<map:flow language="javascript">
          <map:script src="flow/wizdom.js"/>
</map:flow>

I changed my default to javascript just in case, but it didn't resolve
the issue.

Cheers,
Michael.

CO> You're using the wrong flow interpreter. The correct one is "javascript"
CO> not "JavaScript". The latter is obsolete and not supported (and should
CO> be removed).



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Flowscript and POST's

Posted by Christopher Oliver <re...@verizon.net>.
You're using the wrong flow interpreter. The correct one is "javascript" 
not "JavaScript". The latter is obsolete and not supported (and should 
be removed).

Regards,

Chris

Michael Lucas-Smith wrote:

>Thursday, December 25, 2003, 11:26:44 PM, you wrote:
>
>
>GC> Michael Lucas-Smith wrote:
>  
>
>>>I grabbed 2003/12/23, 23:12:58 cvs snapshot of 2.1.4-dev, but I got
>>>the error that createObject is not a function. Is there a newer
>>>version I need to get?
>>>      
>>>
>
>GC> No, that should do.
>GC> Check if your
>GC> org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon contains a
>GC> jsFunction_createObject Method and do a clean build.
>
>I checked the source and it definitely contains
>jsFunction_createObject. So I wiped the build directory and ran
>build.sh again, checked for any FOM*class files and found only the new
>ones recently made from the build, started it up and it crashed again
>in the same fashion.
>
>I'm starting to wonder if it's to do with the flow interpreter I'm
>using?
>
><map:components>
>                <map:flow-interpreters default="JavaScript"/>
></map:components>
>
>That's what I'm using. Is there any more required to get Cocoon to use
>this new behaviour?
>
>Cheers,
>Michael.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[6]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
Thursday, December 25, 2003, 11:26:44 PM, you wrote:


GC> Michael Lucas-Smith wrote:
>> I grabbed 2003/12/23, 23:12:58 cvs snapshot of 2.1.4-dev, but I got
>> the error that createObject is not a function. Is there a newer
>> version I need to get?

GC> No, that should do.
GC> Check if your
GC> org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon contains a
GC> jsFunction_createObject Method and do a clean build.

I checked the source and it definitely contains
jsFunction_createObject. So I wiped the build directory and ran
build.sh again, checked for any FOM*class files and found only the new
ones recently made from the build, started it up and it crashed again
in the same fashion.

I'm starting to wonder if it's to do with the flow interpreter I'm
using?

<map:components>
                <map:flow-interpreters default="JavaScript"/>
</map:components>

That's what I'm using. Is there any more required to get Cocoon to use
this new behaviour?

Cheers,
Michael.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Re[4]: Flowscript and POST's

Posted by Guido Casper <gc...@s-und-n.de>.
Michael Lucas-Smith wrote:
> I grabbed 2003/12/23, 23:12:58 cvs snapshot of 2.1.4-dev, but I got
> the error that createObject is not a function. Is there a newer
> version I need to get?

No, that should do.
Check if your
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon contains a
jsFunction_createObject Method and do a clean build.

Guido

>
> Cheers,
> Michael
>
>> With the latest CVS you can do something like:
>
>> var util =
>>
cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipe
>> lineUtil);
>> var doc = util.processToDOM(cocoon.parameters.actionurl, {});
>> var result  =
>> Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOf(doc,
>> XPathExpression, "default");
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[4]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
I grabbed 2003/12/23, 23:12:58 cvs snapshot of 2.1.4-dev, but I got
the error that createObject is not a function. Is there a newer
version I need to get?

Cheers,
Michael

GC> With the latest CVS you can do something like:

GC> var util =
GC> cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipe
GC> lineUtil);
GC> var doc = util.processToDOM(cocoon.parameters.actionurl, {});
GC> var result  =
GC> Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOf(doc,
GC> XPathExpression, "default");



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Re[2]: Flowscript and POST's

Posted by Guido Casper <gc...@s-und-n.de>.
Michael Lucas-Smith wrote:
> I now have the response coming back in the flowscript:
>
> function submit() {
>          var result = new Packages.java.io.ByteArrayOutputStream();
>          cocoon.processPipelineTo(cocoonparameters.actionurl, {},
>          result);
>          result = result.toString();
>          if (??)
>             cocoon.redirectTo(cocoon.parameters.success);
>          else
>              cocoon.redirectTo(cocoon.paramters.failure);
> }
>
> In the future I'll probably start using continuations and use
> sendPageAndWait, but for now I'm using redirectTo.
>
> The ?? is the question. The result I'm getting back from that process
> is XML. What is the easiest way to then parse that XML and act on its
> contents inside the flowscript?

With the latest CVS you can do something like:

var util =
cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipe
lineUtil);
var doc = util.processToDOM(cocoon.parameters.actionurl, {});
var result  = Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOf(doc,
XPathExpression, "default");

HTH
Guido


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[2]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
TC> Hello,

TC> I missed this thread due to email issues, but I'd like to jump in here a
TC> second if I may:

TC> When you say "parameters" do you mean URL parameters,

TC> e.g.: index.html?a=foo&b=bar

TC> as opposed to putting the request parameters in the body of the POST?

Correct. Although even if you have both they should end up in the body
if the wsproxy-method is set to POST.

TC> Be aware the WebServiceProxyGenerator may eventually be deprecated, and
TC> there are other generators in the "proxy" block.

What will replace it? I w as a little surprised that the request's
information was passed through the flow pipeline to the
processPipelineTo and then to the backend pipeline. It shows
exceptional design and forethought.

TC> Parameter handling in the WSProxy has always been a little goofy, 
TC> because of the need to combine parameters which were POSTed along with
TC> parameters defined on the src attribute of the generator, such as:

TC> <map:generate type="wsproxy" 
TC> src="http://example.com/servlet/Whatever?foo=bar"/>

TC> The foo=bar key/value pair needs to be merged with any parameters that
TC> were sent to the proxy as POST or GET originally.

Yep. I'm taking advantage of that.

TC> The WSProxy defaults to GET.  If you need a POST, use it like this:

TC> <map:generate type="wsproxy" src="http://foo">
TC>    <map:parameter name="wsproxy-method" value="post"/>
TC> </map:generate>

TC> The value=POST can be any case, so post or PoSt or POST works.  You can
TC> also explicitly set it to GET, which doesn't do much except for be a
TC> little more verbose in the sitemap.

Yes. I've set the wsproxy-method to post, which is why I assumed it
would put the parameters in to the body, not the header.

TC> Any more questions, just ask.

I do have a question that is related, but away from the wsproxy side
of things.

I now have the response coming back in the flowscript:

function submit() {
         var result = new Packages.java.io.ByteArrayOutputStream();
         cocoon.processPipelineTo(cocoonparameters.actionurl, {},
         result);
         result = result.toString();
         if (??)
            cocoon.redirectTo(cocoon.parameters.success);
         else
             cocoon.redirectTo(cocoon.paramters.failure);
}

In the future I'll probably start using continuations and use
sendPageAndWait, but for now I'm using redirectTo.

The ?? is the question. The result I'm getting back from that process
is XML. What is the easiest way to then parse that XML and act on its
contents inside the flowscript?

My initial thoughts are that there should be a way to generate
flowscript by pumping that result through an xslt transformer.. but
perhaps it is easier to use DOM objects in some fashion? Are the
Javascript DOM objects available, or would the Java ones be required?
And then, how do I test on it?

TC> Regards,

TC> Tony


TC> ---------------------------------------------------------------------
TC> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
TC> For additional commands, e-mail: users-help@cocoon.apache.org



-- 

Michael Lucas-Smith
Research and Development
Wizard Information Services, Australia

"We don't have to test anything if we don't want it to work"


Wizard Information Services
15 Barry Dr
Canberra, Australia

Extension: 972
Phone: (612) 6275 0750


IMPORTANT-
  The contents of this email and its attachments may be confidential and/or legally privileged.  Any unauthorized use of the contents is expressly prohibited.  If you receive this email in error, please contact the sender, then delete the email.  If you are not the intended recipient (or responsible for the delivery of the message to such person), you may not copy or deliver this message to anyone.  The reproduction or dissemination of this email or its attachments is prohibited without the consent of the sender.

  Prior to opening or using the attachments, check them for viruses and defects.
  The content of this email and its attachments may become altered in transmission.  Please notify us of any problems with the transmission.
  Our liability is limited to re-sending the email and any attachments.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Flowscript and POST's

Posted by Tony Collen <co...@umn.edu>.
Michael Lucas-Smith wrote:

>>>I assume this is a bug in the wsproxy generator, as I've told the
>>>wsproxy generator to use a wsproxy-method of POST - which it does, but
>>>then proceeds to use parameters instead of body content.
>>> 
>>>
> 
> U> The WSProxyGenerator uses a HTTPClient that is capable of posting XML as
> U> the entire post body. However, it doesn't (AFAIK) pass this 
> U> functionality on to the Cocoon user. If you are able to make it do so, I
> U> think it would be a useful, and potentially quite simple, patch. Are you
> U> willing/able to have a go?
> 
> I'm afraid not at the moment. My java knowledge is sketchy at best and
> I'm very swamped with billable work.
> 
> Thanks for clarifying wsproxy generator's behaviour.


Hello,

I missed this thread due to email issues, but I'd like to jump in here a 
second if I may:

When you say "parameters" do you mean URL parameters,

e.g.: index.html?a=foo&b=bar

as opposed to putting the request parameters in the body of the POST?

Be aware the WebServiceProxyGenerator may eventually be deprecated, and 
there are other generators in the "proxy" block.

Parameter handling in the WSProxy has always been a little goofy, 
because of the need to combine parameters which were POSTed along with 
parameters defined on the src attribute of the generator, such as:

<map:generate type="wsproxy" 
src="http://example.com/servlet/Whatever?foo=bar"/>

The foo=bar key/value pair needs to be merged with any parameters that 
were sent to the proxy as POST or GET originally.

The WSProxy defaults to GET.  If you need a POST, use it like this:

<map:generate type="wsproxy" src="http://foo">
   <map:parameter name="wsproxy-method" value="post"/>
</map:generate>

The value=POST can be any case, so post or PoSt or POST works.  You can 
also explicitly set it to GET, which doesn't do much except for be a 
little more verbose in the sitemap.

Any more questions, just ask.

Regards,

Tony


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re[2]: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
>>
>>I assume this is a bug in the wsproxy generator, as I've told the
>>wsproxy generator to use a wsproxy-method of POST - which it does, but
>>then proceeds to use parameters instead of body content.
>>  
>>
U> The WSProxyGenerator uses a HTTPClient that is capable of posting XML as
U> the entire post body. However, it doesn't (AFAIK) pass this 
U> functionality on to the Cocoon user. If you are able to make it do so, I
U> think it would be a useful, and potentially quite simple, patch. Are you
U> willing/able to have a go?

I'm afraid not at the moment. My java knowledge is sketchy at best and
I'm very swamped with billable work.

Thanks for clarifying wsproxy generator's behaviour.

Cheers,
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Flowscript and POST's

Posted by Upayavira <uv...@upaya.co.uk>.
Michael Lucas-Smith wrote:

>Monday, December 22, 2003, 12:05:07 PM, you wrote:
>
>I've dug a little deeper. I've made my backend match use the wsproxy
>generator and now it almost 'just works'.
>
>When I say 'just works', the values in the POST have been sent to the
>backend, without anything special required, but the values of the POST
>have been sent as parameters!
>
>I assume this is a bug in the wsproxy generator, as I've told the
>wsproxy generator to use a wsproxy-method of POST - which it does, but
>then proceeds to use parameters instead of body content.
>  
>
The WSProxyGenerator uses a HTTPClient that is capable of posting XML as 
the entire post body. However, it doesn't (AFAIK) pass this 
functionality on to the Cocoon user. If you are able to make it do so, I 
think it would be a useful, and potentially quite simple, patch. Are you 
willing/able to have a go?

Regards, Upayavira

>Apart from this slight problem, which may not ever be a problem,
>things are back on track.
>
>Cheers,
>Michael
>
>MLS> Hi,
>
>MLS> I'm new to this crowd and I'm no Cocoon expert.
>MLS> I've just started to play with the flowscript part of Cocoon and have
>MLS> found it very interesting.
>
>MLS> I've got an immediate use I can put it to in one of my company's
>MLS> projects, but my lack of understanding has left me with a problem.
>
>MLS> I have a situation where Cocoon is the web front end to a backend
>MLS> system. Cocoon requests XML from the backend system.
>MLS> I have some XSLT that outputs input forms against the XML's original
>MLS> data and allows the user to POST in changes to the document.
>
>MLS> I'd like to use flowscript to switch which page the user sees
>MLS> depending on the success/failure of the backend operation.
>
>MLS> Thus far I have:
>
>MLS> <match pattern="**/*.form">
>MLS>        <call function="submit">
>MLS>              <parameter name="actionurl"
>MLS>              value="resource/{1}/{2}.server"/>
>MLS>              <parameter name="success" value="success.html"/>
>MLS>              <parameter name="failure" value="../{1}/{2}.html"/>
>MLS>        </call>
>MLS> </match>
>
>MLS> function submit() {
>MLS>          var result = new
>MLS> Packages.java.io.byteArrayOutputStream();
>MLS>         
>MLS> cocoon.processPipelineTo(cocoon.parameters.actionurl, {},
>MLS>          result);
>MLS>          result = result.toString();
>MLS>          cocoon.redirectTo(cocoon.paramters.failure);
>MLS> }
>
>MLS> The POST goes to the .form match which then calls the flowscript.
>MLS> Unfortunately, there doesn't appear to be an obvious way to POST on
>MLS> this POST to the backend pipeline, which I was hoping to do using
>MLS> processPipelineTo with my actionurl parameter.
>
>MLS> Has any one got any idea how I can 'push' that POST on to my backend
>MLS> easily?
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Flowscript and POST's

Posted by Michael Lucas-Smith <mi...@wizardis.com.au>.
Monday, December 22, 2003, 12:05:07 PM, you wrote:

I've dug a little deeper. I've made my backend match use the wsproxy
generator and now it almost 'just works'.

When I say 'just works', the values in the POST have been sent to the
backend, without anything special required, but the values of the POST
have been sent as parameters!

I assume this is a bug in the wsproxy generator, as I've told the
wsproxy generator to use a wsproxy-method of POST - which it does, but
then proceeds to use parameters instead of body content.

Apart from this slight problem, which may not ever be a problem,
things are back on track.

Cheers,
Michael

MLS> Hi,

MLS> I'm new to this crowd and I'm no Cocoon expert.
MLS> I've just started to play with the flowscript part of Cocoon and have
MLS> found it very interesting.

MLS> I've got an immediate use I can put it to in one of my company's
MLS> projects, but my lack of understanding has left me with a problem.

MLS> I have a situation where Cocoon is the web front end to a backend
MLS> system. Cocoon requests XML from the backend system.
MLS> I have some XSLT that outputs input forms against the XML's original
MLS> data and allows the user to POST in changes to the document.

MLS> I'd like to use flowscript to switch which page the user sees
MLS> depending on the success/failure of the backend operation.

MLS> Thus far I have:

MLS> <match pattern="**/*.form">
MLS>        <call function="submit">
MLS>              <parameter name="actionurl"
MLS>              value="resource/{1}/{2}.server"/>
MLS>              <parameter name="success" value="success.html"/>
MLS>              <parameter name="failure" value="../{1}/{2}.html"/>
MLS>        </call>
MLS> </match>

MLS> function submit() {
MLS>          var result = new
MLS> Packages.java.io.byteArrayOutputStream();
MLS>         
MLS> cocoon.processPipelineTo(cocoon.parameters.actionurl, {},
MLS>          result);
MLS>          result = result.toString();
MLS>          cocoon.redirectTo(cocoon.paramters.failure);
MLS> }

MLS> The POST goes to the .form match which then calls the flowscript.
MLS> Unfortunately, there doesn't appear to be an obvious way to POST on
MLS> this POST to the backend pipeline, which I was hoping to do using
MLS> processPipelineTo with my actionurl parameter.

MLS> Has any one got any idea how I can 'push' that POST on to my backend
MLS> easily?




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org