问题
I'm a noob learning Wicket/Jquery. I'm trying to access JavaScript (Jquery) variables from Wicket. Here's an example I'm working with:
Component slider = new WebMarkupContainer("slider").add(new SliderBehavior(
new SliderOptions().changeEvent("alert('clicked!')").orientation(Orientation.HORIZONTAL).min(10).max(100).value(20)));
I'm implementing here a jqwicket slider example. Instead of the "alert('clicked!')" event I would like to read the value of the slider to the java. All help appreciated!!!
回答1:
you have to combine jquery's "changeEvent" with the ajax request sending current slider value to your wicket component.
jqwicket contains example for doing this. for more information see AjaxSlider here:
http://code.google.com/p/jqwicket/source/browse/tags/jqwicket-demo-0.4/jqwicket-demo/src/main/java/net/javaforge/jqwicket/SliderPage.java
回答2:
https://github.com/wicketstuff/core/blob/master/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/ui/Page4Slider.java
来源:https://stackoverflow.com/questions/5139715/accessing-javascript-jquery-variables-from-apache-wicket