实现JavaScript事件到检票口 [英] Implementing javascript events to Wicket

查看:151
本文介绍了实现JavaScript事件到检票口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的RIA开发,并与<工作href="http://$c$c.google.com/p/jqwicket/source/browse/tags/jqwicket-demo-0.4/jqwicket-demo/src/main/java/net/javaforge/jqwicket/SliderPage.java"相对=nofollow>阿贾克斯滑块例如的。我无法弄清楚如何使用JavaScript事件工作。在这里,在实施例的onValueChanged事件是pimplemented $ P $。如何实现说onchange-或onSlider事件?

所有帮助很大AP preciated!

 公共抽象类AjaxSlider扩展WebMarkupContainer {

    私有静态最后长的serialVersionUID = 1L;

    公共AjaxSlider(字符串ID){
            超级(ID);
            super.setOutputMarkupId(真正的);
    }
    公共JQUIComponentBehaivor&LT; SliderOptions&GT; getSlideBehaviors(){
        列表行为= getBehaviors();
        对于(对象行为:行为){
            如果(行为的instanceof SliderBehavior)
                        返回(SliderBehavior)行为;
        }
        返回null;
    }


    公共抽象无效onValueChanged(AjaxRequestTarget目标,
                    INT为newValue);

    @覆盖
    保护无效onInitialize(){
            super.onInitialize();
            AbstractDefaultAjaxBehavior ajaxBehavior =
                新AbstractDefaultAjaxBehavior(){
                    私有静态最后长的serialVersionUID = 1L;

                    @覆盖
                    保护无效响应(AjaxRequestTarget目标){
                            字符串sliderValue = RequestCycle.get()调用getRequest()
                                            .getParameter(SV);
                            如果(Utils.isNotBlank(sliderValue)){
                                    onValueChanged(目标,Integer.valueOf(sliderValue));
                            }
                    }
            };
            super.add(ajaxBehavior);
            super.add(新SliderBehavior(新SliderOptions()
                            .changeEvent(wicketAjaxGet(
                                            ajaxBehavior,
                                            新MapBuilder&LT;字符串,对象&gt;()加(SV,
                                                            。JS(ui.value))建()))));
    }

}
 

解决方案

你给的例子添加一个事件处理程序change事件。这是什么事件处理程序的作用是issueing一个GET请求, ajaxBehavior 上面定义。行为然后提取从GET参数调用 onValueChanged

滑块值

您可以添加其他事件处理程序,就像这对 SliderOptions 。例如:

  .slideEvent(
    wicketAjaxGet(ajaxBehavior,
                  新MapBuilder&LT;字符串,对象&gt;()
                  。新增(SV,JS(ui.value))建()))))。
 

此处理程序应该调用Ajax的行为,用户移动滑块任意时间。

I'm new to ria-development and working with the Ajax Slider example. I can't figure out how to work with javascript events. Here in the example the onValueChanged-event is preimplemented. How do I implement say onchange- or onSlider-event?

All help greatly appreciated!

public abstract class AjaxSlider extends WebMarkupContainer {

    private static final long serialVersionUID = 1L;

    public AjaxSlider(String id) {
            super(id);
            super.setOutputMarkupId(true);
    }
    public JQUIComponentBehaivor<SliderOptions> getSlideBehaviors() {
        List behaviors = getBehaviors();
        for(Object behavior : behaviors){
            if(behavior instanceof SliderBehavior)
                        return (SliderBehavior) behavior;
        }
        return null;
    }


    public abstract void onValueChanged(AjaxRequestTarget target,
                    int newValue);

    @Override
    protected void onInitialize() {
            super.onInitialize();
            AbstractDefaultAjaxBehavior ajaxBehavior =
                new AbstractDefaultAjaxBehavior() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    protected void respond(AjaxRequestTarget target) {
                            String sliderValue = RequestCycle.get().getRequest()
                                            .getParameter("sv");
                            if (Utils.isNotBlank(sliderValue)) {
                                    onValueChanged(target, Integer.valueOf(sliderValue));
                            }
                    }
            };
            super.add(ajaxBehavior);
            super.add(new SliderBehavior(new SliderOptions()
                            .changeEvent(wicketAjaxGet(
                                            ajaxBehavior,
                                            new MapBuilder<String, Object>().add("sv",
                                                            js("ui.value")).build()))));
    }

}

解决方案

The example you gave adds an event handler for the change event. What this event handler does is issueing a GET request to the ajaxBehaviordefined above. The behavior then extracts the slider value from the GET parameters and calls onValueChanged.

You can add another event handler just like this to SliderOptions. For instance:

.slideEvent(
    wicketAjaxGet(ajaxBehavior,
                  new MapBuilder<String, Object>()
                  .add("sv",  js("ui.value")).build()))));

This handler should call the ajax behavior any time the user moves the slider.

这篇关于实现JavaScript事件到检票口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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