Unable to dispaly widget label

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to dispaly widget label

mangvlad
I am trying to supply label for the tab (tabs widget) from the form instance and it seems to be ignoring all xforms tags when I have them inside the widget:label tag.

(Attached is a sample form that demonstrates that)

Syntax error or a bug? :-)

Thanks.

testSimple.xhtml
Reply | Threaded
Open this post in threaded view
|

Re: Unable to dispaly widget label

fl.schmitt(ops-users)
hi mangvlad,

> I am trying to supply label for the tab (tabs widget) from the form instance
> and it seems to be ignoring all xforms tags when I have them inside the
> widget:label tag.

that's true - the tab widget gets "preprocessed" by a xslt stylesheet, the tab
label is created acording to the following rule (omitted the case when the tab
is active):

<!-- Case where this tab is inactive -->
     <xforms:case id="{$tab-id}-inactive">
         <xhtml:div class="widget-tab-inactive">
             <xforms:trigger appearance="xxforms:link" id="{@id}-trigger">
                 <xsl:choose>
                     <xsl:when test="widget:label/@ref">
                         <xforms:label ref="{widget:label/@ref}"/>
                     </xsl:when>
                     <xsl:otherwise>
                     <xforms:label>
                         <xsl:value-of select="widget:label"/>
                     </xforms:label>
                 </xsl:otherwise>
             </xsl:choose>
             <xforms:action ev:event="DOMActivate">
                 <xforms:toggle case="{$tab-id}"/>
                 <xforms:toggle case="{$tab-id}-active"/>
                 <xsl:for-each select="$tabs[@id != $tab-id]">
                     <xforms:toggle case="{@id}-inactive"/>
                 </xsl:for-each>
             </xforms:action>
         </xforms:trigger>
     </xhtml:div>
</xforms:case>

So, with a nested xforms:output inside the widget:label and without a @ref
attribute, since the xforms:output isn't processed yet, there's no textual value
that could be selected by xsl:value-of. Instead, adding a @ref attribute to the
xforms:widget lets the XSLT use the referenced element value:

<widget:tabs width="100%" align="center">
     <widget:tab id="tab1">
         <widget:label ref="/tabs/tab1" />
         <xhtml:p>foo</xhtml:p>
     </widget:tab>
     <widget:tab id="tab2">
         <widget:label ref="/tabs/tab2" />        <xhtml:p>bar</xhtml:p>
     </widget:tab>
     <widget:tab id="tab3">
         <widget:label ref="/tabs/tab3" />
         <!--Just to show that my XPath is correct here, let me display it-->
         <xforms:output ref="/tabs/tab3" />
     </widget:tab>
</widget:tabs>


HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Unable to dispaly widget label

mangvlad
Thank you! I got it.

I have tried to user @ref before but it did not work for me and the reason is that my labels for the tabs are coming from a different model and passing model id as an attribute of the label does not work.

I am not sure how easy would it be to change the XSLT to pass model attribute down, but for now I switched to use xxforms:instance(), instead of using instance() function.


fs(ops-users) wrote
hi mangvlad,

> I am trying to supply label for the tab (tabs widget) from the form instance
> and it seems to be ignoring all xforms tags when I have them inside the
> widget:label tag.

that's true - the tab widget gets "preprocessed" by a xslt stylesheet, the tab
label is created acording to the following rule (omitted the case when the tab
is active):


     <xforms:case id="{$tab-id}-inactive">
         <xhtml:div class="widget-tab-inactive">
             <xforms:trigger appearance="xxforms:link" id="{@id}-trigger">
                 <xsl:choose>
                     <xsl:when test="widget:label/@ref">
                         <xforms:label ref="{widget:label/@ref}"/>
                     </xsl:when>
                     <xsl:otherwise>
                     <xforms:label>
                         <xsl:value-of select="widget:label"/>
                     </xforms:label>
                 </xsl:otherwise>
             </xsl:choose>
             <xforms:action ev:event="DOMActivate">
                 <xforms:toggle case="{$tab-id}"/>
                 <xforms:toggle case="{$tab-id}-active"/>
                 <xsl:for-each select="$tabs[@id != $tab-id]">
                     <xforms:toggle case="{@id}-inactive"/>
                 </xsl:for-each>
             </xforms:action>
         </xforms:trigger>
     </xhtml:div>
</xforms:case>

So, with a nested xforms:output inside the widget:label and without a @ref
attribute, since the xforms:output isn't processed yet, there's no textual value
that could be selected by xsl:value-of. Instead, adding a @ref attribute to the
xforms:widget lets the XSLT use the referenced element value:

<widget:tabs width="100%" align="center">
     <widget:tab id="tab1">
         <widget:label ref="/tabs/tab1" />
         <xhtml:p>foo</xhtml:p>
     </widget:tab>
     <widget:tab id="tab2">
         <widget:label ref="/tabs/tab2" />                                                        <xhtml:p>bar</xhtml:p>
     </widget:tab>
     <widget:tab id="tab3">
         <widget:label ref="/tabs/tab3" />
         
         <xforms:output ref="/tabs/tab3" />
     </widget:tab>
</widget:tabs>


HTH
florian


--
You receive this message as a subscriber of the ops-users@ow2.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
For general help: mailto:sympa@ow2.org?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws