agorapulse / grails-facebook-sdk

Facebook SDK Grails Plugin
http://agorapulse.github.com/grails-facebook-sdk/guide
30 stars 13 forks source link

Can't use facebook.app.id in a 404 error mapping page #4

Closed aldrinm closed 12 years ago

aldrinm commented 12 years ago

Mapped a 404 response code to an error.gsp. Referring facebook.app.id causes in that error.gsp causes an error, "No such property: app for class: org.codehaus.groovy.grails.web.taglib.NamespacedTagDispatcher"

URLMapping:
    "404" (view: '/error')

error.gsp:
    <facebook:initJS appId="${facebook.app.id}" >
        <g:pageProperty name="page.afterFBInitJS" >
    </facebook:initJS>
benorama commented 12 years ago

Grails filters will only fire when the URI is mappable to a Grails controller and action. That's why the FacebookSdkFilters is not executed in your case. Sorry, this is a Grails limitation...

404 should be "dumb" views, but if required, you might want to access facebookApp and facebookAppService from error.gsp : http://stackoverflow.com/questions/2510929/problem-calling-grails-service-from-gsp

Here is the code executed in FacebookSdkFilters :

request.facebook = [:]
request.facebook.app = facebookApp
request.facebook.user = new FacebookUser()
request.facebook.authenticated = false

FacebookUser facebookUser = new FacebookUser()
if (request.facebook.app.id) {
  request.facebook.user.id = facebookAppService.getUserId()
  if (request.facebook.user.id) {
    request.facebook.authenticated = true
  }
}
benorama commented 11 years ago

Hi aldrinm,

FYI, I'm going to release pretty soon Facebook SDK V0.4. The main objective was to "clean" the SDK code which was pretty messy (since it was a port of PHP code...). The other objective was to be able to support multiple Facebook app within a single Grails app. It's pretty big refactoring of the code base.

Unfortunately, it won't be backward compatible with V0.3.* ... FacebookApp, FacebookSdkFilters and FacebookAppService have been deprecated and replaced by a single FacebookContext bean: a cleaner approach to access Facebook context info (current app, user, page...) So if you use any of them, you might have to do some refactoring on your app.

I'm looking for some feedback, if you have some time to play with it, it's on "develop" branch. You can download the updated docs here : http://cl.ly/2q2T300G201J

Thanks !

Ben