2015-12-08 60 views
1

我在PrimeFaces 5.2中使用GMap時遇到問題 我試圖用單個標記顯示地圖窗口,但標記不顯示,我一直得到空白地圖沒有標記。調查後發現,顯然XHTML文件中的模型標籤被忽略。即使我填寫完整的廢話(如型號=「#{} asdfasdf),它甚至不拋出一個錯誤我的代碼PrimeFaces GMap忽略模型標籤,不顯示標記

片段:

XHTML

 <p:outputPanel id="mapPanel" style="text-align:center;width:400px"> 
      <p:gmap id="map" rendered="#{testRecordsView.showMap}" 
       model="#{GMapView.simpleModel}" zoom="10" type="ROADMAP" 
       center="#{testRecordsView.selectedTest.lat}, #{testRecordsView.selectedTest.lng}" 
       style="width:400px;height:400px" /> 
     </p:outputPanel> 

GMapView.java

@ManagedBean 
public class GMapView implements Serializable { 

private static final long serialVersionUID = -2238997881933594120L; 

private MapModel simpleModel; 

@ManagedProperty("#{testRecordsView}") 
private TestRecordsView dtView; 

@PostConstruct 
public void init() { 
    System.out.println("MAPMAPMAP"); 
    simpleModel = new DefaultMapModel(); 

    LatLng coord1 = new LatLng(dtView.getSelectedTest().getLat(), dtView.getSelectedTest().getLng()); 

    // Basic marker 
    simpleModel.addOverlay(new Marker(coord1, "test")); 
} 

public MapModel getSimpleModel() { 
    System.out.println("Map: " + simpleModel + " !"); 
    return simpleModel; 
} 

public void setDtView(TestRecordsView dtView) { 
    this.dtView = dtView; 
} 

}

在GMapView這些腳印永遠不會發生,如果我把斷點somew在這裏,他們也沒有被激活。顯然,整個班級從來沒有被召喚過。有沒有人有過這個問題?

回答

0

這一行:

model="#{GMapView.simpleModel}" zoom="10" type="ROADMAP" 

放克小寫在啓動;-)

model="#{gMapView.simpleModel}" zoom="10" type="ROADMAP" 

你去那裏。

+0

修復它。通過明確設置bean的名稱還找到了一個替代解決方案@ManagedBean(name =「GMapView」) – ChaoSera