[mapguide-users] Storing WebLayout in Session Repository

Gunter Becker gunter.becker at CSOGIS.DE
Thu Feb 22 09:39:44 EST 2007


Hi Hidekazu,

yes I think your right with that. Pauls advice works just as long as the
user 
is at the webpage with the AjaxViewer. When you leave this page your
settings are lost.

Unfortunately it seems that the Map-Object has no XML-representation. When
you try to call GetResourceContent at "Web Tier Api" there is just this:

 <?xml version="1.0" encoding="UTF-8" ?> 
  <Map />

Also there is no xsd-File in Schema Repository for "Map". I've hoped to
perform some xslt-tranformation to transform the Map to the MapDefinition.
No chance!

I've seen another post on this group that maybe useful for your application.
But Ithink you have to cahnge some AjaxViewer-Code:

http://www.nabble.com/forum/ViewPost.jtp?post=7641754&framed=y&skin=16610

So I think the only way to do it completly at the server is that one I
described in my last post. Store WebLayout and MapDefinition in the session
repository. I've tried it today and it works for me. I'm at the beginning of
my application development and the only thing I need right now is to reset
the visibility of the layers. So it is ok at the moment. When the
application grows I have to spent more time on it.

Thanks a lot, Gunter


Hidekazu Shimaji wrote:
> 
> Paul's advice is a great help for me, but this means that 
> I cannot use the MgMap class if I want to change a map 
> in initially showing the map, doesn't it?
> 
> I agree with Gunter.
> It is very complicated, and I also hope a method to show "Map" 
> as well as "MapDefinition".
> 
> Hidekazu
> 
> --- Gunter Becker <gunter.becker at CSOGIS.DE> wrote:
> 
>> 
>> So I think the steps I have to perform are:
>> 
>>   - Store the original MapDefinition in Session Repository (make a copy)
>>   - Make a reference to the users Map in Session Repository
>>   - loop through all the layers in the Map to get all the properties like
>> for example the visibility of a layer
>>   - Modify the copy of the MapDefinition with this properties
>>   - Call AjaxViewer with stored WebLayout and the modified MapDefinition
>> 
>> Does anyone agree with me?
>> If so then it's a bigger job than I've first thought.
>> 
>> Isn't there a method somewhere to make a new MapDefinition out of a Map?
>> 
>> 
>> 
>> 
>> I have to store the original MapDefinition which was first called with
>> the
>> WebLayout into the session repository and then try to iterate through the
>> layers collection of the Map to modify the
>> 
>> 
>> Hidekazu Shimaji wrote:
>> > 
>> > Hello,
>> > 
>> > Not "NeulingenALK.Map" but "NeulingenALK.MapDefinition" is required for
>> > the WebLayout.
>> > I tried the same way of you, but it did not work.
>> > I don't know why.  I finally gave up using the MgMap class, 
>> > and used the SetResource function for setting a xml of the
>> MapDefinition.
>> > 
>> > Does anybody know about it?
>> > 
>> > Regards,
>> > Hidekazu Shimaji
>> > 
>> > --- Gunter Becker <gunter.becker at CSOGIS.DE> wrote:
>> > 
>> >> 
>> >> OK your code works for me but now I got the problem that the map isn't
>> >> shown
>> >> in the AjaxViewer. Instead I got hte following error message:
>> >> 
>> >>   An unclassified exception occurred. Exception occurred in method
>> >> MgMap_Create__SWIG_0 at line 681 in file .\MgApi_wrap.cpp
>> >> 
>> >> My Query to launch AjaxViewer:
>> >> 
>> >>  
>> >>
>> >
>>
> http://geo19/mapguide/mapviewerajax/?SESSION=bb143bae-ffff-ffff-8000-000476dc3d5a_en&amp;WEBLAYOUT=Session:bb143bae-ffff-ffff-8000-000476dc3d5a_en//Current.WebLayout
>> >> 
>> >> XML representation of the WebLayout:
>> >> 
>> >>   <?xml version="1.0" encoding="utf-8" ?> 
>> >>   <WebLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> >> xsi:noNamespaceSchemaLocation="WebLayout-1.0.0.xsd">
>> >>       <Title>ALK Neulingen</Title> 
>> >>       <Map>
>> >>          
>> >>
>> <ResourceId>Session:279a9b8c-0000-1000-8000-000476dc3d5a_en//NeulingenALK.Map</ResourceId>
>> >> 
>> >>           <HyperlinkTarget>TaskPane</HyperlinkTarget> 
>> >>       </Map>
>> >>       ...
>> >> 
>> >> Must the <ResourceId> be of Type "MapDefinition" or is "Map" also OK?? 
>> >> 
>> >> To make things clear:
>> >> 
>> >> My intention is to store the WebLayout into the session repository to
>> >> give
>> >> the user the ability to leave the AjaxViewer and go to another webpage
>> of
>> >> my
>> >> application and then return to the AjaxViewer. All of the changes he
>> had
>> >> done before leaving the map (changing colors, adding layers, ..)
>> should
>> >> be
>> >> avbailable after loading WebLayout stored in session.
>> >> 
>> >> Is that the right way to this ??
>> >> 
>> >> 
>> >> Hidekazu Shimaji wrote:
>> >> > 
>> >> > Hello,
>> >> > 
>> >> > I don't think the ResourceHeader is the cause.
>> >> > You have to set the content of xmlWebLayout to byteArray.
>> >> > 
>> >> > How about do like this:
>> >> > 
>> >> > --- the code start
>> >> > //save the xml to MemoryStream
>> >> > System.IO.MemoryStream stream = new System.IO.MemoryStream();
>> >> > xmlWebLayout.Save(stream);
>> >> > // get byte array from the MemoryStream
>> >> > byte[] byteArray = stream.ToArray();
>> >> > //convert byte array to string without the first byte(BOM)
>> >> > string outerXml = System.Text.Encoding.UTF8.GetString(byteArray, 1,
>> >> > byteArray.Length - 1);
>> >> > // convert string to byte array with the utf-8 encoding 
>> >> > byteArray = System.Text.Encoding.UTF8.GetBytes(outerXml);
>> >> > 
>> >> > // store the WebLayout in Session-Repository
>> >> > MgByteSource byteSource = new MgByteSource(byteArray,
>> >> >    byteArray.Length);
>> >> > byteSource.MimeType = MgMimeType.Xml;
>> >> > MgResourceIdentifier userWebLayoutId = new
>> >> >     MgResourceIdentifier("Session:" + sessionId + @"//Current." +
>> >> >     MgResourceType.WebLayout);
>> >> > 
>> >> > resourceService.SetResource(userWebLayoutId, byteSource.GetReader(),
>> >> > null);
>> >> > --- the code end
>> >> > 
>> >> > 
>> >> 
>> >> -- 
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Storing-WebLayout-in-Session-Repository-tf3265925s16610.html#a9096652
>> >> Sent from the MapGuide Users mailing list archive at Nabble.com.
>> >> 
>> >> _______________________________________________
>> >> mapguide-users mailing list
>> >> mapguide-users at lists.osgeo.org
>> >> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>> >> 
>> > 
>> > _______________________________________________
>> > mapguide-users mailing list
>> > mapguide-users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/mapguide-users
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Storing-WebLayout-in-Session-Repository-tf3265925s16610.html#a9098651
>> Sent from the MapGuide Users mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>> 
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Storing-WebLayout-in-Session-Repository-tf3265925s16610.html#a9100948
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list