Integration with JavaScript and <xforms:repeat/>

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Integration with JavaScript and <xforms:repeat/>

Stian Sigvartsen
Integration with JavaScript and <xforms:repeat/>

Hi

I've been experimenting with the JavaScript integration available in Orbeon 3.9. My ultimate goal is to set instance data based on a call to a JSON service, and the <xxforms:code/> element would be ideal for this, but I don't think it's implemented yet? The feature is described here: http://wiki.orbeon.com/forms/projects/client-side-api-for-custom-javascript-widgets

Assuming that is the case I thought I'd have a go at using the more generic JavaScript integration described here: http://wiki.orbeon.com/forms/doc/developer-guide/xforms-javascript-integration

So I am using <xxforms:script/> element to execute JavaScript that consumes the JSON service and then I set set control values based on it using ORBEON.xforms.Document.setValue(). This in turn updates the XForms instance the controls are bound to.

However, this doesn't seem to work properly when the <xforms:input/> elements are inside a <xforms:repeat/>. As aforementioned reference describes this scenario: "Within repeats, currently you have to pass an "effective id", which is the id as found within the HTML element. Effective ids usually have the form myControl·1-2, where the suffix indicates the levels of repetition. The "·" character is unicode U+00B7."

I believe I have successfully derived the correct control ID to pass for the parameter, because the control in the repeat does in fact get updated successfully in the browser. However no event is dispatched to the Orbeon server to update the XForms instance (I did a HTTP trace with Firebug, comparing it with the working example without <xforms:repeat/>).

The JavaScript I executed is: ORBEON.xforms.Document.setValue('<portlet:namespace/>numberControl$xforms-input-1·1', 'testing');
My control is called "numberControl", I picked the full control name out of the generated HTML source.

Does anyone know if this is a known Orbeon 3.9 issue?

I am running this inside a Liferay portlet using the separate deployment with portlet approach.

-Stian



--
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
Reply | Threaded
Open this post in threaded view
|

Re: Integration with JavaScript and <xforms:repeat/>

Erik Bruchez
Administrator
> I've been experimenting with the JavaScript integration available in Orbeon
> 3.9. My ultimate goal is to set instance data based on a call to a JSON
> service, and the <xxforms:code/> element would be ideal for this, but I
> don't think it's implemented yet? The feature is described here:
> http://wiki.orbeon.com/forms/projects/client-side-api-for-custom-javascript-widgets

That's right, this is not implemented yet.

> I believe I have successfully derived the correct control ID to pass for the
> parameter, because the control in the repeat does in fact get updated
> successfully in the browser. However no event is dispatched to the Orbeon
> server to update the XForms instance (I did a HTTP trace with Firebug,
> comparing it with the working example without <xforms:repeat/>).
>
> The JavaScript I executed is:
> ORBEON.xforms.Document.setValue('<portlet:namespace/>numberControl$xforms-input-1·1',
> 'testing');
> My control is called "numberControl", I picked the full control name out of
> the generated HTML source.
>
> Does anyone know if this is a known Orbeon 3.9 issue?
It is not a known issue, but unfortunately I don't know if it's
actually a bug without doing research. Can you see if the value change
event is present in the Ajax request sent to the server after you call
setValue()? Is an event sent at all?

-Erik


--
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
Reply | Threaded
Open this post in threaded view
|

RE: Re: Integration with JavaScript and <xforms:repeat/>

Stian Sigvartsen
In reply to this post by Stian Sigvartsen
Hi Erik

Sorry for the delay, it has been a busy week.
I have created a bare necessities xhtml file which runs in the sandbox
so you can reproduce the issue. The fact that I can reproduce this in
this fashion also means that this issue is not to do with running orbeon
in a portlet.

There is a set value event is present in the AJAX request.

<!DOCTYPE xxforms:event-request [<!ENTITY nbsp "&#160;">]>
<xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xxforms:uuid>749696F0-4496-18C0-8A86-1333CDF16D8F</xxforms:uuid>
<xxforms:sequence>3</xxforms:sequence> <xxforms:action> <xxforms:event
name="xxforms-value"
source-control-id="elementControl$xforms-input-1*1">testing</xxforms:eve
nt> </xxforms:action> </xxforms:event-request>


XForms markup:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xf="http://www.w3.org/2002/xforms"  
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
        <head>
                <title>Javascript integration with repeats issue</title>
                <xf:model id="main-model">
                        <xf:instance id="test" xmlns="">
                                <root>
                                        <element>A</element>
                                        <element>B</element>
            </root>
                        </xf:instance>
                </xf:model>
        </head>
        <body>
                <xf:trigger id="changevalue-trigger">
                        <xf:label>Change value using JS
integration</xf:label>
                        <xf:action ev:event="DOMActivate">
                                <xxforms:script>
       
ORBEON.xforms.Document.setValue('elementControl$xforms-input-1*1',
'testing');
                                </xxforms:script>
                        </xf:action>
                </xf:trigger>  
                <xf:repeat id="element-repeat" nodeset="element">
                        <div>
                                <xf:input id="elementControl" ref=".">
                                        <xf:label>Element</xf:label>
                                </xf:input>
                        </div>  
                </xf:repeat>
                <fr:xforms-inspector/>
        </body>
</html>

-Stian


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Erik
Bruchez
Sent: 20 May 2012 01:43
To: [hidden email]
Subject: [ops-users] Re: Integration with JavaScript and
<xforms:repeat/>


> I've been experimenting with the JavaScript integration available in
Orbeon
> 3.9. My ultimate goal is to set instance data based on a call to a
JSON
> service, and the <xxforms:code/> element would be ideal for this, but
I
> don't think it's implemented yet? The feature is described here:
>
http://wiki.orbeon.com/forms/projects/client-side-api-for-custom-javascr
ipt-widgets

That's right, this is not implemented yet.

> I believe I have successfully derived the correct control ID to pass
for the
> parameter, because the control in the repeat does in fact get updated
> successfully in the browser. However no event is dispatched to the
Orbeon
> server to update the XForms instance (I did a HTTP trace with Firebug,
> comparing it with the working example without <xforms:repeat/>).
>
> The JavaScript I executed is:
>
ORBEON.xforms.Document.setValue('<portlet:namespace/>numberControl$xform
s-input-1*1',
> 'testing');
> My control is called "numberControl", I picked the full control name
out of
> the generated HTML source.
>
> Does anyone know if this is a known Orbeon 3.9 issue?

It is not a known issue, but unfortunately I don't know if it's
actually a bug without doing research. Can you see if the value change
event is present in the Ajax request sent to the server after you call
setValue()? Is an event sent at all?

-Erik


--
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