2012-05-21 2 views
1

JSF2에서 작업 중이며 gmap 객체로지도를 표시하고 싶습니다. 내가 본 것처럼 gmap 객체는 richfaces 4.x와 더 이상 존재하지 않으므로 gmap4jsf.jar을 가져 와서 내지도를 렌더링하려고 시도했습니다 ...JSF에 gmap 객체로지도를 표시하려고합니다.

예제를 사용하려면 Richfaces 데모를 여기에서 : Richfaces live demo

rich : 패널에서 jsf 요소로 제어 (유형, 확대/축소 ... 변경)하고 싶다면 Firebug에서 오류가 발생합니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><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:rich="http://richfaces.org/rich" 
xmlns:m="http://code.google.com/p/gmaps4jsf/"><h:head><title>JSF 2.0: Ajax Support</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<link href="../css/style.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=myPersonnalKeyIsWrittenHere"></script> 
<script type="text/javascript" 
    src="http://code.jquery.com/jquery-1.7.1.js"></script> 

<style>.optionList {height: 30px;}</style></h:head><h:body> 
<div id="container"> 
    <ui:include src="tpl/menu.xhtml" /> 
    <h1>Gmap4Jsf</h1> 
    <div align="center"> 

     <f:view contentType="text/html"> 
      <h:panelGrid columns="2"> 
       <h:form id="mapform" prependId="false"> 
        <m:map var="map" mapVar="map" gmapKey="#{gmapBean.gmapkey}" id="map" /> 
       </h:form> 
       <h:panelGroup> 
        <h:form> 

         <rich:tabPanel switchType="ajax" width="350" height="400"> 
          <rich:tab label="Using Google Map API"> 
           <h:panelGrid columns="2" columnClasses="optionList"> 
            <h:outputText value="Controls:" /> 
            <h:panelGroup> 
             <a href="javascript: void 0" onclick="map.hideControls()">Hide</a> 
             <a href="javascript: void 0" onclick="map.showControls()">Show</a> 
             <br /> 
            </h:panelGroup> 

            <h:outputText value="Zoom:" /> 
            <rich:inputNumberSlider id="zoom" showInput="false" 
             minValue="1" maxValue="18" value="#{gmapBean.zoom}" 
             onchange="map.setZoom(this.value)" /> 


            <h:outputText value="Map Type:" /> 
            <h:panelGroup> 
             <a href="javascript: void 0" 
              onclick="map.setMapType(G_NORMAL_MAP)">Normal</a> 
             <a href="javascript: void 0" 
              onclick="map.setMapType(G_SATELLITE_MAP)">Satellite</a> 
             <a href="javascript: void 0" 
              onclick="map.setMapType(G_HYBRID_MAP)">Hybrid</a> 
             <br /> 
            </h:panelGroup> 

           </h:panelGrid> 
          </rich:tab> 

          <rich:tab label="Using Ajax with JSON"> 
           <rich:dataGrid var="place" value="#{gmapBean.point}" 
            columns="2"> 
            <h:graphicImage onclick="showPlace('#{place.id}')" 
             style="cursor:pointer" value="resource://#{place.pic}" /> 
           </rich:dataGrid> 
          </rich:tab> 
         </rich:tabPanel> 
        </h:form> 
       </h:panelGroup> 
      </h:panelGrid> 
     </f:view> 
    </div> 
</div> 
: 여기 내 코드는 ... 내가 다른 스레드에서 답을 찾을 수 없습니다 때문에 누군가가 문제를하시기 바랍니다 찾아 좀 도와 줄래 ... "지도는 정의되지 않는다"

답변

1

좋아 나는

내가 JSF에 의해 생성 된 자바 스크립트 변수의 이름을 정의했다 ... 그것을 발견했다. 그래서 gmap 요소에 특성 "jsVariable"을 추가했습니다.

<m:map jsVariable="map" var="map" mapVar="map" gmapKey="#{gmapBean.gmapkey}" id="map" /> 

안녕