DataInterop Sample - Dynamically changing Binding?

M

Matthew Ortiz

I've got an InfoPath form that requires work offline. In other words, the
users will grab the InfoPath form originally from a URL, open the form, the
form executes the DataObject query and caches the data. I've done this
successfully using the DataInterop sample.

Now when the user saves the form locally and then re-opens the form when
offline the data is cached, it can be seen if you open the saved form in a
text editor, but the repeating section that contains a repeating table that
is bound to the original data object no longer binds. This isn't surprising;
however, I now need to change the binding of the repeating section and the
contained repeating table so that the cached data is now used to bind to.

I have not found how this is happening in the DataInterop sample. However,
in testing the sample I’ve opened the form, queried on the Employee, and then
click the Offline button. This caches the data, the same way that I do in my
app, and then prompts the user to save the file for offline use. The form is
then closed and the SQL Server service is stopped. I then re-open the form
and after a while waiting for the time out on the DataObject query execution
the cached data now shows up in the drop-downs. How is this being done?
I’ve obviously got a bit more complicated binding going on but how is the
data binding being changed to look at the cached data?

If I take a look at the OrderDetails.xsl I can see where I think the
‘xdComboBox’ is original bound to the DataObject (e.g.
‘xdXDocument:GetDOM("Employees")/dfs:myFields/dfs:dataFields/d:Employees’)
but the question remains how is control then changed to bind to the cached
data?

Can somebody provide any help on this? This seems to be something that
would be obvious but I’m not getting it.

I appreciate any support,

Matthew Ortiz
 
R

Rick Severson [MSFT]

Dynamically changing the binding of a control could be tricky. You might
try to have 2 identical repeating controls bound to two different sources.
One bound to the online data source and the other to an offline source.
Using rules and conditional formatting, you can show/hide the unused
control. Since the controls look the same, it gives the appearance of one
control.

In the OnLoad function, you could do a check for
Application.MachineOnlineState and only query the secondary data source for
the online version if this returns true (this way the user is not waiting
for a connection to time out just to find out they are off line).

Then, prior to leaving OnLoad, if you are online, you could update the cache
file from the online data source to the offline data source.
 
S

Steve van Dongen [MSFT]

I've got an InfoPath form that requires work offline. In other words, the
users will grab the InfoPath form originally from a URL, open the form, the
form executes the DataObject query and caches the data. I've done this
successfully using the DataInterop sample.

Now when the user saves the form locally and then re-opens the form when
offline the data is cached, it can be seen if you open the saved form in a
text editor, but the repeating section that contains a repeating table that
is bound to the original data object no longer binds. This isn't surprising;
however, I now need to change the binding of the repeating section and the
contained repeating table so that the cached data is now used to bind to.

I have not found how this is happening in the DataInterop sample. However,
in testing the sample I’ve opened the form, queried on the Employee, and then
click the Offline button. This caches the data, the same way that I do in my
app, and then prompts the user to save the file for offline use. The form is
then closed and the SQL Server service is stopped. I then re-open the form
and after a while waiting for the time out on the DataObject query execution
the cached data now shows up in the drop-downs. How is this being done?
I’ve obviously got a bit more complicated binding going on but how is the
data binding being changed to look at the cached data?

If I take a look at the OrderDetails.xsl I can see where I think the
‘xdComboBox’ is original bound to the DataObject (e.g.
‘xdXDocument:GetDOM("Employees")/dfs:myFields/dfs:dataFields/d:Employees’)
but the question remains how is control then changed to bind to the cached
data?

Can somebody provide any help on this? This seems to be something that
would be obvious but I’m not getting it.

The DataInterop sample doesn't change bindings. Look at the
LoadAuxiliaryDOMs function and where it's called in the OnLoad
handler. LoadAuxiliaryDOMs is called once and it calls Query on the
DataObjects. If it works, cool, if not then LoadAuxiliaryDOMs is
called again with the true parameter which causes it to copy the
cached data into the secondary datasource DOMs.

As Rick says, in SP1, it would be better to use the new
Application.MachineOnlineState property than waiting for the queries
to timeout. The OnLoad would basically look something like this:

gblnOnline = Application.MachineOnlineState;
LoadAuxiliaryDOMs(!gblnOnline);
if (gblnOnline)
{
if
(XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Orders/@EmployeeID").text
== "")
{
XDocument.ViewInfos("Query").IsDefault = true;
}
else
{
XDocument.ViewInfos("Orders").IsDefault = true;
}
}
else
{
XDocument.ViewInfos("Orders").IsDefault = true;
}

Regards,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top