-1

我想在我的 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>
4

1 回答 1

0

您的错误是:在组合中,您必须包含<h:head></h:head>应用 css,但尚未加载其中的任何代码。您需要将脚本添加到/WEB-INF/template/template.xhtml

模板.xhtml

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

另请参阅了解 jsf ui:composition 的用途

于 2013-05-04T02:37:53.093 回答