You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by solled <so...@msn.com> on 2008/06/16 18:36:33 UTC
How do I pass back data from HTML (javascript) to my Java code
Hi,
How do I get data generated by javascript functions to my Java code using
Wicket. For example, I have the following javascript code:
<script type="text/javascript">
var map;
var gdir;
var geocoder = null;
var addressMarker;
var mileage;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
setDirections("", "", "en_US");
onGDirectionsLoad();
}
}
function setDirections(fromAddress, toAddress, locale) {
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": locale });
}
function onGDirectionsLoad(){
// Use this function to access information about the latest load()
// results.
document.getElementById("getDistance").innerHTML = gdir.getDistance().html;
}
</script>
How do I pass the getDistance value in function onGDirectionsLoad() to my
java code?
thanks for any help.
--
View this message in context: http://www.nabble.com/How-do-I-pass-back-data-from-HTML-%28javascript%29-to-my-Java-code-tp17868387p17868387.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How do I pass back data from HTML (javascript) to my Java code
Posted by richardwilko <ri...@gmail.com>.
You could create an abstractDefaultAjaxBehaviour in your page, then do an
ajax get onto it, appending your parameter as a url parameter, then get your
parameter from the request in java. or you could have a wicket page, and do
an ajax get on that, appending your parameter as a url parameter, and get
your parameter from the page parameters.
Admittedly both ways seem a little hacky but i cant think of another way.
My presentation on google maps from the london wicket user group may be
helpful, as may the one about a gallery (not mine):
http://code.google.com/p/londonwicket/downloads/list
hope that helps
solled wrote:
>
> Hi,
>
> How do I get data generated by javascript functions to my Java code using
> Wicket. For example, I have the following javascript code:
>
> <script type="text/javascript">
>
> var map;
> var gdir;
> var geocoder = null;
> var addressMarker;
> var mileage;
>
> function initialize() {
> if (GBrowserIsCompatible()) {
> map = new GMap2(document.getElementById("map_canvas"));
> gdir = new GDirections(map,
> document.getElementById("directions"));
> GEvent.addListener(gdir, "load", onGDirectionsLoad);
> GEvent.addListener(gdir, "error", handleErrors);
>
> setDirections("", "", "en_US");
>
> onGDirectionsLoad();
> }
> }
>
> function setDirections(fromAddress, toAddress, locale) {
> gdir.load("from: " + fromAddress + " to: " + toAddress,
> { "locale": locale });
> }
>
> function onGDirectionsLoad(){
> // Use this function to access information about the latest load()
> // results.
>
> document.getElementById("getDistance").innerHTML =
> gdir.getDistance().html;
>
> }
> </script>
>
>
>
> How do I pass the getDistance value in function onGDirectionsLoad() to my
> java code?
>
> thanks for any help.
>
>
--
View this message in context: http://www.nabble.com/How-do-I-pass-back-data-from-HTML-%28javascript%29-to-my-Java-code-tp17868387p17868825.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org