Thread: [Xsltforms-support] stepping through recordset type data display
Brought to you by:
alain-couthures
|
From: Stephen C. <Ste...@ut...> - 2010-01-05 05:32:15
|
Hello, I have a specific problem where I wish to select a record from a xf:select1 list and then on on the basis of the selected value display a full record below it. The full record will be displayed with the use of a xf:group tag, so I am a really wanting to dynamically change the node the group references via its 'ref 'or 'bind' attribute. I cannot get this to work, but I cannot find an example where someone has done this to know that it should work. Effectively the behaviour that I want to replicate can be seen in an (non-Xform) example here http://xmljs.sourceforge.net/contributedAdd-ons/xpath/sampleApplications/contactManager/contactManager.html. This just steps through a xml 'recordset' displaying each record in turn. I'd be interested to see this done in an XSLTForms example! My Xform code is as follows: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="forms/xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:aatams="http://www.imos.org.au/aatams" xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" wfs:dummy="dummy" gml:dummy="dummy" aatams:dummy="dummy"> <head> <title>PRINT RECOVERY WORKSHEET</title> <link href="forms/aatams.css" rel="stylesheet" type="text/css" /> <xf:model id="model1"> <!-- get the relevant deployments --> <xf:instance id="inst_installations" src="../deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&namespace=xmlns(aatams=http://www.imos.org.au/aatams)&typename=aatams:installation" /> <xf:instance id="inst_installation_deployments" src="../deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&namespace=xmlns(aatams=http://www.imos.org.au/aatams)&typename=aatams:installation_deployment" /> <xf:instance id="inst_selected"> <data> <installation_fid /> <deployment_fid /> </data> </xf:instance> <xf:bind id="selected_installation_fid" nodeset="instance('inst_selected')/installation_fid" type="xsd:string" required="false()" /> <xf:bind id="selected_deployment_fid" nodeset="instance('inst_selected')/deployment_fid" type="xsd:string" required="false()" /> <xf:bind id="selected_deployment" nodeset="instance('inst_installation_deployments')//aatams:installation_deployment[aatams:deployment_fid=instance('inst_selected')/deployment_fid]" /> <xf:dispatch ev:event="xforms-ready" name="set-selected" target="model1" /> <xf:action ev:event="set-selected"> <xf:setvalue ref="instance('inst_selected')//installation_fid" value="instance('inst_installations')//aatams:installation[1]/@gml:id" /> <xf:dispatch name="xforms-revalidate" target="model1" /> </xf:action> </xf:model> </head> <body> <xf:switch> <xf:case id="select_deployment"> <div class="form"> <legend>PRINT RECOVERY WORKSHEET</legend> <div class="form-contents"> <div class="dependant-selects"> <xf:select1 bind="selected_installation_fid" appearance="minimal" incremental="true()"> <xf:label>Installation</xf:label> <xf:itemset nodeset="instance('inst_installations')//aatams:installation"> <xf:value ref="@gml:id" /> <xf:label ref="aatams:name" /> </xf:itemset> <xf:action ev:event="xforms-value-changed"> <xf:setvalue ref="instance('inst_selected')//deployment_fid" value="" /> </xf:action> </xf:select1> <xf:select1 bind="selected_deployment_fid" appearance="minimal" incremental="true()"> <xf:label>Scheduled Recoveries</xf:label> <xf:itemset nodeset="instance('inst_installation_deployments')//aatams:installation_deployment[aatams:installation_fid=instance('inst_selected')/installation_fid and aatams:scheduled_recovery_date >= local-date()]"> <xf:value ref="@gml:id" /> <xf:label ref="aatams:name" /> </xf:itemset> </xf:select1> </div> <xf:trigger> <xf:label>Show Worksheet</xf:label> <xf:toggle case="show_worksheet" ev:event="DOMActivate" /> </xf:trigger> </div> </div> </xf:case> <xf:case id="show_worksheet"> <xf:group bind="selected_deployment"> <xf:output ref="aatams:longitude"> <xf:label>Longitude:</xf:label> </xf:output> <xf:output ref="aatams:latitude"> <xf:label>Latitude:</xf:label> </xf:output> </xf:group> <xf:output bind="selected_deployment_fid"> <xf:label>deployment:</xf:label> </xf:output> <xf:trigger> <xf:label>Select Deployment</xf:label> <xf:toggle case="select_deployment" ev:event="DOMActivate" /> </xf:trigger> </xf:case> </xf:switch> <br /> <div id="console" style="display:block;top:100px;" /> </body> </html> I want the output controls in the xf:group to change according to the item selected in the second select. Interestingly the contents of the second xf:select1 changes automatically according to what is selected by the user in the first xf:select1 but the 'context' of the xf:group is not changing in the same fashion. I can provide all the model data files as well if anyone is interested to see this in action. -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |
|
From: Tambet M. <tam...@gm...> - 2010-01-05 08:01:41
|
Stephen Cameron wrote:
> Hello,
>
> I have a specific problem where I wish to select a record from a
> xf:select1 list and then on on the basis of the selected value display a
> full record below it.
>
> The full record will be displayed with the use of a xf:group tag, so I
> am a really wanting to dynamically change the node the group references
> via its 'ref 'or 'bind' attribute
Something like this should work:
<xforms:select1 ref="instance('temp')/selected_id">
<xforms:itemset nodeset="instance('data')/item">
<xforms:value ref="id"/>
<xforms:label ref="label"/>
</xforms:itemset>
</xforms:select1>
<xforms:group ref="instance('data')/item[id =
instance('temp')/selected_id]">
<xforms:output ref="id">...</xforms:output>
<xforms:output ref="label">...</xforms:output>
</xforms:group>
Tambet
|
|
From: Klotz, L. <Lei...@XE...> - 2010-01-05 23:30:21
|
If the test code is working for you, it's possible there's a bug with bind in XSLTForms so you might try re-doing your existing code without the bind/@id and see if that works.
By the way, there are a couple of simplications you might try as well:
. Unless I'm wrong and XSLTForms is unusual, you can remove a couple of MIP attribute from those binds:
<xf:bind id="selected_deployment_fid" nodeset="instance('inst_selected')/deployment_fid" type="xsd:string" required="false()" />
The type and required bindings aren't doing anything for you. You might be planning to use them for something later though.
If you do decide to put the types in, you'll probably need an xmlns:xsd definition, or else use a recent SVN release of XSLTforms and use unprefixed names (which are actually defined as unions with the empty string).
. In XPath, // is usually expensive:
In ref="instance('inst_selected')//installation_fid"
You might do get better performnance if the binding doesn't have to search the entire instance to find the element.
In this case, since the context node default is "/*[1]" you can just do
ref="instance('inst_selected')/installation_fid"
. xforms-ready vs. xforms-model-construct-done
Unless you want to wait for the UI to be initialized, you can do model setup on xforms-model-construct-done instead of on xforms-ready.
It should avoid an extra (possibly expensive) refresh.
. Initial instances
This may be an artifact of your test code that the instances are loaded from long query stirngs, but you might find it more maintainable to do this: (You might not find this more readable, but if you do, it might be helpful.)
<xf:instance id="inst_installations">
<data xmlns="">
<service>WFS</service>
<version>1.1.0<version>
<request>GetFeature</request>
<namespace>xmlns(aatams=http://www.imos.org.au/aatams)</namespace>
<typename>aatams:installation</typename>
</data>
</xf:instance>
<xf:submission id="init_inst_installations" resource="../deegree-wfs/services" ref="instance('inst_installations')" replace="instance" method="get" separator="&" />
<xf:send ev:event="xforms-model-construct-done" submission="init_inst_installations" />
. Questions about the init sequence
Why is the dispatch of the custom event "set-selected" and separate setvalue necessary?
Does doing the setvalue directly on xforms-ready (or on xforms-model-construct-done) not work?
If it doesn't, it may be an XSLTForms bug.
Also, the dispatche to xforms-revalidate is a puzzler as well, and if it's a bug workaround for xsltforms it would be good to know.
I'd have naively thought that this might work fine:
<xf:setvalue ev:event="xforms-model-construct-done" ref="instance('inst_selected')/installation_fid"
value="instance('inst_installations')/aatams:installation[1]/@gml:id" />
. @incremental
@incremental isn't an xpath expression, so it's incremental="true".
Leigh.
-----Original Message-----
From: Stephen Cameron [mailto:Ste...@ut...]
Sent: Monday, January 04, 2010 9:32 PM
To: xsl...@li...
Subject: [Xsltforms-support] stepping through recordset type data display
Hello,
I have a specific problem where I wish to select a record from a
xf:select1 list and then on on the basis of the selected value display a full record below it.
The full record will be displayed with the use of a xf:group tag, so I am a really wanting to dynamically change the node the group references via its 'ref 'or 'bind' attribute.
I cannot get this to work, but I cannot find an example where someone has done this to know that it should work.
Effectively the behaviour that I want to replicate can be seen in an
(non-Xform) example here
http://xmljs.sourceforge.net/contributedAdd-ons/xpath/sampleApplications/contactManager/contactManager.html.
This just steps through a xml 'recordset' displaying each record in turn. I'd be interested to see this done in an XSLTForms example!
My Xform code is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="forms/xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns:gml="http://www.opengis.net/gml"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:aatams="http://www.imos.org.au/aatams"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events" wfs:dummy="dummy"
gml:dummy="dummy" aatams:dummy="dummy">
<head>
<title>PRINT RECOVERY WORKSHEET</title>
<link href="forms/aatams.css" rel="stylesheet" type="text/css" />
<xf:model id="model1">
<!-- get the relevant deployments -->
<xf:instance id="inst_installations"
src="../deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&namespace=xmlns(aatams=http://www.imos.org.au/aatams)&typename=aatams:installation"
/>
<xf:instance id="inst_installation_deployments"
src="../deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&namespace=xmlns(aatams=http://www.imos.org.au/aatams)&typename=aatams:installation_deployment"
/>
<xf:instance id="inst_selected">
<data>
<installation_fid />
<deployment_fid />
</data>
</xf:instance>
<xf:bind id="selected_installation_fid"
nodeset="instance('inst_selected')/installation_fid" type="xsd:string"
required="false()" />
<xf:bind id="selected_deployment_fid"
nodeset="instance('inst_selected')/deployment_fid" type="xsd:string"
required="false()" />
<xf:bind id="selected_deployment"
nodeset="instance('inst_installation_deployments')//aatams:installation_deployment[aatams:deployment_fid=instance('inst_selected')/deployment_fid]"
/>
<xf:dispatch ev:event="xforms-ready" name="set-selected"
target="model1" />
<xf:action ev:event="set-selected">
<xf:setvalue
ref="instance('inst_selected')//installation_fid"
value="instance('inst_installations')//aatams:installation[1]/@gml:id" />
<xf:dispatch name="xforms-revalidate" target="model1" />
</xf:action>
</xf:model>
</head>
<body>
<xf:switch>
<xf:case id="select_deployment">
<div class="form">
<legend>PRINT RECOVERY WORKSHEET</legend>
<div class="form-contents">
<div class="dependant-selects">
<xf:select1 bind="selected_installation_fid"
appearance="minimal" incremental="true()">
<xf:label>Installation</xf:label>
<xf:itemset nodeset="instance('inst_installations')//aatams:installation">
<xf:value ref="@gml:id" />
<xf:label ref="aatams:name" />
</xf:itemset>
<xf:action ev:event="xforms-value-changed">
<xf:setvalue ref="instance('inst_selected')//deployment_fid" value="" />
</xf:action>
</xf:select1>
<xf:select1 bind="selected_deployment_fid"
appearance="minimal" incremental="true()">
<xf:label>Scheduled Recoveries</xf:label>
<xf:itemset nodeset="instance('inst_installation_deployments')//aatams:installation_deployment[aatams:installation_fid=instance('inst_selected')/installation_fid
and aatams:scheduled_recovery_date >= local-date()]">
<xf:value ref="@gml:id" />
<xf:label ref="aatams:name" />
</xf:itemset>
</xf:select1>
</div>
<xf:trigger>
<xf:label>Show Worksheet</xf:label>
<xf:toggle case="show_worksheet"
ev:event="DOMActivate" />
</xf:trigger>
</div>
</div>
</xf:case>
<xf:case id="show_worksheet">
<xf:group bind="selected_deployment">
<xf:output ref="aatams:longitude">
<xf:label>Longitude:</xf:label>
</xf:output>
<xf:output ref="aatams:latitude">
<xf:label>Latitude:</xf:label>
</xf:output>
</xf:group>
<xf:output bind="selected_deployment_fid">
<xf:label>deployment:</xf:label>
</xf:output>
<xf:trigger>
<xf:label>Select Deployment</xf:label>
<xf:toggle case="select_deployment"
ev:event="DOMActivate" />
</xf:trigger>
</xf:case>
</xf:switch>
<br />
<div id="console" style="display:block;top:100px;" />
</body>
</html>
I want the output controls in the xf:group to change according to the item selected in the second select.
Interestingly the contents of the second xf:select1 changes automatically according to what is selected by the user in the first
xf:select1 but the 'context' of the xf:group is not changing in the same fashion.
I can provide all the model data files as well if anyone is interested to see this in action.
--
Regards
Stephen Cameron
Data Programmer
Integrated Marine Observing System (IMOS)
eMarine Information Infrastructure Project
University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia
Tel: +61 3 6226 8507
Fax: +61 3 6226 2997
Email: ste...@ut...
URL: http://www.imos.org.au/eMII.html
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Xsltforms-support mailing list
Xsl...@li...
https://lists.sourceforge.net/lists/listinfo/xsltforms-support
|
|
From: Stephen C. <Ste...@ut...> - 2010-01-06 00:42:18
|
Thanks for your valued comments Leigh,
I'll work through them all and comment
Klotz, Leigh wrote:
> If the test code is working for you, it's possible there's a bug with bind in XSLTForms so you might try re-doing your existing code without the bind/@id and see if that works.
>
> By the way, there are a couple of simplications you might try as well:
>
> . Unless I'm wrong and XSLTForms is unusual, you can remove a couple of MIP attribute from those binds:
>
> <xf:bind id="selected_deployment_fid" nodeset="instance('inst_selected')/deployment_fid" type="xsd:string" required="false()" />
>
> The type and required bindings aren't doing anything for you. You might be planning to use them for something later though.
> If you do decide to put the types in, you'll probably need an xmlns:xsd definition, or else use a recent SVN release of XSLTforms and use unprefixed names (which are actually defined as unions with the empty string).
>
Presumably as these (type and required) are the defaults and so are not
needed. Is that unprefixed names for datatypes only ?
> . In XPath, // is usually expensive:
> In ref="instance('inst_selected')//installation_fid"
> You might do get better performnance if the binding doesn't have to search the entire instance to find the element.
> In this case, since the context node default is "/*[1]" you can just do
> ref="instance('inst_selected')/installation_fid"
>
Agreed
> . xforms-ready vs. xforms-model-construct-done
> Unless you want to wait for the UI to be initialized, you can do model setup on xforms-model-construct-done instead of on xforms-ready.
> It should avoid an extra (possibly expensive) refresh.
>
I actually need the refresh to occur (I think), see my comments below regarding xforms-revalidate.
> . Initial instances
> This may be an artifact of your test code that the instances are loaded from long query stirngs, but you might find it more maintainable to do this: (You might not find this more readable, but if you do, it might be helpful.)
>
> <xf:instance id="inst_installations">
> <data xmlns="">
> <service>WFS</service>
> <version>1.1.0<version>
> <request>GetFeature</request>
> <namespace>xmlns(aatams=http://www.imos.org.au/aatams)</namespace>
> <typename>aatams:installation</typename>
> </data>
> </xf:instance>
> <xf:submission id="init_inst_installations" resource="../deegree-wfs/services" ref="instance('inst_installations')" replace="instance" method="get" separator="&" />
> <xf:send ev:event="xforms-model-construct-done" submission="init_inst_installations" />
>
>
This is a nice way to do it, I presume this method is available to allow
you to build a request dynamically, handy to know!
> . Questions about the init sequence
> Why is the dispatch of the custom event "set-selected" and separate setvalue necessary?
> Does doing the setvalue directly on xforms-ready (or on xforms-model-construct-done) not work?
> If it doesn't, it may be an XSLTForms bug.
>
> Also, the dispatche to xforms-revalidate is a puzzler as well, and if it's a bug workaround for xsltforms it would be good to know.
> I'd have naively thought that this might work fine:
> <xf:setvalue ev:event="xforms-model-construct-done" ref="instance('inst_selected')/installation_fid"
> value="instance('inst_installations')/aatams:installation[1]/@gml:id" />
>
>
Sorry, I copied some old code for this Xform and some things are not
needed, however to explain the origins of the set-selected custom event:
In HTML you have the following situation.
<select id="list1">
<option value="1" >Item 1</option>
<option value="2" selected="true">Item 2</option>
<option value="3">Item 3</option>
</select>
So the second item in the list appears selected after the form loads. In
Xforms I cannot see how to achieve the same thing other than using the
method I devised. This method avoids user confusion,
as it's problematic when the first item is visible in the select1 list
but unless the user actually selects an item in the list nothing has
actually been triggered (so a mandatory field appears as invalid even though
a valid option is visible). I don't really want to use an empty option,
partly as this is not simple to achieve in XForms either when the
select1 data comes from outside of the form.
There is a problem currently when there is only one item in the list as
that item cannot be manually selected at all, this is something on my
todo list for resolution (is it a bug?).
> . @incremental
> @incremental isn't an xpath expression, so it's incremental="true".
>
> Leigh.
>
> -----Original Message-----
> From: Stephen Cameron [mailto:Ste...@ut...]
> Sent: Monday, January 04, 2010 9:32 PM
> To: xsl...@li...
> Subject: [Xsltforms-support] stepping through recordset type data display
>
> Hello,
>
> I have a specific problem where I wish to select a record from a
> xf:select1 list and then on on the basis of the selected value display a full record below it.
>
> The full record will be displayed with the use of a xf:group tag, so I am a really wanting to dynamically change the node the group references via its 'ref 'or 'bind' attribute.
>
> I cannot get this to work, but I cannot find an example where someone has done this to know that it should work.
>
> Effectively the behaviour that I want to replicate can be seen in an
> (non-Xform) example here
> http://xmljs.sourceforge.net/contributedAdd-ons/xpath/sampleApplications/contactManager/contactManager.html.
> This just steps through a xml 'recordset' displaying each record in turn. I'd be interested to see this done in an XSLTForms example!
>
> My Xform code is as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet href="forms/xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns:gml="http://www.opengis.net/gml"
> xmlns:wfs="http://www.opengis.net/wfs"
> xmlns:aatams="http://www.imos.org.au/aatams"
> xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:ev="http://www.w3.org/2001/xml-events" wfs:dummy="dummy"
> gml:dummy="dummy" aatams:dummy="dummy">
> <head>
> <title>PRINT RECOVERY WORKSHEET</title>
> <link href="forms/aatams.css" rel="stylesheet" type="text/css" />
> <xf:model id="model1">
> <!-- get the relevant deployments -->
> <xf:instance id="inst_installations"
> src="../deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&namespace=xmlns(aatams=http://www.imos.org.au/aatams)&typename=aatams:installation"
> />
> <xf:instance id="inst_installation_deployments"
> src="../deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&namespace=xmlns(aatams=http://www.imos.org.au/aatams)&typename=aatams:installation_deployment"
> />
> <xf:instance id="inst_selected">
> <data>
> <installation_fid />
> <deployment_fid />
> </data>
> </xf:instance>
> <xf:bind id="selected_installation_fid"
> nodeset="instance('inst_selected')/installation_fid" type="xsd:string"
> required="false()" />
> <xf:bind id="selected_deployment_fid"
> nodeset="instance('inst_selected')/deployment_fid" type="xsd:string"
> required="false()" />
> <xf:bind id="selected_deployment"
> nodeset="instance('inst_installation_deployments')//aatams:installation_deployment[aatams:deployment_fid=instance('inst_selected')/deployment_fid]"
> />
> <xf:dispatch ev:event="xforms-ready" name="set-selected"
> target="model1" />
> <xf:action ev:event="set-selected">
> <xf:setvalue
> ref="instance('inst_selected')//installation_fid"
> value="instance('inst_installations')//aatams:installation[1]/@gml:id" />
> <xf:dispatch name="xforms-revalidate" target="model1" />
> </xf:action>
> </xf:model>
> </head>
> <body>
> <xf:switch>
> <xf:case id="select_deployment">
> <div class="form">
> <legend>PRINT RECOVERY WORKSHEET</legend>
> <div class="form-contents">
> <div class="dependant-selects">
> <xf:select1 bind="selected_installation_fid"
> appearance="minimal" incremental="true()">
> <xf:label>Installation</xf:label>
> <xf:itemset nodeset="instance('inst_installations')//aatams:installation">
> <xf:value ref="@gml:id" />
> <xf:label ref="aatams:name" />
> </xf:itemset>
> <xf:action ev:event="xforms-value-changed">
> <xf:setvalue ref="instance('inst_selected')//deployment_fid" value="" />
> </xf:action>
> </xf:select1>
> <xf:select1 bind="selected_deployment_fid"
> appearance="minimal" incremental="true()">
> <xf:label>Scheduled Recoveries</xf:label>
> <xf:itemset nodeset="instance('inst_installation_deployments')//aatams:installation_deployment[aatams:installation_fid=instance('inst_selected')/installation_fid
> and aatams:scheduled_recovery_date >= local-date()]">
> <xf:value ref="@gml:id" />
> <xf:label ref="aatams:name" />
> </xf:itemset>
> </xf:select1>
> </div>
> <xf:trigger>
> <xf:label>Show Worksheet</xf:label>
> <xf:toggle case="show_worksheet"
> ev:event="DOMActivate" />
> </xf:trigger>
> </div>
> </div>
> </xf:case>
> <xf:case id="show_worksheet">
> <xf:group bind="selected_deployment">
> <xf:output ref="aatams:longitude">
> <xf:label>Longitude:</xf:label>
> </xf:output>
> <xf:output ref="aatams:latitude">
> <xf:label>Latitude:</xf:label>
> </xf:output>
> </xf:group>
> <xf:output bind="selected_deployment_fid">
> <xf:label>deployment:</xf:label>
> </xf:output>
> <xf:trigger>
> <xf:label>Select Deployment</xf:label>
> <xf:toggle case="select_deployment"
> ev:event="DOMActivate" />
> </xf:trigger>
> </xf:case>
> </xf:switch>
> <br />
> <div id="console" style="display:block;top:100px;" />
> </body>
> </html>
>
> I want the output controls in the xf:group to change according to the item selected in the second select.
>
> Interestingly the contents of the second xf:select1 changes automatically according to what is selected by the user in the first
> xf:select1 but the 'context' of the xf:group is not changing in the same fashion.
>
> I can provide all the model data files as well if anyone is interested to see this in action.
>
>
>
--
Regards
Stephen Cameron
Data Programmer
Integrated Marine Observing System (IMOS)
eMarine Information Infrastructure Project
University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia
Tel: +61 3 6226 8507
Fax: +61 3 6226 2997
Email: ste...@ut...
URL: http://www.imos.org.au/eMII.html
|
|
From: Klotz, L. <Lei...@xe...> - 2010-01-06 01:07:51
|
Stephen,
I don't mean to make you do an "oral defense" of your code. I do want to find out if I can glean any XSLTForms bugs from your experience,
and at the same time give back to you in the form of some streamlining. So there's more commentary below.
-----Original Message-----
From: Stephen Cameron [mailto:Ste...@ut...]
Sent: Tuesday, January 05, 2010 4:42 PM
To: xsl...@li...
Subject: Re: [Xsltforms-support] stepping through recordset type data display
Thanks for your valued comments Leigh,
I'll work through them all and comment
Klotz, Leigh wrote:
> . xforms-ready vs. xforms-model-construct-done Unless you want to wait
> for the UI to be initialized, you can do model setup on xforms-model-construct-done instead of on xforms-ready.
> It should avoid an extra (possibly expensive) refresh.
>
I actually need the refresh to occur (I think), see my comments below regarding xforms-revalidate.
Can you let me know in what cases the refresh doesn't happen? If you do a setvalue in an action handler, refresh should just happen
automagically. The "extra refresh" I was talking about is this: if you wait until xforms-read, the UI will get set up, then you'll do some
changes, and then the refresh will happen again. xforms-model-construct-done is the last step before the UI gets set
up, and it's the right place to hook in data initialization, which is what I think you're doing in this case.
...
> . Questions about the init sequence
> Why is the dispatch of the custom event "set-selected" and separate setvalue necessary?
> Does doing the setvalue directly on xforms-ready (or on xforms-model-construct-done) not work?
> If it doesn't, it may be an XSLTForms bug.
>
> Also, the dispatche to xforms-revalidate is a puzzler as well, and if it's a bug workaround for xsltforms it would be good to know.
> I'd have naively thought that this might work fine:
> <xf:setvalue ev:event="xforms-model-construct-done" ref="instance('inst_selected')/installation_fid"
>
> value="instance('inst_installations')/aatams:installation[1]/@gml:id"
> />
>
>
Sorry, I copied some old code for this Xform and some things are not needed, however to explain the origins of the set-selected custom event:
I've got a more specific question, which is to ask why you're listening to xforms-ready and then dispatching a custom event called set-selected.
In the example code, the set-selected event isn't used anywhere else; maybe in the real code it's used in other places, which would explain
why it's named (for sharing). If it's a bug workaround of some sort, it'd be nice to know.
In HTML you have the following situation.
<select id="list1">
<option value="1" >Item 1</option>
<option value="2" selected="true">Item 2</option> <option value="3">Item 3</option> </select>
So the second item in the list appears selected after the form
loads. In Xforms I cannot see how to achieve the same thing other
than using the method I devised. This method avoids user
confusion, as it's problematic when the first item is visible in
the select1 list but unless the user actually selects an item in
the list nothing has actually been triggered (so a mandatory field
appears as invalid even though a valid option is visible).
This problem shouldn't happen at all, and it's a bug in the XSLTForms implementation. An xf:select1 bound to a node where the node value
isn't in the itemset or items should not show a selected value. It should also sport a CSS3 psuedo-class :out-of-range; most current
XHTML+XForms+CSS2 implementations do this with a dynamic DOM-level attribute instead since CSS3 isn't there for us.
But anyway, even once that's cleared up, you probably still would want to set the initial value, and so doing this ought to work fine:
<xf:setvalue ev:event="xforms-model-construct-done" ref="instance('inst_selected')/installation_fid"
value="instance('inst_installations')/aatams:installation[1]/@gml:id" />
If you find you still need the revalidate or refresh, I'm pretty sure there's a bug in XSLTForms.
...
There is a problem currently when there is only one item in the
list as that item cannot be manually selected at all, this is
something on my todo list for resolution (is it a bug?).
This may have been fixed in recent SVN versions of XSLTForms by Alain.
Leigh.
|