Re: [Xsltforms-support] stepping through recordset type data display
Brought to you by:
alain-couthures
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 |