[mapguide-users] Re: Mapguide JavaAjaxViewer Update Features Memory
Leak?
ar_gaeta
ar_gaeta at yahoo.it
Wed Dec 15 03:53:49 EST 2010
Try this, I launch it from the TaskPane, passing the information MAPNAME and
SESSION.
For me this work well for a shpfile loaded INSIDE the MGOS server (but it's
not transformed in .sdf, it stays shpfile...).
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="org.osgeo.mapguide.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.text.*" %>
<%@ page import="javax.servlet.jsp.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ include file="../common/common.jsp" %>
<%
String sessionId = request.getParameter("SESSION");
String mapName = request.getParameter("MAPNAME");
String layername = "sensibili_3003"; //name of layer that you want update,
loaded in the map
String newattribute = "hospital"; //new attribute to give to the field
String field = "dest_uso"; //name of field to change
try
{
// Initialize web tier with the site configuration file. The config
// file should be in the same folder as this script.
String realpath = getServletContext().getRealPath("/");
String configPath = realpath + "webconfig.ini";
MapGuideJavaApi.MgInitializeWebTier( configPath );
// Get the user information using the session id,
// and set up a connection to the site server.
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceService resourceService=(MgResourceService)
siteConnection.CreateService(MgServiceType.ResourceService);
MgFeatureService featureService=(MgFeatureService)
siteConnection.CreateService(MgServiceType.FeatureService);
MgMap map = new MgMap(siteConnection);
map.Open(mapName);
MgLayer layer = (MgLayer)map.GetLayers().GetItem(layername);
// Create a filter containing all the IDs of the features on this layer
String layerClassName = layer.GetFeatureClassName();
String layerFeatureId = layer.GetFeatureSourceId();
String selectionString = "FeatId >= 0";
//In this way you get directly the ResId of the layer (I mean:
"Library://prova_basic/Data/layername.FeatureSource")
MgResourceIdentifier fdo = new MgResourceIdentifier(layerFeatureId);
MgPropertyCollection properties = new MgPropertyCollection();
properties.Add(new MgStringProperty(field, newattribute));
MgUpdateFeatures updateFeature1 = new MgUpdateFeatures(layername,
properties, selectionString);
MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
commands.Add(updateFeature1);
featureService.UpdateFeatures(fdo, commands, false);
}
catch (MgException e)
{
out.println("<p><strong>Error:</strong> ");
out.println(e.GetDetails());
out.println("</p>");
}
%>
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Mapguide-JavaAjaxViewer-Update-Features-Memory-Leak-tp5833542p5837514.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list