Wednesday, August 16, 2006

One of the most useful pieces of code used by the InfoPath Developers here at Visiphor is the SecondaryDataSource Class written by one of our senior developers, Keith Curtis.

This class exposes some simple methods which we use to interact with secondary data sources.
  • Call the secondary datasource (query()),
  • Query data (GetNodeValue(), GetValue())
  • Set data (SetNodeValue).
All of the clutter of handling a secondary datasource in code (namespacing, instantiating the connection, etc.) are handled from within the class. The developer need only instanciate the class, by passing the name of the secondary data source and the XDocument, to have access to these very simple tools.

The GetNodeValue and GetValue methods behave more like typical XSLT xsl:value-of calls where xpath queries that result in missing nodes do not cause catastrophic exceptions, but rather return empty strings. Trace messages can be returned if the xpath query does not return a node, but the call will not fail.

We added a winform to the InfoPath form that is called by the query method. The winform displays a progress bar, which runs in a separate thread so while the form is disabled by calls to a datasource/webservice, the progress bar gives the user something to look at. Also, because the winform runs in a separate thread, it displays while the form is initially loading (before the first view is rendered) - NICE!

I'll talk more about the winform and the speed-of-load issues which spawned the need/want of the progress bar in future entries.

If you'd like more info about the class, drop me a line.

Thanks for reading,

Jessel

No comments: