ArcGIS Server Java–自訂command

來源:互聯網
上載者:User

參考:Server Java 開發實戰---自訂command

 

command裡面就是命令按鈕。在我們的ArcGIS Server的Web ADF裡面,command被用來做一些不用跟地圖互動的工作.1.編寫java類,實現command的功能

command裡面就是命令按鈕。在我們的ArcGIS Server的Web ADF裡面,command被用來做一些不用跟地圖互動的工作.

 

1.編寫java類,實現command的功能

 

代碼

package com.demo;

import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.geometry.WebExtent;

public class MyFullExtent {
WebContext context;

public WebContext getContext() {
return context;
}

public void setContext(WebContext context) {
this.context = context;
}

public void setFullExtent() {
try {
WebExtent ex = context.getWebMap().getFullExtent();
context.getWebMap().setCurrentExtent(ex);
context.refresh();

} catch (Exception ex) {
ex.printStackTrace();
}
}
}

 

 

2.在faces-config.xml檔案,在裡面添加如下配置:web context作為一個屬性,用來初始化MyFullExtent,#{mapContext}指向了一個在faces-config.xml檔案中定義的另外一個Bean

 

代碼

<managed-bean>         
<managed-bean-name>myFullExtent</managed-bean-name>
<managed-bean-class>com.demo. MyFullExtent </managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>context</property-name>
<value>#{mapContext}</value>
</managed-property>
</managed-bean>

 

 

3.在頁面中調用

 

<a:command id="fullExtent" 
action="#{myFullExtent. setFullExtent }"
toolText="全圖顯示" />

 

4.錯誤:Managedbean myFullExtent could not be created 引用的對象 "#{mapContext}" 的範圍比引用對象小原因為myFullExtent的managed-bean-scope屬性為session,而mapContext的managed-bean-scope屬性為request,調用的對象的作用範圍應大於等於調用者的作用範圍。此處將session改為request即可。

 

 

 

 

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.