使用 JQWicket 的 AjaxSlider
我将再次通过询问基础知识来展示我的新手。此后续问题与线程相关: Accessing javascript (Jquery) Variables from Apache Wicket
我开始使用 AjaxSlider 示例,我将值发送回给我,但是如何使用其他参数再次渲染滑块组件?我想更改可以分配给该 AjaxSlider 的最大值。有没有关于这个的api?
[我的目标是创建一个带有百分比(从 0 到 100)的标签和两个滑块,您可以使用它们随意分配百分比。例如让用户在男性和女性之间分配金钱]这是我当前正在使用的代码:
add(new AjaxSlider("ajaxSlider1") {
private static final long serialVersionUID = 1L;
@Override
public void onValueChanged(AjaxRequestTarget target, int newValue) {
System.out.println("selected_value: "+newValue);
}
});
原始示例可以在这里找到:AjaxSliderExample
感谢所有帮助,谢谢读到这里!
Once again I'm gonna show my noobiness by asking about the basics. This follow-up question is related to thread: Accessing javascript (Jquery) variables from Apache Wicket
I started to work with the AjaxSlider example, I have the value send back to me, but how do I render the slider component again with other parameters? I would like to change the maximum value that can be assigned to that AjaxSlider. Is there an api somewhere about this?
[the object for me is to create a label with percentages (from 0 to 100) and two sliders with which you can distribute the percentage as you please. E.g. let the user distribute money among men and women] This is the code I'm working with currently:
add(new AjaxSlider("ajaxSlider1") {
private static final long serialVersionUID = 1L;
@Override
public void onValueChanged(AjaxRequestTarget target, int newValue) {
System.out.println("selected_value: "+newValue);
}
});
The original example can be found here: AjaxSliderExample
Appreciate all the help and thank you for reading this far!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须从
onValueChanged(..)
方法中访问底层 jqwicket 的SliderBehavior
(例如,在onValueChanged(..)
方法中为SliderBehavior
创建一个 getter >AjaxSlider 或使其受到保护)。之后,您可以像这样更改滑块的最大值:通过这种方式,您可以操作所有可用的滑块选项(请参阅 jqwicket 的
SliderOptions
类或原始 JQuery UI Slider 文档)。笔记!您也可以继承 jqwicket 的预定义
SliderWebMarkupContainer
来实现相同的结果。You have to access the underlying jqwicket's
SliderBehavior
from within theonValueChanged(..)
method (e.g. create a getter for theSliderBehavior
in theAjaxSlider
or make it protected). After this you can change the maximum value of the slider like this:In this way you can manipulate all available slider options (see jqwicket's
SliderOptions
class or original JQuery UI Slider documentation).Note! You can alternatively inherit jqwicket's predefined
SliderWebMarkupContainer
to achieve the same result.我不熟悉
AjaxSlider
,但是如果 Ajax 请求想要重新渲染任何组件,则必须将该组件添加到AjaxRequestTarget
中。(对此的限制是,只有具有标记 id 的组件才能通过 Ajax 请求重绘。这意味着您在创建这些组件时必须调用
setOutputMarkupId( true )
。I'm not familiar with
AjaxSlider
, however if an Ajax request wants to re-render any component, the component has to be added to theAjaxRequestTarget
.(A restriction on this is that only components with markup ids can be redrawn by an Ajax request. This means that you have to call
setOutputMarkupId( true )
on these components when you create them.