本文介绍了< p:gmap组件的绑定不起作用-Primefaces 3.4.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用了p:gmap组件,但是当我尝试使用binding属性在Bean中引用GMap时,它不起作用并且地图也没有显示.

JSF代码:

<p:gmap binding="#{mapBean.map}" center=" -26.9995, -49.686" zoom="11" type="ROADMAP" />

后备bean代码:

public GMap getMap() {
    map = new GMap();
    map.setCenter("-26.9995, -49.686");
    map.setZoom(11);
    map.setType("ROADMAP");
    map.setModel(geoModel);
    map.setStyle("width:850px;height:450px");
    map.setWidgetVar("vMap");
    return map;
}

当我使用此组件而未绑定时,它可以正常工作...

Primefaces版本3.4.1;Glassfish 3.1.2.2

有什么主意吗?

谢谢

解决方案

我发现了与您相关的相同问题...当我使用绑定属性在托管Bean中引用GMap时,不会呈现该地图. /p>

我注意到文件gmap.js尚未加载,因此也未渲染GMap.

我没有找到导致此问题的原因,但是我找到了解决问题的方法,但这不是一种优雅的方法. :D

将gmap.js复制到项目目录结构的文件系统后,我在xhtml文件中添加了这一行.

<h:head>
    ...
    <h:outputScript library="primefaces" name="gmap/gmap.js" />
    ...
</h:head>

希望对您有所帮助!祝你好运! :D

I'm using the p:gmap component in an application, but when I try to use the binding attribute to reference a GMap in a bean, it doesn't work and the map is not showed.

JSF code:

<p:gmap binding="#{mapBean.map}" center=" -26.9995, -49.686" zoom="11" type="ROADMAP" />

Backing bean code:

public GMap getMap() {
    map = new GMap();
    map.setCenter("-26.9995, -49.686");
    map.setZoom(11);
    map.setType("ROADMAP");
    map.setModel(geoModel);
    map.setStyle("width:850px;height:450px");
    map.setWidgetVar("vMap");
    return map;
}

When I used this component without binding, and it worked normally...

Primefaces version 3.4.1;Glassfish 3.1.2.2

Any idea?

Thanks

解决方案

I found the same problem related for you... When I use the binding attribute to reference GMap in a Managed Bean, the map isn't rendered.

I noticed that the file gmap.js was not been loading and for this reason GMap was not been rendered too.

I didn't get to find out the cause of this problem, but I found a way to solve it, but is not an elegant way. :D

I added this line in my xhtml file after copy gmap.js to file system of directory structure of the project.

<h:head>
    ...
    <h:outputScript library="primefaces" name="gmap/gmap.js" />
    ...
</h:head>

I hope this help you! Good luck! :D

这篇关于&lt; p:gmap组件的绑定不起作用-Primefaces 3.4.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 22:53