You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jon Evans <jo...@misgl.com> on 2004/03/24 17:40:41 UTC
CForms in a coplet
Hi,
For any form to work properly in a CachingURICoplet, you need to
transform the coplet through the HTMLEventLinkTransformer, to convert
the action parameter of the form tag to an event.
For this to work with cocoon forms, you need to have first transformed
using forms-samples-styling.xsl or equivalent, to convert the cforms
markup to an actual HTML form.
This works fine.
One of the other things that cforms does is create javascript alert
links, e.g. alert("This field is required"). Unfortunately the
HTMLEventLinkTransformer wipes out these anchor tags, and replaces them
with <a href="some-useless-event"...
I can see two ways around this.
1) Split out the forms-samples-styling.xsl stuff, so that it is done in
two stages so we can insert an HTMLEventLinkTransformer stage in the
middle:
<map:transform src="cforms-pre-styling.xsl"/>
<!-- now we have the form element etc. in place -->
<map:transform type="portal-html-eventlink"/>
<map:transform src="cforms-post-styling.xsl"/>
<!-- now we have other elements, like forms-validation-messaage links
-->
2) Modify HTMLEventLinkTransformer so that it ignores certain anchor
link classes:
<map:transform type="portal-html-eventlink">
<map:parameter name="ignore-link-classes"
value="forms-validation-message"/>
</map:transform>
(the popup links have their own class, forms-validation-message).
I can code up either solution - I need it anyway for my own code. What
do you think? Or is there another way?
Jon
Re: CForms in a coplet, PATCH
Posted by Christian Mayrhuber <cm...@iicm.edu>.
On Thursday 25 March 2004 15:23, Jon Evans wrote:
> Hi Christian,
>
> On 25 Mar 2004, at 12:05, Christian Mayrhuber wrote:
> > See BUG: 27904
> > I've a fix for it.
>
> It should be easy to combine my patch with yours.
>
> I'm could rename
>
> + /** Remembers if the current element is a remote anchor */
> + protected Stack areRemoteAnchors;
>
> to something like
>
> + /** Remembers if the current element is being transformed */
> + protected Stack beingTransformed;
>
> so it can work with both anchors and "anchor classes to ignore".
>
> But, having said that, your patch on its own fixes my problem, because
> all of the problematic links produced by cforms have href="#".
>
> Carsten?
Great.
I haven't noticed your patch, because the list didn't work
for me until I tried again today.
Please do as you desire.
--
lg, Chris
RE: CForms in a coplet, PATCH
Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Jon Evans wrote:
>
> Hi Christian,
>
> On 25 Mar 2004, at 12:05, Christian Mayrhuber wrote:
>
> > See BUG: 27904
> > I've a fix for it.
>
> It should be easy to combine my patch with yours.
>
> I'm could rename
>
> + /** Remembers if the current element is a remote anchor */
> + protected Stack areRemoteAnchors;
>
> to something like
>
> + /** Remembers if the current element is being transformed */
> + protected Stack beingTransformed;
>
> so it can work with both anchors and "anchor classes to ignore".
>
> But, having said that, your patch on its own fixes my
> problem, because all of the problematic links produced by
> cforms have href="#".
>
I will apply Christians patch. If someone/you need more functionality
(like filtering against classes etc) we can integrate it when needed.
Thanks
Carsten
Re: CForms in a coplet, PATCH
Posted by Jon Evans <jo...@misgl.com>.
Hi Christian,
On 25 Mar 2004, at 12:05, Christian Mayrhuber wrote:
> See BUG: 27904
> I've a fix for it.
It should be easy to combine my patch with yours.
I'm could rename
+ /** Remembers if the current element is a remote anchor */
+ protected Stack areRemoteAnchors;
to something like
+ /** Remembers if the current element is being transformed */
+ protected Stack beingTransformed;
so it can work with both anchors and "anchor classes to ignore".
But, having said that, your patch on its own fixes my problem, because
all of the problematic links produced by cforms have href="#".
Carsten?
Jon
Re: CForms in a coplet, PATCH
Posted by Christian Mayrhuber <cm...@iicm.edu>.
On Thursday 25 March 2004 12:31, Carsten Ziegeler wrote:
> Jon Evans wrote:
> > I had another thought, the bogus links have href="#". Is it
> > worth also coding a specific workaround to prevent it from
> > touching links with href="#"?
>
> Hmm, don't know. If the browser does not send a new request to
> resolve the anchor, yes those links should not be encoded.
>
> Carsten
See BUG: 27904
I've a fix for it.
--
lg, Chris
RE: CForms in a coplet
Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Jon Evans wrote:
> I had another thought, the bogus links have href="#". Is it
> worth also coding a specific workaround to prevent it from
> touching links with href="#"?
>
Hmm, don't know. If the browser does not send a new request to
resolve the anchor, yes those links should not be encoded.
Carsten
Re: CForms in a coplet
Posted by Jon Evans <jo...@misgl.com>.
Hi,
On 25 Mar 2004, at 08:45, Carsten Ziegeler wrote:
> Jon Evans wrote:
> > 2) Modify HTMLEventLinkTransformer so that it ignores certain
> > anchor link classes:
> >
> > <map:transform type="portal-html-eventlink">
> > <map:parameter name="ignore-link-classes"
> > value="forms-validation-message"/>
> > </map:transform>
> >
> > (the popup links have their own class, forms-validation-message).
> >
> > I can code up either solution - I need it anyway for my own
> > code. What do you think? Or is there another way?
> >
> I think 2) makes sense. Do you plan to make the parameter container
> several
> values (comma separated)? That would be great!
>
> Waiting for the patch :)
Comma separated should be easy, with String.split(). I'll start
working on it now.
I had another thought, the bogus links have href="#". Is it worth also
coding a specific workaround to prevent it from touching links with
href="#"?
Jon
RE: CForms in a coplet
Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Jon Evans wrote:
> I can see two ways around this.
>
> 1) Split out the forms-samples-styling.xsl stuff, so that it
> is done in two stages so we can insert an
> HTMLEventLinkTransformer stage in the
> middle:
>
> <map:transform src="cforms-pre-styling.xsl"/>
> <!-- now we have the form element etc. in place -->
> <map:transform type="portal-html-eventlink"/> <map:transform
> src="cforms-post-styling.xsl"/>
> <!-- now we have other elements, like forms-validation-messaage links
> -->
>
>
> 2) Modify HTMLEventLinkTransformer so that it ignores certain
> anchor link classes:
>
> <map:transform type="portal-html-eventlink">
> <map:parameter name="ignore-link-classes"
> value="forms-validation-message"/>
> </map:transform>
>
> (the popup links have their own class, forms-validation-message).
>
> I can code up either solution - I need it anyway for my own
> code. What do you think? Or is there another way?
>
I think 2) makes sense. Do you plan to make the parameter container several
values (comma separated)? That would be great!
Waiting for the patch :)
Carsten