You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Stette <ja...@gmail.com> on 2007/11/06 19:04:55 UTC

gmap2 and map creation

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

Re: gmap2 and map creation

Posted by Jan Stette <ja...@gmail.com>.
On 07/11/2007, Martin Funk <fu...@arcor.de> wrote:
>
> >
> sorry I was just to tired yesterday look into that any deeper.


No problem, of course!  :-)


I just committed a patch. Could you check if it suits your needs?


The patch adds checks for "isAttached()" in some operations, but not all.
So I was still getting some similar errors, for example in GMap2.addControl
().

I've worked around this so far by applying a patch in GMap2, adding the
middle line:

        map = new WebMarkupContainer("map");
        map.setMarkupId("gmapInternalMarkupId"); // Work around problem of
non-attached component
        map.setOutputMarkupId(true);

While this is a bit of a hack, could the problem be better fixed in a
similar way?  That would avoid having to remember to do the check for every
operation in GMap2.

Also could you check if the codechange in the ManyPanel is asking for
> the same as your code?


Looks like it yes, but as discussed above, it only calls setZoom() and not
all the other operations that may be called on the component before it's
added into the page hierarchy.

Regards,
Jan

Re: gmap2 and map creation

Posted by Martin Funk <fu...@arcor.de>.
Jan Stette schrieb:
> I'm pretty sure I'm using the latest version:
>   
sorry I was just to tired yesterday look into that any deeper.

I just committed a patch. Could you check if it suits your needs?
Also could you check if the codechange in the ManyPanel is asking for 
the same as your code?


Good night,

Martin
> $ svn info
> Path: .
> URL:
> https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-contrib-gmap2
> Repository Root:
> https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff
> Repository UUID: ef7698a4-5110-0410-9fc6-c7eb3693863f
> Revision: 3219
> Node Kind: directory
> Schedule: normal
> Last Changed Author: funkattack
> Last Changed Rev: 3149
> Last Changed Date: 2007-10-23 21:44:10 +0100 (Tue, 23 Oct 2007)
>
> Actually, that stack trace might have been misleading as I had been playing
> around with the code in GMap2... Here's a stack trace with the original
> version:
>
> 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.getJSsetCenter(GMap2.java:424)
>     at wicket.contrib.gmap.GMap2.setCenter(GMap2.java:353)
>
> Jan
>
>
>
> On 06/11/2007, Martin Funk <fu...@arcor.de> wrote:
>   
>> Hi Jan,
>>
>>     
>>> 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)
>>>
>>>
>>> (This is with Wicket 1.3 beta 4, and the head of gmap2)
>>>
>>>       
>> Looking at the line numbers I'd ask, are you sure you are running the
>> latest wicket-contrib-gmap2?
>>
>> like
>>
>> svn info
>> Pfad: .
>> URL:
>>
>> https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-contrib-gmap2
>> Basis des Projektarchivs:
>> https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff
>> UUID des Projektarchivs: ef7698a4-5110-0410-9fc6-c7eb3693863f
>> Revision: 3219
>> Knotentyp: Verzeichnis
>> Plan: normal
>> Letzter Autor: funkattack
>> Letzte geänderte Rev: 3149
>> Letztes Änderungsdatum: 2007-10-23 22:44:10 +0200 (Di, 23 Okt 2007)
>>
>> Also the description sounds like something we might have covered in the
>> one of the last updates.
>>
>> Have fun,
>>
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: gmap2 and map creation

Posted by Jan Stette <ja...@gmail.com>.
I'm pretty sure I'm using the latest version:

$ svn info
Path: .
URL:
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-contrib-gmap2
Repository Root:
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff
Repository UUID: ef7698a4-5110-0410-9fc6-c7eb3693863f
Revision: 3219
Node Kind: directory
Schedule: normal
Last Changed Author: funkattack
Last Changed Rev: 3149
Last Changed Date: 2007-10-23 21:44:10 +0100 (Tue, 23 Oct 2007)

Actually, that stack trace might have been misleading as I had been playing
around with the code in GMap2... Here's a stack trace with the original
version:

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.getJSsetCenter(GMap2.java:424)
    at wicket.contrib.gmap.GMap2.setCenter(GMap2.java:353)

Jan



On 06/11/2007, Martin Funk <fu...@arcor.de> wrote:
>
> Hi Jan,
>
> > 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)
> >
> >
> > (This is with Wicket 1.3 beta 4, and the head of gmap2)
> >
>
> Looking at the line numbers I'd ask, are you sure you are running the
> latest wicket-contrib-gmap2?
>
> like
>
> svn info
> Pfad: .
> URL:
>
> https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-contrib-gmap2
> Basis des Projektarchivs:
> https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff
> UUID des Projektarchivs: ef7698a4-5110-0410-9fc6-c7eb3693863f
> Revision: 3219
> Knotentyp: Verzeichnis
> Plan: normal
> Letzter Autor: funkattack
> Letzte geänderte Rev: 3149
> Letztes Änderungsdatum: 2007-10-23 22:44:10 +0200 (Di, 23 Okt 2007)
>
> Also the description sounds like something we might have covered in the
> one of the last updates.
>
> Have fun,
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: gmap2 and map creation

Posted by Martin Funk <fu...@arcor.de>.
Hi Jan,

> 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)
>
>
> (This is with Wicket 1.3 beta 4, and the head of gmap2)
>   

Looking at the line numbers I'd ask, are you sure you are running the 
latest wicket-contrib-gmap2?

like

svn info
Pfad: .
URL: 
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-contrib-gmap2
Basis des Projektarchivs: 
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff
UUID des Projektarchivs: ef7698a4-5110-0410-9fc6-c7eb3693863f
Revision: 3219
Knotentyp: Verzeichnis
Plan: normal
Letzter Autor: funkattack
Letzte geänderte Rev: 3149
Letztes Änderungsdatum: 2007-10-23 22:44:10 +0200 (Di, 23 Okt 2007)

Also the description sounds like something we might have covered in the 
one of the last updates.

Have fun,

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org