[mapguide-internals] Making DWF viewer feature selection behave like Ajax viewer selection

Carl Jokl carl.jokl at keynetix.com
Fri Jul 18 07:45:01 EDT 2008


If there is a hard way to do things it looks like I will find it.

I fixed this problem but doing things a much easier way.

Just to recap the steps I did incase someone else needs to do the same
change from one viewer to the other. 

Firstly the selection and map name need to be passed in the server explicity
with the DWF viewer. To do this in my testing I created a couple of hidden
fields in the existing form which posted back to perform a selection based
action (in this case list the selected parcels on the sheboygan map). I
added a javascript function to call as an "onsubmit" event of the form.

The javascript function was:

function updateClientSelectionParameters()
{
            document.forms[0].selectionField.value =
parent.ViewerFrame.GetMapFrame().GetSelectionXML();
            document.forms[0].selectionMapField.value =
parent.ViewerFrame.GetMapFrame().GetMapName();
}

This would then populate the fields with the map and selection xml string as
of the time when the submit occurs. 

That facilitates the selection being passed with the request. On the server
side the ASPX I had to set in the page tag: ValidateRequest="false" because
otherwise ASP .Net throws a hissy fit about how the xml contained within the
request property must be malitious and for security's sake it had to stop
proceeding for the greater good of humanity....or something to that effect. 

On the server side I check for the presence of the client selection property
and the map name property in the request and if they are there an MgSelecton
object is created with the (MgMap map, string selectionXML) constructor
where the map was retrieved previously from the resource service using the
map name. Then all I have to do is call Save on the MgSelection object
supplying the map name again which should create the expected map.Selection
resource which I was trying to create myself the hard way.

Later when code executes to get the map selection using another MgSelection
object again but this time just created with the MgMap constructor and after
creation calling the Open(ResourceService, MapName) method of the
MgSelection object will load the selection object. The selection object will
be blissfully unaware whether the selection was created by the Ajax viewer
or explicity created by me..or you...previously from values supplied from
the DWF viewer.

There ...solved my own problem.
-- 
View this message in context: http://www.nabble.com/Making-DWF-viewer-feature-selection-behave-like-Ajax-viewer-selection-tp18524340p18527524.html
Sent from the MapGuide Internals mailing list archive at Nabble.com.



More information about the mapguide-internals mailing list