Any Tuts Out There?

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

Any Tuts Out There?

Randin
I was wondering if there was any other examples/tutorials out there other than the ones included in the git repository? Tweek is a bit too advanced for me. All I'm looking to do is learn how to take a URL from a db and return the json.
Reply | Threaded
Open this post in threaded view
|

Re: Any Tuts Out There?

n8han
Administrator
Dispatch isn't involved in db access, unless that db has an HTTP API like Couch, there is a bit of code here that gets at the content behind a URL:
http://databinder.net/dispatch/Stdout_Walkthrough

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Any Tuts Out There?

Randin
Thank you for the answer now I have a new question I modified one of the examples of your code but got this error.....

HelloWorld.scala:15: error: value ># is not a member of dispatch.Request
   http(db / "/fwo/IDV60901/IDV60901.94868.json"  ># { 'body ! str })
                                                  ^
one error found


Here is the code.....

import dispatch._
import dispatch.json._
import http._


class HelloWorld {
  val http = new Http
  val db = :/("www.bom.gov.au")
   http(db / "/fwo/IDV60901/IDV60901.94868.json"  ># { 'body ! str })

Reply | Threaded
Open this post in threaded view
|

Re: Any Tuts Out There?

n8han
Administrator
Randin [via Databinder] wrote:
> Thank you for the answer now I have a new question I modified one of the
> examples of your code but got this error.....
>
> HelloWorld.scala:15: error: value ># is not a member of dispatch.Request
>    http(db / "/fwo/IDV60901/IDV60901.94868.json"  ># { 'body ! str })

You're missing one import:
import dispatch.json.JsHttp._

(I know it's a lot of imports, but they're necessary so that the HTTP
and json modules can be used independently.)

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Any Tuts Out There?

Randin
Bah, it's there, I had the Ide pruned the unused Imports before I cut it, seems it's not seeing the import, very sorry. Here is the complete one, as you'll see I tried alot of things....


import dispatch._
import net.liftweb._
import dispatch.json._
import http._
import net.liftweb.json._
import liftjson._
import org.apache.http.client.utils.URIUtils
import org.apache.http.client.methods.HttpGet

class HelloWorld {
  val http = new Http
  val db = :/("www.bom.gov.au")
   http(db / "/fwo/IDV60901/IDV60901.94868.json"  ># { 'body ! str })
}

Reply | Threaded
Open this post in threaded view
|

Re: Any Tuts Out There?

n8han
Administrator
> Bah, it's there, I had the Ide pruned the unused Imports before I cut it, seems it's not seeing the import, very sorry. Here is the complete one, as you'll see I tried alot of things....
>
>
> import dispatch._
> import net.liftweb._
> import dispatch.json._
> import http._
> import net.liftweb.json._
> import liftjson._
> import org.apache.http.client.utils.URIUtils
> import org.apache.http.client.methods.HttpGet
>

I guess what we need most is a rundown of the different modules. There are two json interfaces built into Dispatch that support the ># operator:

dispatch-http-json: uses the parser in dispatch-json
dispatch-lift-json: uses lift-json through a separate dependency

In the code below you're using the extractor syntax, so dispatch-lift-json should not be on the classpath at all and there shouldn't be any lift imports.

> class HelloWorld {
>   val http = new Http
>   val db = :/("www.bom.gov.au")
>    http(db / "/fwo/IDV60901/IDV60901.94868.json"  ># { 'body ! str })
> }
>
>
>
> View message @ http://n2.nabble.com/Any-Tuts-Out-There-tp3977778p4008999.html 
> To start a new topic under Dispatch, email [hidden email]
> To unsubscribe from Dispatch, click here.
>

Reply | Threaded
Open this post in threaded view
|

Re: Any Tuts Out There?

Randin
Ah, yes, I pluged into a basic lift build at one time, would it matter I still had it importing, from what you said I also was importing the correct one although both are greying out in Intellij.