Making DWF viewer feature selection behave like Ajax viewer selection

View: New views
3 Messages — Rating Filter:   Alert me  

Making DWF viewer feature selection behave like Ajax viewer selection

by Carl Jokl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am currently working on a map guide enterprise framework library for use within my company and am currently fixing issues relating do difference in behaviour between the Ajax viewer and the DWF viewer. The framework will need to be able to work consistently with both.

I currently have a problem with selection because the Ajax viewer handles feature selection on the server side where the DWF viewer holds selection state on the client side. I know that in order to deal with selection on the server the client selection needs to be sent from the client to the server prior to performing any operation that needs it. I note that from what I have been able to see the MgSelection object seems to depend on a resource [map name].Selection stored in the session. My though was to take the client selection and use the resource manager to store appropriate selection xml in the resource repository the MgSelection object expects to find. So far this has not worked properly. I have the client selection being posted to the server successfully as part of the request which needs to deal with selection. I have stored that in the location which the MgSelection looks for it. From what I can see though the xml layout of the expected server selection xml is not the same as the client selection xml meaning I may need to convert it. In order to give me a better idea of how the server selection xml should look I have a mechanism of dumping the contents of the selection resource when using the Ajax viewer to see what is there. The problem is that whenever I have done this I have found the body of the document always to be empty i.e. <Selection></Selection>. This has put into question whether this selection resource is generated the way I expect it to be. I wonder if the resource gets built after the creation of the MgSelection object but before the MgSelection.Open call. I am wondering if what I am trying to do i.e. fake ajax view selection for the MgSelection object when using the dwf viewer the way I am trying to do it is even possible at all. If it is not it would be good to find that out before spending too much time trying to do it.

Re: Making DWF viewer feature selection behave like Ajax viewer selection

by Carl Jokl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have also tried dumping the selection file contents between the MgSelection creation and MgSelection.Open call and it is still just <Selection></Selection> making me wonder when it gets populated. I may have to dig around more in the MapGuide source C++ files to try and figure out when this resource gets populated.

Re: Making DWF viewer feature selection behave like Ajax viewer selection

by Carl Jokl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 and the selectionXML is the selectionXML retrieved from the Http Request parameter. 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 data into the 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.
LightInTheBox - Buy quality products at wholesale price