Wicket 1.5中的Javascript [英] Javascript in Wicket 1.5

查看:166
本文介绍了Wicket 1.5中的Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找Wicket 1.5完成以下任务的方式:

im looking for the Wicket 1.5 Way of doing the following tasks:

  1. 将外部.js文件从面板添加到页面的页眉.
  2. 在面板底部的页面底部添加<script>...</script>标记
  3. 在Body标签的onLoad事件中添加一些Javascript
  1. Add a external .js File to header of the Page from a Panel.
  2. Add a <script>...</script> Tag at Bottom of Page from a Panel
  3. Add some Javascript to the onLoad Event of the Body tag

在Wicket 1.2和1.3中有很多示例,但是这些API已经消失了. 关于Javascript/Ajax的任何出色的Wicket 1.5文章都很棒.

There are lots of examples how to do this in Wicket 1.2 and 1.3 but these API are gone. Any good Wicket 1.5 Articles aboutJavascript/Ajax would be great.

推荐答案

HaBaLeS自己发现了问题:

HaBaLeS found it out himself:

add(new Behavior(){
        private final ResourceReference SOME_JS = new JavaScriptResourceReference(ChartTestPage.class, "some.js");

            @Override
            public void renderHead(Component component, IHeaderResponse response) {
                response.renderOnDomReadyJavaScript("alert('hello')"); //on Load
                response.renderJavaScriptReference(SOME_JS); //include js file
                response.renderJavaScript("alert('world');", "somescript"); //<script> tag
            }


        });

这篇关于Wicket 1.5中的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆