I am working with an InfoPath form with multiple views and submitting via HTTP POST to a Java servlet. If I get an error message back from the servlet (e.g., the value for "/xpath/to/node" needs attention), I would like to not only display a message (I've done that), but also set focus to a field bound to that node.
I can use
View.SelectText() to set focus, but how can I tell which view(s) have a control bound to the node? Can this be answered using JScript?
Here's some pseudocode to describe my question...
// assume we're given XPath to a node with a "problem"
var problemNodeXPath = "/xpath/to/node";
// Fetch the specific DOM node using XPath
var objNode = XDocument.DOM.selectSingleNode(problemNodeXPath);
// Get the views that contain 1+ controls bound to the node
// Can this be done using JScript?
var possibleViews = viewsWithControlsBoundToNode(objNode);
// Switch to the first view that uses the data
XDocument.View.SwitchView(possibleViews(0))
// Set focus to the "problem" node
XDocument.View.SelectText(objNode);
In the fictitious
viewsWithControlsBoundToNode(node) method above, I would iterate through available views, test each one to see if it contained a control bound to the given node, and return a list of those views that met the criteria. Even an
anyViewWithControlBoundToNode(node) method would suffice.
My apologies if this has been covered or answered elsewhere. Any help would be appreciated.