primefaces GMmap inside a dialog not rendering

和自甴很熟 提交于 2019-12-13 08:01:30

问题


I want to open a Gmap inside my jsf page, i tried these sample but it didn't work:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<script src="http://maps.google.com/maps/api/js?sensor=false"
    type="text/javascript"></script>
</h:head>
<body>
<ui:composition template="/WEB-INF/template/template.xhtml">
    <ui:define name="content">
        <p:commandButton type="button" icon="ui-icon-pin-s" value="Show Map"
            onclick="dlg.show()" />

        <p:dialog widgetVar="dlg" width="625" height="400" modal="true">
            <p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID"
                style="width:600px;height:400px" widgetVar="mymap" />
        </p:dialog>
    </ui:define>
</ui:composition>
</body>
</html>

回答1:


Your mistake is: in composition, you have to include <h:head></h:head> to apply css, but any code from that have not been loaded. You need to add script to /WEB-INF/template/template.xhtml

template.xhtml:

<h:head>
    // other here
    <script src="http://maps.google.com/maps/api/js?sensor=false"
    type="text/javascript"></script>
</h:head>

See also:understand the purpose of jsf ui:composition



来源:https://stackoverflow.com/questions/16368842/primefaces-gmmap-inside-a-dialog-not-rendering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!