agorapulse / grails-facebook-sdk

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

Error after upgrate from 0.4.6 to 0.4.8 #37

Closed confile closed 11 years ago

confile commented 11 years ago

Version 0.4.6 works perfect, but when I switched to version 0.4.8

//      runtime ":facebook-sdk:0.4.6"
        compile ":facebook-sdk:0.4.8"

I got the console errors while running the app:

Uncaught ReferenceError: jQuery is not defined JyNeunFPYRKfafPVaUIzozjdHSkpOPWca7ioQKWp0ZN.js:1
(anonymous function) JyNeunFPYRKfafPVaUIzozjdHSkpOPWca7ioQKWp0ZN.js:1
Uncaught ReferenceError: $ is not defined hN7n3MT2KKJzLU3H4aeYrgLQo48CPn5gUOwXBWdQCbm.js:1
(anonymous function)

What do I have to change? Any idea? Nothing has changed and still Jquery is available as before.

benorama commented 11 years ago

It looks like jQuery is not defined. Can you check in your source code if it is inserted in your html head JS scripts?

Are you using the Cache Resources plugin? If you do, you might want to disable it to know the source of the error.

You can also check in the source code if the FB SDK is correctly initialized.

confile commented 11 years ago

As I wrote I use version 0.4.6 of your plugin and it is working. When I only change to 0.4.8 it does not work. Nothing else has changed. Yes I use Cache Resources plugin.

benorama commented 11 years ago

I'm sorry, but I can't reproduce your issue. This is what I did:

Could you give me some more context on how to reproduce this issue?

Thanks.

confile commented 11 years ago

@benorama I think I found what is going wrong. Here is what I use with 0.4.6

main layout at the bottom:

    <facebook:initJS appId="${grailsApplication.config.grails.plugin.facebooksdk.appId}" xfbml="${true}" locale="de_DE">
    </facebook:initJS>

This is not working anymore with 0.4.9 but if you delete locale="de_DE" it is working. So I guess that some error must be in the taglib. What do you think?

(In your docu http://benorama.github.com/grails-facebook-sdk/ref/tags/initJS.html it must be "simply insert initJS tag, after HTML tag and before ")

benorama commented 11 years ago

Indeed, you need to pass a java Locale (http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html). This is what we use to get current request locale.

<facebook:initJS
            appId="${facebookContext.app.id}"
            locale="${RequestContextUtils.getLocale(request)}"
            xfbml="${true}">
confile commented 11 years ago

@benorama where do I get RequestContextUtils in a Grails GSP? Do I have to add

import org.springframework.web.servlet.support.RequestContextUtils

in every Controller or is there a better way?

benorama commented 11 years ago

You are not using an IDE? Intellij IDEA is a must for Grails development. It will accelerate your development. For example, it will automatically insert in your GSP:

<%@ page import="org.springframework.web.servlet.support.RequestContextUtils" %>
confile commented 11 years ago

@benorama I am using GGTS. What about that?

benorama commented 11 years ago

GGTS is fine, but you might give a try to Intellij with the Free 30 days trial. It's like working on a PC and then on a Mac : you cannot go back once you're addicted... ;)

benorama commented 11 years ago

At the top of the GSP where you want to use RequestContextUtils

confile commented 11 years ago

Okay it is working thank you.