Using relevant attribute with a control group

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

Using relevant attribute with a control group

Dan Godley
Hi all,

I'm having some trouble getting groups of controls to display properly.

Each group of controls is bound to a nodeset which has its relevant attribute set, e.g.

<xf:bind id="bndShowGrp1Inputs" nodeset="instance('inst_display')/showGrp1Inputs" relevant="instance('inst_display')/showGroup = '1'"/>

<xf:bind id="bndShowGrp2Inputs" nodeset="instance('inst_display')/showGrp2Inputs" relevant="instance('inst_display')/showGroup = '2'"/>

......

<xf:group bind="bndShowGrp1Inputs">
  <xf:input bind="bndInput1">
    ...
  </xf:input>
  <xf:input bind="bndInput2">
    ...
  </xf:input>
</xf:group>

<xf:group bind="bndShowGrp2Inputs">
  <xf:input bind="bndInput3">
    ...
  </xf:input>
  <xf:input bind="bndInput4">
    ...
  </xf:input>
</xf:group>

Assuming the value of the node at instance('inst_display')/showGroup is changed to either 1 or 2, I'd expect bndShowGrp1Inputs and bndShowGrp2Inputs to show/hide themselves as appropriate.

Should I be able to do this in Presentation Server?  Apart from when the form initialises, I can't seem to get this to work.  I can get the same code to work in another XForms engine.

Many thanks, Dan




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using relevant attribute with a control group

Alessandro  Vernet
Administrator
On 7/17/06, [hidden email] <[hidden email]> wrote:
> [...]
> Assuming the value of the node at instance('inst_display')/
> showGroup is changed to either 1 or 2, I'd expect bndShowGrp1Inputs
> and bndShowGrp2Inputs to show/hide themselves as appropriate.
>
> Should I be able to do this in Presentation Server?  Apart from
> when the form initialises, I can't seem to get this to work.

Hi Dan,

Yes, this should work just fine, and in fact we have been using
<xforms:group> bound to a node which relevance changes to display/hide
the group in a number of cases. Would you be able to create a
stand-alone XForms file that we can run in the XForms sandbox to
reproduce this?

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

RE: Using relevant attribute with a control group

Dan Godley
In reply to this post by Dan Godley

Hi Alex,

Thanks for your reply.  I did manage to get a simple example of this working in the sandbox.  Not sure what the original problem was, but have attached the working code for info anyway.

Cheers, Dan



###########################################

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events"  xmlns:xf="http://www.w3.org/2002/xforms">
        <head>
                <title>Relevant test</title>
                <xf:model id="mdl_pages">
                        <xf:instance id="inst_page_data">
                                <data xmlns="">
                                        <pages>
                                                <page id="1"/>
                                                <page id="2"/>
                                                <page id="3"/>
                                                <page id="4"/>
                                        </pages>
                                        <currentPage>1</currentPage>
                                        <numPages/>
                                </data>
                        </xf:instance>
                        <xf:bind id="bnd_show_page_1" nodeset="instance('inst_page_data')/pages/page[@id = '1']" relevant="instance('inst_page_data')/currentPage = '1'"/>
                        <xf:bind id="bnd_show_page_2" nodeset="instance('inst_page_data')/pages/page[@id = '2']" relevant="instance('inst_page_data')/currentPage = '2'"/>
                        <xf:bind id="bnd_show_page_3" nodeset="instance('inst_page_data')/pages/page[@id = '3']" relevant="instance('inst_page_data')/currentPage = '3'"/>
                        <xf:bind id="bnd_show_page_4" nodeset="instance('inst_page_data')/pages/page[@id = '4']" relevant="instance('inst_page_data')/currentPage = '4'"/>
                        <xf:bind nodeset="instance('inst_page_data')/numPages" calculate="count(instance('inst_page_data')/pages/page)"/>
                        <xf:bind id="bnd_current_page"  nodeset="instance('inst_page_data')/currentPage" calculate="xfif(number(.) &lt; 1, '1', xfif(number(.) &gt; ../numPages, ../numPages, .))" readonly="false()"/>
                        <!-- ************************************ -->
                        <xf:instance id="inst_button_state">
                                <data xmlns="">
                                        <showPrev/>
                                        <showNext/>
                                </data>
                        </xf:instance>
                        <xf:bind id="bnd_prev" nodeset="instance('inst_button_state')/showPrev" relevant="instance('inst_page_data')/currentPage &gt; 1" />
                        <xf:bind id="bnd_next" nodeset="instance('inst_button_state')/showNext" relevant="instance('inst_page_data')/currentPage &lt; instance('inst_page_data')/numPages"/>
                </xf:model>
        </head>
        <body>
                <xf:group bind="bnd_show_page_1">
                        <h3>Page 1</h3>
                </xf:group>
                <xf:group bind="bnd_show_page_2">
                        <h3>Page 2</h3>
                </xf:group>
                <xf:group bind="bnd_show_page_3">
                        <h3>Page 3</h3>
                </xf:group>
                <xf:group bind="bnd_show_page_4">
                        <h3>Page 4</h3>
                </xf:group>
                <xf:trigger bind="bnd_prev" id="prev">
                        <xf:label>&lt;&lt; Prev</xf:label>
                        <xf:action ev:event="DOMActivate">
                                <xf:setvalue bind="bnd_current_page" value=". - 1" />
                        </xf:action>
                </xf:trigger>
                <xf:trigger bind="bnd_next" id="next">
                        <xf:label>Next >></xf:label>
                        <xf:action ev:event="DOMActivate">
                                <xf:setvalue bind="bnd_current_page" value=". + 1" />
                        </xf:action>
                </xf:trigger>
        </body>
</html>

#################################################################
 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet
Sent: 21 July 2006 04:59
To: [hidden email]
Subject: Re: [ops-users] Using relevant attribute with a control group

On 7/17/06, [hidden email] <[hidden email]> wrote:
> [...]
> Assuming the value of the node at instance('inst_display')/ showGroup
> is changed to either 1 or 2, I'd expect bndShowGrp1Inputs and
> bndShowGrp2Inputs to show/hide themselves as appropriate.
>
> Should I be able to do this in Presentation Server?  Apart from when
> the form initialises, I can't seem to get this to work.

Hi Dan,

Yes, this should work just fine, and in fact we have been using <xforms:group> bound to a node which relevance changes to display/hide the group in a number of cases. Would you be able to create a stand-alone XForms file that we can run in the XForms sandbox to reproduce this?

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws