You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Remmerie Bart <Ba...@elia.be> on 2004/07/08 10:42:16 UTC
[cforms] field-styling Hyperlink
Dear all,
I've managed to create a hyperlink styling as follows:
Adding the following code to forms-field-styling.xsl
<xsl:template match="fi:field[fi:styling/@type='myLink']" priority="2">
<a name="{@id}" id="{@id}">
<xsl:attribute name="href">showDetail/
<xsl:value-of select="fi:value"/>
</xsl:attribute>
<xsl:value-of select="fi:value"/>
</a>
</xsl:template>
I can use the following snippet in my template
<ft:widget id="name">
<fi:styling type="myLink"/>
</ft:widget>
My question is the following:
I also have a widget containing the unique ID of each repeater row, and I
would prefer to go to showDetail/[value of the unique ID] and not
showDetail/[value of the name].
Is there a way to load the value of another widget into the styling of an
actual widget ?
Something like the code below, but working! (the one below is not working)
Or is this something that can only be done from flowscript ?
And, how can this be done from flowscript ?
<xsl:template match="fi:field[fi:styling/@type='myLink']" priority="2">
<a name="{@id}" id="{@id}">
<xsl:attribute name="href">showDetail/
<xsl:value-of select="./fi:field[@id='id']/fi:value"/>
</xsl:attribute>
<xsl:value-of select="fi:value"/>
</a>
</xsl:template>
Thanks all,
Bart
This message and its attachments may contain confidential information protected by intellectual property rights or other rights & is strictly for the exclusive use of the intended recipient. It is strictly prohibited to copy, alter or disclose this message or its contents to any other person without Elia's prior consent. If you are not the intended recipient of this message, please inform the person who sent it and delete the message from your system. Elia is not liable for any direct or indirect damage arising from errors, inaccuracies or any loss in the message, from unauthorized use, disclosure, copying or alteration of it or as a result of any virus being passed on. This message does not constitute any commitment from Elia except when expressly otherwise agreed between the intended recipient and Elia.
U vindt de Nederlandse versie van deze disclaimer op onze internetsite www.elia.be
Vous pouvez découvrir la version française de ce disclaimer sur notre site internet www.elia.be
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [cforms] field-styling Hyperlink
Posted by Marc Portier <mp...@outerthought.org>.
Bart,
wouldn't you just want to make this an action instead, and have the
click thus submit the form and trigger the flow-logic accordingly?
in case you don't however lets take a stab at it...
IIUC, (and putting it somewhat more general) you have something like:
fd:repeater id="rep"
+ fd:field id="key"
+ fd:field id="value"
and would like to include this in the template with some
ft:repeater-widget
+ ft:widget id="value"
+ fi:styling type="href" linkid="key"
the main observation to make is that the actual 'id's you will be
matching in the xslt are _not_ those fd:field/@id's you see above as
'key' and 'value',
at the time your xslt comes into play we'll be seeing fi:field's with
assmebled id's of the kind rep.[row-number].key and rep.[row-number].value:
fi:repeater-widget
+ fi:field id="rep.0.key"
+ fi:field id="rep.0.value"
+ fi:styling type="href" linkid="key"
+ fi:field id="rep.1.key"
+ fi:field id="rep.1.value"
+ fi:styling type="href" linkid="key"
+ fi:field id="rep.2.key"
+ fi:field id="rep.2.value"
+ fi:styling type="href" linkid="key"
etc etc
actually, what you try to do calls for an enhancement request
(bugzilla?) to be having access to something like
+ fi:field id="rep.N.key" namespace="rep.N" localname="key"
+ fi:field id="rep.N.value" namespace="rep.N" localname="value"
+ fi:styling type="href" linkid="key"
without those new @namespace and @localname attributes however you're
condemned to some string-manipulating xslt to get that info from the @id:
<xsl:template name="splitter">
<xsl:param name="running-id" />
<xsl:param name="running-ns" />
<xsl:param name="mode" />
<xsl:variable name="endPart"
select="substring-after($running-id, '.')" />
<xsl:variable name="startPart"
select="substring-before($running-id, '.')" />
<xsl:choose>
<xsl:when test="$endPart = ''">
<xsl:choose>
<xsl:when test="$mode = 'ns-part'"><xsl:value-of
select="substring-after($running-ns,'.')" /></xsl:when>
<xsl:otherwise><xsl:value-of
select="$running-id" /></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:call-template name="splitter">
<xsl:with-param name="running-id" select="$endPart" />
<xsl:with-param name="running-ns"
select="concat($running-ns, '.', $startPart)" />
<xsl:with-param name="mode" select="$mode" />
</xsl:call-template></xsl:otherwise>
</xsl:choose>
</xsl:template>
and that you could then use from some template looking like this:
<!-- warning: untested code below -->
<xsl:template match="fi:field[fi:styling/@type='href']" >
<xsl:variable name="namespace"><xsl:call-template name="splitter">
<xsl:with-param name="running-id" select="@id" />
<xsl:with-param name="mode" select="'ns-part'" />
</xsl:call-template></xsl:variable>
<xsl:variable name="id"
select="concat($namespace, '.', fi:styling/@linkid)" />
<xsl:variable name="id_val"
select="../fi:field[@id=$id]/fi:value/text()" />
<a name="{@id}" id="{@id}" href="showDetail{$id_val}">
<xsl:value-of select="fi:value"/>
</a>
</xsl:template>
HTH,
-marc=
Remmerie Bart wrote:
> Dear all,
>
> I've managed to create a hyperlink styling as follows:
>
> Adding the following code to forms-field-styling.xsl
>
> <xsl:template match="fi:field[fi:styling/@type='myLink']" priority="2">
> <a name="{@id}" id="{@id}">
> <xsl:attribute name="href">showDetail/
> <xsl:value-of select="fi:value"/>
> </xsl:attribute>
> <xsl:value-of select="fi:value"/>
> </a>
> </xsl:template>
>
> I can use the following snippet in my template
> <ft:widget id="name">
> <fi:styling type="myLink"/>
> </ft:widget>
>
> My question is the following:
> I also have a widget containing the unique ID of each repeater row, and I
> would prefer to go to showDetail/[value of the unique ID] and not
> showDetail/[value of the name].
>
> Is there a way to load the value of another widget into the styling of an
> actual widget ?
> Something like the code below, but working! (the one below is not working)
> Or is this something that can only be done from flowscript ?
> And, how can this be done from flowscript ?
>
>
> <xsl:template match="fi:field[fi:styling/@type='myLink']" priority="2">
> <a name="{@id}" id="{@id}">
> <xsl:attribute name="href">showDetail/
> <xsl:value-of select="./fi:field[@id='id']/fi:value"/>
> </xsl:attribute>
> <xsl:value-of select="fi:value"/>
> </a>
> </xsl:template>
>
>
> Thanks all,
> Bart
>
>
>
>
>
> This message and its attachments may contain confidential information protected by intellectual property rights or other rights & is strictly for the exclusive use of the intended recipient. It is strictly prohibited to copy, alter or disclose this message or its contents to any other person without Elia's prior consent. If you are not the intended recipient of this message, please inform the person who sent it and delete the message from your system. Elia is not liable for any direct or indirect damage arising from errors, inaccuracies or any loss in the message, from unauthorized use, disclosure, copying or alteration of it or as a result of any virus being passed on. This message does not constitute any commitment from Elia except when expressly otherwise agreed between the intended recipient and Elia.
>
> U vindt de Nederlandse versie van deze disclaimer op onze internetsite www.elia.be
>
> Vous pouvez découvrir la version française de ce disclaimer sur notre site internet www.elia.be
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo@outerthought.org mpo@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org