Code
package com.demo;
import javax.faces.event.ActionEvent;
import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.geometry.WebExtent;
import com.esri.adf.web.faces.event.MapEvent;
import com.esri.adf.web.faces.event.MapToolAction;
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();
}
}
}
package com.demo;
import javax.faces.event.ActionEvent;
import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.geometry.WebExtent;
import com.esri.adf.web.faces.event.MapEvent;
import com.esri.adf.web.faces.event.MapToolAction;
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();
}
}
}
Code
<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>
<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>
在配置文件里配置<managed-propety>将java类中的字段赋值为#{mapContext}
通过WebUtil也是一种方法
FacesContext facesContext
=
phaseEvent.phaseEvent.getFacesContext();
WebUtil.getWebContext(facesContext.getViewRoot());
WebUtil.getWebContext(facesContext.getViewRoot());