I get a trouble with the xforms.

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

I get a trouble with the xforms.

suneclipse
Hello!Now I have nearly finished a project based on ops.That is real great!So thank you very much!However,still I have encountered a little difficulty about the xforms.Our custommers want to make the web pages more dynamic.They want to drag some elements,drop them down,to express some information,and to submit the information to the server.And you have to show the shape again after the data have been saved to the db some time later.Well,if it is html+javascript,that will be easy.But now,for xforms,how to do this?At the beginning,I want to add some javascript,but I find I can't see the instance data without by a xforms:input.Well,can't I use javascript freely on the xforms?I mean,I can only express part of the communication scene by xforms,but when I want to use another part by xhtml+javascript,I find no language there to use to express.



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

Re: I get a trouble with the xforms.

Erik Bruchez
Administrator
 > Hello!Now I have nearly finished a project based on ops.That is real
 > great!So thank you very much!However,still I have encountered a
 > little difficulty about the xforms.Our custommers want to make the
 > web pages more dynamic.They want to drag some elements,drop them
 > down

It would be great integrate drag and drop within Orbeon Forms. But we
haven't yet done that. One idea was to make it (optionally) automatic
for things like repeats.

 > to express some information,and to submit the information to the
 > server.And you have to show the shape again after the data have been
 > saved to the db some time later.Well,if it is html+javascript,that
 > will be easy.But now,for xforms,how to do this?At the beginning,I
 > want to add some javascript,but I find I can't see the instance data
 > without by a xforms:input.Well,can't I use javascript freely on the
 > xforms?I mean,I can only express part of the communication scene by
 > xforms,but when I want to use another part by xhtml+javascript,I
 > find no language there to use to express.

You an use JavaScript in your page, and use the available APIs to
communicate with the XForms engine, see:

   http://www.orbeon.com/ops/doc/reference-xforms-ng#xforms-javascript

This is a fairly limited API for now.

-Erik

--
Orbeon Forms - XForms Everywhere
http://www.orbeon.com/blog/




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

Re: I get a trouble with the xforms.

ToddG
In reply to this post by suneclipse
I had the same question myself about custom javascript.  Not knowing the answer, I did some research in OPS-USERS ARCHIVE and found that if the <xforms input> has an "id" attribute, the <html:input> will have the same id (written by Alessandro Vernet for OPS 3.0 November 2005). 
 
If you have an input control with id="facilityID": 
    <xforms:input ref="ID" id="facilityID">
then in JavaScript you set the value of this input with:
    document.getElementById("facilityID").value = "34"
When this code runs, our JavaScript code notices that
you are programmatically modifying a value, it sends
an event to the server, and other controls bound to
the same node are updated.
 
As for programmatically submitting the form, I see (written by Erik Bruchez on October 2006) that:
 
For security reasons, you can't dispatch built-in events
(i.e. DOM events or XForms events, except DOMActivate,
DOMFocusIn and DOMFocusOut) from JavaScript, even if you
use xxforms:external-events. I realized that this was
not explicit in the doc so I updated it. If you use a
custom event instead, then things work. See attached.
 
and then he demonstrates programmatic submission as: 

 <xhtml:head>
    <xforms:model id="main-model" xxforms:external-events="foo-submit">            
        <xforms:instance id="data" xmlns=""><a>Hello</a></xforms:instance>
        <xforms:submission id="mySubmit" action="http://www.google.com" method="get"/>
        <xforms:send submission="mySubmit" ev:event="foo-submit"/>
    </xforms:model>
</xhtml:head>
<xhtml:body>
    <xhtml:p><xhtml:a href="javascript:ORBEON.xforms.Document.dispatchEvent('main-model','foo-submit')">Trigger the submission directly</xhtml:a></xhtml:p>
    <xforms:trigger id="trigger-submit">
        <xforms:label>Submit</xforms:label>
        <xforms:send submission="mySubmit" ev:event="DOMActivate"/>
    </xforms:trigger>
    <xhtml:p><xhtml:a href="javascript:ORBEON.xforms.Document.dispatchEvent('trigger-submit','DOMActivate')">Pretend to click button</xhtml:a></xhtml:p>
</xhtml:body>
Then I went to the OPS documentation and found section 9.3. "JavaScript Integration" which instructs:

In JavaScript, you get the current value of an XForms control
    var value = ORBEON.xforms.Document.getValue("myControl")
where myControl is the id of the XForms control, for instance: 
    <xforms:input id="myControl">.  

The analogous setValue() works as well.  I also found that custom javascript can be called from OPS XFORMS actions as demonstrated in section 9.4.2 of the documentation:
 
<xforms:action ev:event="xforms-value-changed">
  <xforms:setvalue ref=".">test</xforms:setvalue>
  <xxforms:script>var v = 2; myValueChanged(v);</xxforms:script>
</xforms:action>
An aside: The example doesn't demonstrate anything significant, what is 'v' anyway, wouldn't it be better to call ORBEON.xforms.Document.getValue() and pass it to my custom function?
 
I have not seen (yet) anything written on custom javascript manipulation of the XFORMS model directly (rather than indirectly through the view).  If it exists, I would hope it allowed for XPath indexing of the model, but I may be asking too much.  Are there other scenarios you can think of for accessing XFORMS via javascript?
 
Todd Gochenour
 
 
 
On 11/22/06, [hidden email] <[hidden email]> wrote:
Hello!Now I have nearly finished a project based on ops.That is real great!So thank you very much!However,still I have encountered a little difficulty about the xforms.Our custommers want to make the web pages more dynamic.They want to drag some elements,dropthem down,to express some information,and to submit the information to the server.And you have to show the shape again after the data have been saved to the db some time later.Well,if it is html+javascript,that will be easy.But now,for xforms,how to do this?At the beginning,I want to add some javascript,but I find I can't see the instance data without by a xforms:input.Well,can't I use javascript freely on the xforms?I mean,I can only express part of the communication scene by xforms,but when I want to use another part by xhtml+javascript,I find no language there to use to express.




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





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

Re: I get a trouble with the xforms.

Alessandro  Vernet
Administrator
On 11/25/06, Todd Gochenour <[hidden email]> wrote:
> I have not seen (yet) anything written on custom javascript manipulation of
> the XFORMS model directly (rather than indirectly through the view).  If it
> exists, I would hope it allowed for XPath indexing of the model, but I may
> be asking too much.  Are there other scenarios you can think of for
> accessing XFORMS via javascript?

Todd,

You are right: there is nothing at this point in Orbeon Forms that
would let you directly modify an XForms instance from JavaScript.
Right now, to modify the value of a node, you need to have a control
bound to that node and use the
ORBEON.xforms.Document.getValue/setValue functions.

For security and performance reasons, I think that it is reasonable to
keep the current situation as the default. But in the future, we could
have a system where you can decide to expose one or more instances to
the JavaScript code.

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
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
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet