TheCoder4eu / BootsFaces-OSP

BootsFaces - Open Source Project
Apache License 2.0
246 stars 102 forks source link

collapsed b:panel p:gmap #720

Closed chongma closed 4 years ago

chongma commented 7 years ago

if a b:panel is collapsed on page load then a p:gmap inside does not get rendered.

stephanrauh commented 7 years ago

Sounds like the same bug as #205. Can you give us a reproducer?

chongma commented 7 years ago

ok i pushed to my test project https://github.com/chongma/test. choose test-> gmap

stephanrauh commented 7 years ago

I have some difficulties to get the project up and running. Which application server do you use?

chongma commented 7 years ago

I used TomEE 7.0.2 but added the same dependencies as there​ were on the BootsFacesWeb project to try to make it compatible

stephanrauh commented 7 years ago

OK, I've got a TomEE 7.0.2 on my PC, so I just have to re-import it into Eclipse.

I don't understand why your project doesn't work with my Wildfly. Probably because I used the wrong URL, but still, it shouldn't be that difficult to find out the URL, should it?

chongma commented 7 years ago

I had never heard of wildfly before now. Which URL was wrong? Did the server start ok? Maybe it is the faces version or web deployment descriptor because they are the only bits i added

stephanrauh commented 7 years ago

Wildfly is the open source version of JBoss. It's one of the leading JavaEE application servers. But if you ask me, it's also an application server that adds a lot of complexity to your program. At least from a developers perspective. From the operations point of view, that's probably a lot of necessary features.

Be that as it may, I've managed to find out the real URL, and I think I can confirm your bug. I don't have a valid Google maps API key, but even so, I think the page shouldn't look like so: image

I guess the lower panel should also show the error message.

chongma commented 7 years ago

Ah well i have heard of JBoss of course. Yes that is exactly how the test looks on my system too. Let me know if you need me to do anything else

stephanrauh commented 7 years ago

As it turns out, this doesn't work with the PrimeFaces p:panel, either. PrimeFaces implements code ensuring that that code works, but for some reason, it doesn't.

My best effort so far is this:

<b:panel rendered="#{gmapBean.mapModel ne null}" title="Map"
     collapsed="true" 
     onexpanded="PrimeFaces.widgets.hiddenMap._render();">
      <p:gmap center="#{gmapBean.latLng.lat},#{gmapBean.latLng.lng}"
           zoom="15" type="HYBRID" style="width:250px;height:250px;"
           model="#{gmapBean.mapModel}" widgetVar="hiddenMap"/>
</b:panel>

The Gmap widget is given a widgetVar, and the internal _render() method is called after expanding the panel.

Problem: the map doesn't show. On the plus side, there's the error message indicating the I don't have the API key, so it seems to be the right direction.

In theory, there's another, better approach: wrap the Gmap widget in a div like so:

<div class="ui-hidden-container" id="gmapwrapperId">
    <p:gmap ... />
</div>

The problem with the second approach is that it does even less. The widget is initialized on the PrimeFaces side, but there's not even an error message.

stephanrauh commented 7 years ago

@Tandraschko: does this pique your curiosity? It seems the deferred initialization of <p:gmap> doesn't work if the widget is in an inactive tab or a collapsed panel. It's not surprising it doesn't work with BootsFaces, but IMHO this pure-PrimeFaces code shou'd work, shouldn't it?

<p:panel rendered="#{gmapBean.mapModel ne null}" title="Map" header="Map"
    collapsed="true" toggleable="true">
        <p:gmap center="#{gmapBean.latLng.lat},#{gmapBean.latLng.lng}"
            zoom="15" type="HYBRID" style="width:100%;height:250px;"
            model="#{gmapBean.mapModel}" />
</p:panel>

Also see http://stackoverflow.com/questions/19067780/primefaces-gmap-not-rendered-when-style-display-none.

tandraschko commented 7 years ago

Yup, should actually work. Not sure if the problem is the panel or the gmap ;)

geopossachs commented 5 years ago

I write for the same error a solution by b:tabView #205 The solution will also work in the same way for b:panel :-)

geopossachs commented 4 years ago

i retest it, the bug was fixed with version 1.4.2