You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Lundquist <ml...@comcast.net> on 2004/12/14 19:31:23 UTC

[cforms] Matching continuation resources

Hi everyone,

When I first started using CForms, I would write  my <ft:form-template> 
with

	action="{$continuation.id}.continue"

and then match 'em like this:

	<map:match pattern="*.continue">
		<call continuation="{1}" />
	</map:match>

That worked fine, until I had forms served at URIs nested more than one 
level deep in the webapp URI space.  Because the URI in the served form 
page is relative, the request might come back with a path that is 
really "foo/bar/835746597348942.continue", and that doesn't hit in the 
matcher shown above.  "Aha," I thought, "the solution is to make the 
URI absolute" , like this:

	action="/{$continuation.id}.continue"

and in the sitemap:

	<map:match pattern="/*.continue">
		<call continuation="{1}" />
	</map:match>

That worked great.

Until...

Until I mounted a subsitemap that also served forms.  What happens is 
that the continuation resource is matched correctly, but it's matched 
in the context of the root sitemap.  So, when the flowscript does a 
cocoon.sendPage() after the return from showForm(), it's not resolved 
in the context of the subsitemap, and the redirect is really to a 
non-existent resource in the root sitemap.

So it's clear that each subsitemap has to have its own matcher for 
continuations, and the continuation URIs have to be relative.  But that 
puts me back where I started.  I guess I can use two matchers, like 
this:

	<map:match pattern="*.continue">
		<call continuation="{1}" />
	</map:match>
	<map:match pattern="**/*.continue">
  		<call continuation="{2}" />
	</map:match>

But that seems klunky.

If there were some way for the subsitemap to know it's mount point, 
then I could use the (undocumented) form-action parameter to the 
FormsTemplateTransformer, something like this:

	<map:transform type="forms>
		<map:parameter name="form-action" 
value="{mount-uri}/{$continuation.id}.continue" />
	</map:transform>

Acctually, this is not the first time I've wished for a sitemap to be 
able to know it's mount point.  I can't remember why I wanted it 
before, though :-/

Thoughts?

~ml


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


Re: [cforms] Matching continuation resources

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Dec 14, 2004, at 11:13 AM, Jorg Heymans wrote:

> What if you include the continuation as a hidden formfield, and add 
> something like
>
>         <map:match type="request-parameter" pattern="continuation-id">
>           <map:call continuation="{1}"/>
>         </map:match>
>
> to the relevant sitemaps.
>
> That would make your continuation-id always local to the form it was 
> used in no (and thus the sitemap the form was served from) ?
>
> My formtemplates are built like
> <ft:form-template action="" method="POST">
>             <ft:continuation-id/>
> ....
>
> </ft:form-template>
>
> Or am i missing your point?

Hmmm, good idea but I don't think it will work :-)  The problem is with 
the internal redirect invoked by cocoon.sendPage().  This happens in 
the context of the sitemap that matched the continuation request, and 
the only way to control that is with the contents of the request 
(whether that comes as a path component, a GET parameter or a POST 
parameter doesn't make any difference).

Thanks,
Mark


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


Re: [cforms] Matching continuation resources

Posted by Jorg Heymans <jh...@domek.be>.
What if you include the continuation as a hidden formfield, and add 
something like

         <map:match type="request-parameter" pattern="continuation-id">
           <map:call continuation="{1}"/>
         </map:match>

to the relevant sitemaps.

That would make your continuation-id always local to the form it was 
used in no (and thus the sitemap the form was served from) ?

My formtemplates are built like
<ft:form-template action="" method="POST">
             <ft:continuation-id/>
....

</ft:form-template>

Or am i missing your point?


Jorg

Mark Lundquist wrote:
> Hi everyone,
> 
> When I first started using CForms, I would write  my <ft:form-template> 
> with
> 
>     action="{$continuation.id}.continue"
> 
> and then match 'em like this:
> 
>     <map:match pattern="*.continue">
>         <call continuation="{1}" />
>     </map:match>
> 
> That worked fine, until I had forms served at URIs nested more than one 
> level deep in the webapp URI space.  Because the URI in the served form 
> page is relative, the request might come back with a path that is really 
> "foo/bar/835746597348942.continue", and that doesn't hit in the matcher 
> shown above.  "Aha," I thought, "the solution is to make the URI 
> absolute" , like this:
> 
>     action="/{$continuation.id}.continue"
> 
> and in the sitemap:
> 
>     <map:match pattern="/*.continue">
>         <call continuation="{1}" />
>     </map:match>
> 
> That worked great.
> 
> Until...
> 
> Until I mounted a subsitemap that also served forms.  What happens is 
> that the continuation resource is matched correctly, but it's matched in 
> the context of the root sitemap.  So, when the flowscript does a 
> cocoon.sendPage() after the return from showForm(), it's not resolved in 
> the context of the subsitemap, and the redirect is really to a 
> non-existent resource in the root sitemap.
> 
> So it's clear that each subsitemap has to have its own matcher for 
> continuations, and the continuation URIs have to be relative.  But that 
> puts me back where I started.  I guess I can use two matchers, like this:
> 
>     <map:match pattern="*.continue">
>         <call continuation="{1}" />
>     </map:match>
>     <map:match pattern="**/*.continue">
>          <call continuation="{2}" />
>     </map:match>
> 
> But that seems klunky.
> 
> If there were some way for the subsitemap to know it's mount point, then 
> I could use the (undocumented) form-action parameter to the 
> FormsTemplateTransformer, something like this:
> 
>     <map:transform type="forms>
>         <map:parameter name="form-action" 
> value="{mount-uri}/{$continuation.id}.continue" />
>     </map:transform>
> 
> Acctually, this is not the first time I've wished for a sitemap to be 
> able to know it's mount point.  I can't remember why I wanted it before, 
> though :-/
> 
> Thoughts?
> 
> ~ml


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