【问题标题】:How to use Events push plugin in grails如何在 grails 中使用事件推送插件
【发布时间】:2013-10-08 00:24:16
【问题描述】:

我为我的项目尝试了以下设置,以使用事件推送插件http://grails.org/plugin/events-push向 UI 发送通知

main.gsp
----------
<html>
  <head>
    <r:require modules="grailsEvents"/>
    <r:script>
        grailsEvents.on('myTestEvent', function (data) {
            alert ("Testing data recieved : "+data)
        }, {});
    </r:script>
   </head>
</html>


MyTestController.groovy
------------------------
def testMyEvent() {
 event for:'myApp' topic:'myTestEvent' data:"Testing something"
}


BuildConfig.groovy
------------------

plugins {
    build ':platform-core:1.0.RC5'
    build ':events-push:1.0.M7'
    compile ':platform-core:1.0.RC5'
    runtime ':platform-core:1.0.RC5'
    compile ':events-push:1.0.M7'
    runtime ':events-push:1.0.M7'
}

MyEvents.groovy (grails-app/conf)
---------------    
    events = {    
        'myTestEvent' namespace : 'myApp', browser:true, browserFilter: { message, request ->
            println "myTestEvent event raised"
            return true // allows browser push on this topic
        }
    }

最初我遇到了问题,因为 events-push 插件无法找到氛围插件。所以我不得不在 grails home (&lt;grails_home&gt;/lib/jars/atmosphere-0.9.0RC3 and atmosphere-1.1.0-SNAPSHOT) 下手动复制粘贴。然后它开始编译项目。但是&lt;r:&gt; 标记没有被编译并抛出运行时错误为Error executing tag &lt;r:layoutResources&gt;: No module found with name [grailsEvents] 我无法找到有关如何使其工作的适当文档。有人可以指出逐步设置此插件并使其工作的正确方法吗? 我提到了这个Grails Events Push plugin not getting a response from server event,但我仍然无法让它工作。非常感谢任何帮助!!!

【问题讨论】:

    标签: grails notifications push grails-plugin gsp


    【解决方案1】:

    可能是this repository 帮助你。 看看..,.

    另请阅读 this 文档。

    而且你无法解决依赖气氛插件,因为你没有提到

    mavenRepo "https://oss.sonatype.org/content/repositories/snapshots/"
    

    在构建配置中的存储库块中。

    【讨论】:

    • 它解决了拉取依赖jar的问题。但是我必须在存储库mavenRepo "http://central.maven.org/maven2/"mavenRepo "https://oss.sonatype.org/content/repositories/snapshots/"下再添加一行。调用问题仍然存在,它没有通知UI。跨度>
    • 它正在通知,它正在浏览器控制台中打印日志。打开浏览器控制台。
    • 或者在 eventTesting/index 页面中做一些改变来查看页面中的效果,比如..,。 jQuery("#asd").html("Event should have been already fired..." + data); 成功的 ajax 行(页面的第 28 行)和 &lt;div id="asd"&gt;&lt;/div&gt; 在正文结束之前。
    • 不,即使我将控制台日志更改为正常警报消息,它也不会出现。但是我发现了问题,我将发布我的发现作为答案。感谢您的帮助@user1690588
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-31
    • 1970-01-01
    相关资源
    最近更新 更多