【问题标题】:primefaces GMmap inside a dialog not rendering对话框内的primefaces GMmap未呈现
【发布时间】:2013-04-28 10:38:22
【问题描述】:

我想在我的 jsf 页面中打开一个 Gmap,我尝试了这些示例,但没有成功:

<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>

【问题讨论】:

    标签: google-maps jsf jsf-2 primefaces


    【解决方案1】:

    您的错误是:在组合中,您必须包含 &lt;h:head&gt;&lt;/h:head&gt; 才能应用 css,但尚未加载其中的任何代码。您需要将脚本添加到/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>
    

    另见understand the purpose of jsf ui:composition

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-26
      • 2014-11-15
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多