<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Custom OnSelection Events - a better way?</title>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:Arial;
        color:navy;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks Brad. I didn’t realize you
could override a javascript method in this fashion. I completely overlooked
this post which I did read, but obviously didn’t understand!<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>-shane<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal style='margin-left:.5in'><b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b>Brad Leighninger<br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, February 28, 2007
1:48 PM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">MapGuide
Users Mail List</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [mapguide-users]
Custom OnSelection Events - a better way?</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>On that same post Jason
Birch wrote an override for the OnSelectionChanged Event and placed it in the
page where he called his viewer.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><a
href="http://www.nabble.com/RE%3A-OnSelection-Event--p4242868s16610.html">http://www.nabble.com/RE%3A-OnSelection-Event--p4242868s16610.html</a><o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>This should modify the
event to run custom code in that instance of the viewer only.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>I modified it a bit to
check to make sure only one item was selected and to send the sessionID to a
custom page where the api is used to get the map and its selection set to
display the data. I think you need to use a full URL to call your custom
page because a relative URL will be relative to the viewer application.
This has worked well for me in the <st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place>
viewer. Jason stated that it will not work in the DWF viewer but I
haven’t tried it.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
color=blue face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>function</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
MyOnSelectionChangedHandler()<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
{<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
originalOnSelectionChanged();<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span
style='color:blue'>var</span></font> mapFrame=ViewerFrame.GetMapFrame();<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>var</span></font> selCount=mapFrame.GetSelectedCount();<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>if</span></font>(selCount==1)<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
{<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>var</span></font>
sessionID=mapFrame.GetSessionId()
parent.tabspage.selecteddetails.location.href=<font color=maroon><span
style='color:maroon'>"http://mysite/mypage.aspx?sessionID="</span></font>+sessionID<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
}<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
}</span></font><font size=2 color=navy face=Arial><span style='font-size:10.0pt;
font-family:Arial;color:navy'><o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Brad Leighninger<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Mathews & Associates,
Inc.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>417-869-6009<o:p></o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=3 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal style='margin-left:.5in'><b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b><st1:PersonName w:st="on">Buscher, Shane</st1:PersonName><br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, February 28, 2007
1:01 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Mapguide_users@lists.osgeo.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> [mapguide-users] Custom
OnSelection Events - a better way?</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I needed a way to capture a selected feature, get
it’s attributes, then show the results in the task frame. I was
able to achieve this by customizing the OnSelectionChanged javascript</span></font>
<font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>function</span></font>
<font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>in the
mainframe.templ (thanks to Kori</span></font> <a
href="http://www.nabble.com/OnSelection-Event--tf1561860s16610.html#a4241783"><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>http://www.nabble.com/OnSelection-Event--tf1561860s16610.html#a4241783</span></font></a><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>). </span></font>
<font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>The
Viewer API does not expose this event, so</span></font> <font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>the downside is
that you’re forced into modifying MapGuide source code</span></font> <font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>that will
get executed for all applications. </span></font> <font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>I’m
developing in an enterprise environment, so I need to be careful with</span></font>
<font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>dabbling
in 3<sup>rd</sup> party source code and want to avoid unexpected results with
other applications that we’ll write. If I</span></font> <font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>(or someone
else)</span></font> <font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>ever did a reinstall of the web extensions and forgot</span></font>
<font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>there
was a customized mainframe.templ,</span></font> <font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>we’d be hosed. Is there any
better way to handle this?</span></font><o:p></o:p></p>
<p style='margin-left:.5in'><a name=""><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Regards,</span></font></a><o:p></o:p></p>
<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Shane</span></font><o:p></o:p></p>
</div>
</body>
</html>