Hi
I am trying to bring back results from a submission to Google (I find that the format to the REST API could be: http://www.google.com/search?hl=en&q=XForms). Right now, I do not seem to be getting back anything!! I have a textarea that I would like to populate with the results of my submission (a "get" submission to the REST API of google. In my code I have something like this: <xforms:submission id="submit" action="http://www.google.com/search? hl=en&q={instance('DataBack')/fe:q}&btnG=Search" method="get" replace="instance" instance="DataBack" separator="&"> <xforms:toggle case="busy" ev:event="xforms-submit" /> <xforms:toggle case="submit-error" ev:event="xforms-submit-error" /> <xforms:toggle case="done" ev:event="xforms-submit-done" /> </xforms:submission> and in my body, I have: <xforms:textarea ref="instance('DataBack')/fe:q"> <xforms:label>Data back:</xforms:label> <xforms:action ev:event="DOMActivate"> <xforms:send submission="submit"/> </xforms:action> </xforms:textarea> What is the best way to do this? thanks for any suggestions. |
Hi
I managed to get back results from a call to another REST server but it opens up a separate page. However I used replace="all". When I try "replace="instance" instance="DataBack" nothing happens. Is it possible to fill the contents of the textarea with the results from such a call. Should I be specifying a certain type of the data for the response I wish to get back to prepopulate my textarea? thanks
|
Administrator
|
In reply to this post by ilango_g
On Sun, Jul 6, 2008 at 7:47 AM, ilango_g <[hidden email]> wrote:
> I am trying to bring back results from a submission to Google (I find that > the format to the REST API could be: > http://www.google.com/search?hl=en&q=XForms). > Right now, I do not seem to be getting back anything!! > > I have a textarea that I would like to populate with the results of my > submission (a "get" submission to the REST API of google. I recommend you use the XForms Inspector to see what is returned by the submission. This will show you in "real time" what the values of your instances are. http://www.orbeon.com/blog/2007/02/02/orbeon-forms-instance-inspector/ If the submission doesn't change the instance to your liking, this is maybe because there was an error during the submission. If that is the case you should see something about it in the orbeon.log. In your case, most likely the issue is that the URL you have there does not return XML; it returns a web page, which might not be what you expected. AFAIK, Google doesn't have a REST API for search. They have an Ajax API, designed to be used in the browser, which is not what you need (even if you might be able to hack around it and use it from the server). Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet -- 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 |
Administrator
|
In reply to this post by ilango_g
What does Google send you back? Is it XML? If not, you can't use the
response to replace an instance. You can try replace="text" if you want to replace the content of an element or attribute with a text response. -Erik On Jul 6, 2008, at 8:48 AM, ilango_g wrote: > > Hi > I managed to get back results from a call to another REST server but > it > opens up a separate page. However I used replace="all". > When I try "replace="instance" instance="DataBack" nothing happens. > Is it possible to fill the contents of the textarea with the results > from > such a call. Should I be specifying a certain type of the data for the > response I wish to get back to prepopulate my textarea? > > thanks > > > ilango_g wrote: >> >> Hi >> I am trying to bring back results from a submission to Google (I >> find that >> the format to the REST API could be: >> http://www.google.com/search?hl=en&q=XForms). >> Right now, I do not seem to be getting back anything!! >> >> I have a textarea that I would like to populate with the results of >> my >> submission (a "get" submission to the REST API of google. >> >> In my code I have something like this: >> <xforms:submission id="submit" action="http://www.google.com/search? >> hl=en&q={instance('DataBack')/fe:q}&btnG=Search" >> method="get" >> replace="instance" instance="DataBack" separator="&"> >> <xforms:toggle case="busy" ev:event="xforms-submit" /> >> <xforms:toggle case="submit-error" >> ev:event="xforms-submit-error" /> >> <xforms:toggle case="done" ev:event="xforms-submit- >> done" >> /> >> </xforms:submission> >> >> and in my body, I have: >> <xforms:textarea ref="instance('DataBack')/fe:q"> >> <xforms:label>Data back:</xforms:label> >> <xforms:action ev:event="DOMActivate"> >> <xforms:send submission="submit"/> >> </xforms:action> >> </xforms:textarea> >> >> What is the best way to do this? >> >> thanks for any suggestions. >> >> > > -- > View this message in context: http://www.nabble.com/populating-an-instance-with-results-of-a-REST-submission-to-google-tp18302782p18303332.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > 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 Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- 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 |
Google does not send me back XML. You are right. I should consider replace="text" then.
|
In reply to this post by Erik Bruchez
Erik
I now have a RESTful server running on Tomcat that returns XML as the result of a database query to MySQL. The format of the URL which uses a parameterized query is below: http://localhost:8080/RestfulServer/<categoryName>/<databaseTableName>/ and this returns me an XML page. Now if I want to do a REST submission to this URL in my XForm, what could be the format of such a URL in the xforms:submission part in the XForm?
|
Administrator
|
Something like:
<xforms:submission serialize="false" method="get" resource="http://localhost:8080/RestfulServer/{XPath expression returning category name}/{XPath expression returning table name}/" replace="instance" instance="response-instance"/> -Erik On Jul 9, 2008, at 9:00 AM, ilango_g wrote: > > Erik > I now have a RESTful server running on Tomcat that returns XML as > the result > of a database query to MySQL. > > The format of the URL which uses a parameterized query is below: > > http://localhost:8080/RestfulServer/<categoryName>/ > <databaseTableName>/ > > and this returns me an XML page. > > Now if I want to do a REST submission to this URL in my XForm, what > could be > the format of such a URL in the xforms:submission part in the XForm? > > > Erik Bruchez wrote: >> >> What does Google send you back? Is it XML? If not, you can't use the >> response to replace an instance. >> >> You can try replace="text" if you want to replace the content of an >> element or attribute with a text response. >> >> -Erik >> >> On Jul 6, 2008, at 8:48 AM, ilango_g wrote: >> >>> >>> Hi >>> I managed to get back results from a call to another REST server but >>> it >>> opens up a separate page. However I used replace="all". >>> When I try "replace="instance" instance="DataBack" nothing happens. >>> Is it possible to fill the contents of the textarea with the results >>> from >>> such a call. Should I be specifying a certain type of the data for >>> the >>> response I wish to get back to prepopulate my textarea? >>> >>> thanks >>> >>> >>> ilango_g wrote: >>>> >>>> Hi >>>> I am trying to bring back results from a submission to Google (I >>>> find that >>>> the format to the REST API could be: >>>> http://www.google.com/search?hl=en&q=XForms). >>>> Right now, I do not seem to be getting back anything!! >>>> >>>> I have a textarea that I would like to populate with the results of >>>> my >>>> submission (a "get" submission to the REST API of google. >>>> >>>> In my code I have something like this: >>>> <xforms:submission id="submit" action="http://www.google.com/ >>>> search? >>>> hl=en&q={instance('DataBack')/fe:q}&btnG=Search" >>>> method="get" >>>> replace="instance" instance="DataBack" separator="&"> >>>> <xforms:toggle case="busy" ev:event="xforms-submit" /> >>>> <xforms:toggle case="submit-error" >>>> ev:event="xforms-submit-error" /> >>>> <xforms:toggle case="done" ev:event="xforms- >>>> submit- >>>> done" >>>> /> >>>> </xforms:submission> >>>> >>>> and in my body, I have: >>>> <xforms:textarea ref="instance('DataBack')/fe:q"> >>>> <xforms:label>Data back:</xforms:label> >>>> <xforms:action ev:event="DOMActivate"> >>>> <xforms:send submission="submit"/> >>>> </xforms:action> >>>> </xforms:textarea> >>>> >>>> What is the best way to do this? >>>> >>>> thanks for any suggestions. >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/populating-an-instance-with-results-of-a-REST-submission-to-google-tp18302782p18303332.html >>> Sent from the ObjectWeb OPS - Users mailing list archive at >>> Nabble.com. >>> >>> >>> -- >>> 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 >> >> -- >> Orbeon Forms - Web Forms for the Enterprise Done the Right Way >> http://www.orbeon.com/ >> >> >> >> -- >> 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 >> >> > > -- > View this message in context: http://www.nabble.com/populating-an-instance-with-results-of-a-REST-submission-to-google-tp18302782p18364058.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > 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 Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- 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 |
I am not very clear how to write this XPath expression, since the XML is not available as an XForm instance. (normally one is used to write instance(testdata)/data.. etc).
Is it like a relative path or something? For example, if the XML that Tomcat shows me being returned is: <test2> <person> <firstname>john</firstname> <lastname>doe</lastname> [hidden email] </person> </test2> What might be the XPath in the XForms submission? My answer seems to the following: http://localhost:8080/RestfulServer/lists/{/test2/person}/ Here 'lists' is a top level element in the config file that holds several path elements of which path name="person" is one and inside that element person is mapped as follows; <row-element>person</row-element> -I
|
In reply to this post by Alessandro Vernet
I changed the URL to my own little REST service running in Tomcat.
When tested on its own, it returns an XML page when I have something like http://localhost:8080/restserver/lists/person Here the 'person' element should map to a database table row-element. Now Erik advised me that I need to use an XPath expression to get to this element. Now, what I realize is: does the XML data from the server need to be pulled into the XForm instance? I was looking up the following on the internet: (Erik's own talk) http://www.flickr.com/services/rest/ ?method=flickr.photos.search &api_key=[key] &tags=mountains &per_page=12 XForms allows you to submit an XML document as URL parameters by configuring the xforms:submission element as follows: <xforms:submission id="sub-flickr" method="get" action="http://www.flickr.com/services/rest/" separator="&" replace="instance" instance="inst-rs"> And pointing to an XML document of the following form: <instanceData> <method>flickr.photos.search</method> <api_key>[key]</api_key> <tags>mountains</tags> <per_page>12</per_page> </instanceData> Should I do something like that?
|
Ilango, As I understand, this an attempt at backward compatibility, or simply compatibility with HTTP URLs. XForms will parse elements into name value pairs. Your example should work as you expect. And for the submission to work, it must respond with XML data and the content type must be an XML type, such as text/xml or application/xml, etc. OF will not attempt to process the response if it is not the right content-type. --Hank On Jul 9, 2008, at 2:40 PM, ilango_g wrote: > > I changed the URL to my own little REST service running in Tomcat. > When tested on its own, it returns an XML page when I have > something like > http://localhost:8080/restserver/lists/person > Here the 'person' element should map to a database table row- > element. Now > Erik advised me that I need to use an XPath expression to get to this > element. > > Now, what I realize is: does the XML data from the server need to > be pulled > into the XForm instance? > > I was looking up the following on the internet: (Erik's own talk) > http://www.flickr.com/services/rest/ > ?method=flickr.photos.search > &api_key=[key] > &tags=mountains > &per_page=12 > > XForms allows you to submit an XML document as URL parameters by > configuring > the xforms:submission element as follows: > > <xforms:submission id="sub-flickr" method="get" > action="http://www.flickr.com/services/rest/" > separator="&" replace="instance" instance="inst-rs"> > > And pointing to an XML document of the following form: > > <instanceData> > <method>flickr.photos.search</method> > <api_key>[key]</api_key> > <tags>mountains</tags> > <per_page>12</per_page> > </instanceData> > > Should I do something like that? > > > Alessandro Vernet wrote: >> >> On Sun, Jul 6, 2008 at 7:47 AM, ilango_g <[hidden email]> wrote: >>> I am trying to bring back results from a submission to Google (I >>> find >>> that >>> the format to the REST API could be: >>> http://www.google.com/search?hl=en&q=XForms). >>> Right now, I do not seem to be getting back anything!! >>> >>> I have a textarea that I would like to populate with the results >>> of my >>> submission (a "get" submission to the REST API of google. >> >> I recommend you use the XForms Inspector to see what is returned by >> the submission. This will show you in "real time" what the values of >> your instances are. >> >> http://www.orbeon.com/blog/2007/02/02/orbeon-forms-instance- >> inspector/ >> >> If the submission doesn't change the instance to your liking, this is >> maybe because there was an error during the submission. If that is >> the >> case you should see something about it in the orbeon.log. >> >> In your case, most likely the issue is that the URL you have there >> does not return XML; it returns a web page, which might not be what >> you expected. AFAIK, Google doesn't have a REST API for search. They >> have an Ajax API, designed to be used in the browser, which is not >> what you need (even if you might be able to hack around it and use it >> from the server). >> >> Alex >> -- >> Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise >> Orbeon's Blog: http://www.orbeon.com/blog/ >> Personal Blog: http://avernet.blogspot.com/ >> Twitter - http://twitter.com/avernet >> >> >> -- >> 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 >> >> >> ----- >> Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise >> http://www.orbeon.com/ >> >> > > -- > View this message in context: http://www.nabble.com/populating-an- > instance-with-results-of-a-REST-submission-to-google- > tp18302782p18371394.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > 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 NEES@UCSB Institute for Crustal Studies, University of California, Santa Barbara 805-893-8042 -- 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 |
Hank
The code that I have is as follows: The result I wanted which was to get data into my 'textarea' element (like firstname or lastname) did not happen: -------- <xforms:instance id="DataResponse"> <fe:person> <fe:lastname/> <fe:firstname></fe:firstname> <fe:email/> </fe:person> </xforms:instance> ----------------- <xforms:submission id="submit" action="http://localhost:9001/restserver/lists/{person}" method="get" replace="instance" xxforms:instance="instance('DataResponse')" separator="&"> <xforms:toggle case="busy" ev:event="xforms-submit" /> <xforms:toggle case="submit-error" ev:event="xforms-submit-error"/> <xforms:toggle case="done" ev:event="xforms-submit-done" /> </xforms:submission>
|
Administrator
|
On Wed, Jul 9, 2008 at 3:40 PM, ilango_g <[hidden email]> wrote:
> The code that I have is as follows: The result I wanted which was to get > data into my 'textarea' element (like firstname or lastname) did not happen: Is this what you see with the XForms Inspector? I.e. the instance that should receive the data is empty? Again, if this is the case, as mentioned, you should see an error in the logs telling you why the submission failed. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet -- 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 |
Administrator
|
In reply to this post by ilango_g
On Wed, Jul 9, 2008 at 11:51 AM, ilango_g <[hidden email]> wrote:
> For example, if the XML that Tomcat shows me being returned is: > > <test2> > <person> > <firstname>john</firstname> > <lastname>doe</lastname> > [hidden email] > </person> > </test2> > > What might be the XPath in the XForms submission? > My answer seems to the following: > http://localhost:8080/RestfulServer/lists/{/test2/person}/ http://localhost:8080/RestfulServer/lists/{/test2/person/firstname}/ If you want the URL to be: http://localhost:8080/RestfulServer/lists/john/ Does this make sense? Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet -- 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 |
Yes, it does.
|
In reply to this post by Alessandro Vernet
Actually, as an afterthought. I was thinking if I could replace {/test2/person}/ with some kind of XQuery. Is that possible?
|
Administrator
|
Not sure if that is what you mean, but the XForms engine only supports
XPath 2.0. It doesn't support XQuery, although that would be nice, since XQuery is an extension of XPath 2.0. In order to run XQuery, you must send your query to an XQuery engine, like Saxon (called from XPL), or eXist. -Erik On Jul 21, 2008, at 7:15 PM, ilango_g wrote: > > Actually, as an afterthought. I was thinking if I could replace > {/test2/person}/ with some kind of XQuery. Is that possible? > > > > Alessandro Vernet wrote: >> >> On Wed, Jul 9, 2008 at 11:51 AM, ilango_g <[hidden email]> >> wrote: >>> For example, if the XML that Tomcat shows me being returned is: >>> >>> <test2> >>> <person> >>> <firstname>john</firstname> >>> <lastname>doe</lastname> >>> [hidden email] >>> </person> >>> </test2> >>> >>> What might be the XPath in the XForms submission? >>> My answer seems to the following: >>> http://localhost:8080/RestfulServer/lists/{/test2/person}/ >> >> You would have: >> >> http://localhost:8080/RestfulServer/lists/{/test2/person/firstname}/ >> >> If you want the URL to be: >> >> http://localhost:8080/RestfulServer/lists/john/ >> >> Does this make sense? >> >> Alex >> -- >> Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise >> Orbeon's Blog: http://www.orbeon.com/blog/ >> Personal Blog: http://avernet.blogspot.com/ >> Twitter - http://twitter.com/avernet >> >> >> -- >> 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 >> >> >> ----- >> Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise >> http://www.orbeon.com/ >> >> > > -- > View this message in context: http://www.nabble.com/populating-an-instance-with-results-of-a-REST-submission-to-google-tp18302782p18581077.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > 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 Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- 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 |
Free forum by Nabble | Edit this page |