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