Re: Re: RE: Re: RE: RE: Error when using xforms:action with xforms:setValue
Posted by
Markku Laine on
Nov 12, 2009; 3:19pm
URL: https://discuss.orbeon.com/Error-when-using-xforms-action-with-xforms-setValue-tp585594p620330.html
On 12.11.2009, at 16.49, Markku Laine wrote:
> Stephanie,
>
>
>> I read in the archives that, via Javascript, we could not do
>> something like "document.getElementById('myModelId')" or
>> "document.getElementById('myInstanceId')" due to hiding them for
>> security reasons. My point is that it would be really handy to
>> have a setting to be able to update our instances/model via
>> javascript which we currently cannot do.
>
> Have you read this proposal about XForms-JavaScript integration:
http://wiki.orbeon.com/forms/projects/client-side-api-for-custom-javascript-widgets>
> As far as I know, it has not implemented yet but it looks really
> good, though.
>
> If you want to modify Instance Data via JavaScript you can do that
> by binding the elements you want to modify to hidden input fields.
> Then just use JavaScript for modifying the value in that hidden
> input field and it will be updated to the Instance Data.
Here is an example how to do it (haven't run the code so it might
contain mistakes).
<head>
...
<script type="text/javascript">
var your-variable = "Hello World!"; // Set value to a variable
using JavaScript
ORBEON.xforms.Document.setValue( "your-element", your-
variable ); // Set value to an element (Instance Data) using JavaScript
</script>
...
<xforms:instance id="your-instance">
<your-instance xmlns="">
<your-element />
</your-instance>
</xforms:instance>
...
</head>
<body>
...
<xforms:input class="hidden" id="your-element" ref="instance( 'your-
instance' )/your-element" />
...
</body>
--
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
OW2 mailing lists service home page:
http://www.ow2.org/wws