Posted by
Martin Hoffmann-5 on
URL: https://discuss.orbeon.com/How-to-change-xforms-model-via-Javascript-tp33221.html
Hello guys,
I found the following snippet, to change a value in the xforms model
via Javascript. This is conform to W3C spec, I think. Unfortunately,
this does not work with Orbeon.
In the post
http://mail-archive.objectweb.org/ops-users/2006-06/msg00043.html Alex says, that DOM access via Javascript is currently not implemented.
My use case is that I would like to get the remote ip from the client machine -
usually server-side accessed via "request.getRemoteHost();". The problem is in XForms I do not have the request object anymore. So I tried to include a JSP
page within the xform. There is a hidden field with the hostname. This works fine. Now, I want to copy the value to the xforms model. But do not have any idea how this can be done with your implementation.
Is there any possibility to write to the model via Javascript? I am using Intalio BPMS and the xform is a workflow task. The form output goes back to my business process. So I am a bit restricted and I would like to do it directly within the XHTML page.
Cheers,
Martin.
Snippet:
<html xmlns="
http://www.w3.org/1999/xhtml"
xmlns:xforms="
http://www.w3.org/2002/xforms"
xmlns:event="
http://www.w3.org/2001/xml-events">
<head>
<script language="javascript">
function changeMe(){
var model = document.getElementById("myModel");
var instance = model.getInstanceDocument ("myInstance");
var textElements = instance.getElementsByTagName("text");
textElements[0].firstChild.nodeValue = 'Changed!';
model.rebuild();
model.refresh();
}
</script>
<xforms:model id="myModel">
<xforms:instance id="myInstance">
<text xmlns="">Change Me!</text>
</xforms:instance>
<xforms:instance id="script">
<script url="javascript:changeMe()"/>
</xforms:instance>
</xforms:model>
</head>
<body>
<xforms:input ref="/text"/>
<xforms:trigger>
<xforms:label>Change!</xforms:label>
<xforms:load resource="javascript:changeMe()" event:event="DOMActivate"/>
</xforms:trigger>
</body>
</html>
--
You receive this message as a subscriber of the
[hidden email] mailing list.
To unsubscribe: mailto:
[hidden email]
For general help: mailto:
[hidden email]?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/wws