I have another question related to wicket-contrib-gmap2:

I'm trying to create a new GMap2 component in response to an AJAX request.
My code looks much like the code in the constructor of class
wicket.contrib.examples.gmap.controls.HomePage(), in the gmap2 examples,
which says:

        final GMap2 topMap = new GMap2("topPanel", LOCALHOST);
        topMap.setZoom(10);

When I try to make calls such as setZoom() on the newly created GMap2, an
exception is thrown:

Caused by: org.apache.wicket.WicketRuntimeException: This component is not
(yet) coupled to a page. It has to be able to find the page it is supposed
to operate in before you can call this method (Component#getMarkupId)
    at org.apache.wicket.Component.getMarkupId(Component.java:1201)
    at wicket.contrib.gmap.GMap2.getJSinvoke(GMap2.java:399)
    at wicket.contrib.gmap.GMap2.getJSsetZoom(GMap2.java:424)
    at wicket.contrib.gmap.GMap2.setZoom(GMap2.java:353)

For various reasons, it's not easy for me to add this component into the
page hierarchy at the time of creation - it's basically being created by a
factory class that doesn't necessarily know about the rest of the world.
The example code works because the creation is not in an Ajax request, so
this code path isn't hit.

It looks like most of the operations on GMap2 require a markup id in this
way.  I tried setting the markup id manually on the GMap2 instance, but that
didn't help; it's the markup id of the contained WebMarkupContainer (the
"map" member) that's looked for:

    public String getJSinvoke(String invocation)
    {
        return "Wicket.maps['" + map.getMarkupId() + "']." + invocation +
";";
    }

Any suggestions for how I can get around this?  It does seem like a
reasonable thing to do, I think?  I haven't seen this kind of problem with
any other Wicket components that are created in the same way...

(This is with Wicket 1.3 beta 4, and the head of gmap2)

Many thanks,
Jan

Reply via email to