mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
using browser based xpath (for now just mozilla). fixes a combobox bug where i wasn't evaluating an xpath:constraint, and allows reading back model data with more complicated xpaths (such as repeater data).
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3819 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -83,25 +83,22 @@ public class XFormsInputMethod
|
|||||||
" };\n" +
|
" };\n" +
|
||||||
"var WEBAPP_CONTEXT = \"" + cp + "\";\n"));
|
"var WEBAPP_CONTEXT = \"" + cp + "\";\n"));
|
||||||
div.appendChild(e);
|
div.appendChild(e);
|
||||||
|
final String[] scripts =
|
||||||
|
{
|
||||||
|
"/scripts/tiny_mce/tiny_mce_src.js",
|
||||||
|
"/scripts/ajax/dojo.js",
|
||||||
|
"/scripts/ajax/xforms.js"
|
||||||
|
};
|
||||||
|
|
||||||
// include all our scripts, order is significant
|
// include all our scripts, order is significant
|
||||||
|
for (int i = 0; i < scripts.length; i++)
|
||||||
|
{
|
||||||
e = result.createElement("script");
|
e = result.createElement("script");
|
||||||
e.setAttribute("type", "text/javascript");
|
e.setAttribute("type", "text/javascript");
|
||||||
e.setAttribute("src", cp + "/scripts/tiny_mce/tiny_mce_src.js");
|
e.setAttribute("src", cp + scripts[i]);
|
||||||
e.appendChild(result.createTextNode("\n"));
|
|
||||||
div.appendChild(e);
|
|
||||||
|
|
||||||
e = result.createElement("script");
|
|
||||||
e.setAttribute("type", "text/javascript");
|
|
||||||
e.setAttribute("src", cp + "/scripts/ajax/dojo.js");
|
|
||||||
e.appendChild(result.createTextNode("\n"));
|
|
||||||
div.appendChild(e);
|
|
||||||
|
|
||||||
e = result.createElement("script");
|
|
||||||
e.setAttribute("type", "text/javascript");
|
|
||||||
e.setAttribute("src", cp + "/scripts/ajax/xforms.js");
|
|
||||||
e.appendChild(result.createTextNode("\n"));
|
e.appendChild(result.createTextNode("\n"));
|
||||||
div.appendChild(e);
|
div.appendChild(e);
|
||||||
|
}
|
||||||
|
|
||||||
ts.writeXML(result, out);
|
ts.writeXML(result, out);
|
||||||
}
|
}
|
||||||
|
@@ -64,41 +64,26 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
var required = binding && binding.required == "true()";
|
var required = binding && binding.required == "true()";
|
||||||
return required;
|
return required;
|
||||||
},
|
},
|
||||||
getModelNode: function()
|
|
||||||
{
|
|
||||||
///XXXarielb todo
|
|
||||||
},
|
|
||||||
getInitialValue: function()
|
getInitialValue: function()
|
||||||
{
|
{
|
||||||
var b = this._getBinding();
|
var chibaData = this.node.getElementsByTagName("data");
|
||||||
var a = [];
|
if (chibaData.length == 0)
|
||||||
do
|
|
||||||
{
|
|
||||||
a.push(b.nodeset);
|
|
||||||
b = b.parent;
|
|
||||||
}
|
|
||||||
while (b);
|
|
||||||
var node = this.xform.getInstance();
|
|
||||||
for (var i = a.length - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
var element_name = (a[i].match(/^\//)
|
|
||||||
? a[i].replace(/^\/(.+)/, "$1")
|
|
||||||
: a[i]);
|
|
||||||
dojo.debug("locating " + a[i] + "(" + element_name + ")" +
|
|
||||||
" in " + node.nodeName);
|
|
||||||
if (element_name.match(/^@/))
|
|
||||||
return node.getAttribute(a[i].replace(/^@(.+)/, "$1"));
|
|
||||||
else if (element_name == '.')
|
|
||||||
break;
|
|
||||||
node = node.getElementsByTagName(element_name)[0];
|
|
||||||
if (node)
|
|
||||||
dojo.debug("got node " + node.nodeName);
|
|
||||||
else
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
var result = dojo.dom.textContent(node);
|
chibaData = chibaData[chibaData.length - 1];
|
||||||
dojo.debug("got '" + result + "' for " + a.reverse().join("/"));
|
var xpath = "/" + chibaData.getAttribute("chiba:xpath");
|
||||||
return result;
|
var d = this.node.ownerDocument;
|
||||||
|
var nsResolver = d.createNSResolver(d);
|
||||||
|
var contextNode = this.xform.getInstance();
|
||||||
|
dojo.debug("locating " + xpath +
|
||||||
|
" from " + chibaData.nodeName +
|
||||||
|
" in " + contextNode.nodeName);
|
||||||
|
var result = d.evaluate(xpath,
|
||||||
|
this.xform.getInstance(),
|
||||||
|
nsResolver,
|
||||||
|
XPathResult.STRING_TYPE,
|
||||||
|
null);
|
||||||
|
return result.stringValue;
|
||||||
},
|
},
|
||||||
_getLabelNode: function()
|
_getLabelNode: function()
|
||||||
{
|
{
|
||||||
@@ -278,6 +263,7 @@ dojo.declare("alfresco.xforms.Select1",
|
|||||||
},
|
},
|
||||||
getValues: function()
|
getValues: function()
|
||||||
{
|
{
|
||||||
|
var binding = this._getBinding();
|
||||||
var values = this.node.getElementsByTagName("item");
|
var values = this.node.getElementsByTagName("item");
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var v in values)
|
for (var v in values)
|
||||||
@@ -286,6 +272,22 @@ dojo.declare("alfresco.xforms.Select1",
|
|||||||
{
|
{
|
||||||
var label = values[v].getElementsByTagName("label")[0];
|
var label = values[v].getElementsByTagName("label")[0];
|
||||||
var value = values[v].getElementsByTagName("value")[0];
|
var value = values[v].getElementsByTagName("value")[0];
|
||||||
|
var valid = true;
|
||||||
|
if (binding.constraint)
|
||||||
|
{
|
||||||
|
dojo.debug("testing " + binding.constraint +
|
||||||
|
" on " + dojo.dom.textContent(value));
|
||||||
|
var d = this.node.ownerDocument;
|
||||||
|
valid = d.evaluate(binding.constraint,
|
||||||
|
value,
|
||||||
|
d.createNSResolver(d),
|
||||||
|
XPathResult.ANY_TYPE,
|
||||||
|
null);
|
||||||
|
dojo.debug("valid " + dojo.dom.textContent(value) + "? " + valid);
|
||||||
|
valid = valid.booleanValue;
|
||||||
|
}
|
||||||
|
if (valid)
|
||||||
|
{
|
||||||
result.push({
|
result.push({
|
||||||
id: value.getAttribute("id"),
|
id: value.getAttribute("id"),
|
||||||
label: dojo.dom.textContent(label),
|
label: dojo.dom.textContent(label),
|
||||||
@@ -293,6 +295,7 @@ dojo.declare("alfresco.xforms.Select1",
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
@@ -571,7 +574,7 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
{
|
{
|
||||||
var index = this.getChildIndex(child);
|
var index = this.getChildIndex(child);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
alert("unable to find child " + child.id + " in " + this.id);
|
throw new Error("unable to find child " + child.id + " in " + this.id);
|
||||||
|
|
||||||
// chiba thinks indexes are initialized to 1 so just
|
// chiba thinks indexes are initialized to 1 so just
|
||||||
// highlight the thing
|
// highlight the thing
|
||||||
@@ -803,6 +806,7 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
required: bind.childNodes[i].getAttribute("xforms:required"),
|
required: bind.childNodes[i].getAttribute("xforms:required"),
|
||||||
nodeset: bind.childNodes[i].getAttribute("xforms:nodeset"),
|
nodeset: bind.childNodes[i].getAttribute("xforms:nodeset"),
|
||||||
type: bind.childNodes[i].getAttribute("xforms:type"),
|
type: bind.childNodes[i].getAttribute("xforms:type"),
|
||||||
|
constraint: bind.childNodes[i].getAttribute("xforms:constraint"),
|
||||||
parent: parent
|
parent: parent
|
||||||
};
|
};
|
||||||
this._loadBindings(bind.childNodes[i], result[id], result);
|
this._loadBindings(bind.childNodes[i], result[id], result);
|
||||||
|
Reference in New Issue
Block a user