Hello All,
I have been working on a custom extension function, which is a simple
function to check that some value in an instance node is not a member of
another existing nodeset (to check that someone is entering a unique
value when compared to a list of existing values). I have the function
working correctly for the simple case but I have run into an issue where
the parameters to the function are only able to take values from one
particular xforms instance. It appears that within my custom function,
I am unable to use nodes from two different instance documents by using
the xforms instance() function in any of the parameters. I am using two
separate instances because the list of existing nodes is ideally coming
from an external data source, and I would like to keep that as a
separate url loadable instance. This will all make more sense with the
included example. I have tested it in both 0.9.7 and 0.9.8. If anyone
has some idea about whether this should work or not please let me know.
Also, I am open to
I have included the function code (paste into
org/chiba/xml/xforms/xpath/ChibaExtensionFunctions.java, recompile,
enable in the org/chiba/xml/xforms/config/default.xml, restart webapp):
public static boolean member(String input, List nodeset) {
if ((nodeset == null) || (nodeset.size() == 0)) {
return false;
}
boolean member = false;
Iterator nodesetIter = nodeset.iterator();
while (nodesetIter.hasNext()) {
String value = nodesetIter.next().toString();
if (input.equals(value)) {
member = true;
break;
}
}
return member;
}
I have also attached my test form as z.xhtml. Within that form, on line
41 which is commented out, I have a working implemenation of the member
function. On line 37 I have the use of the member function which does
not work I believe because of the parameters.
Thanks,
Zach Roberts
z.xhtml
Description: application/xhtml
|