BESClientUI and Adobe Flex (Passing Parameters)?

(imported topic written by wnolan91)

I’m trying to figure out the easiest way get BigFix Relevance into Adobe Flex. The one method I’m working on, which I’m not sure is the “Ideal” method is to sending the Parameters via FlashVars, explained in the article below.

http://blog.flexexamples.com/2007/08/07/grabbing-flashvars-from-the-embedding-html-template/#more-64

So it fairly easy to get the relevance I’m looking for via the current BESClientUI (HTML), but we like the look and feel of Adobe Flex. So, the question is? How do I get <?relevance operating system ?> and <?relevance computer name ?> to pass it’s value to Flex? Assuming that it the best way to do it.

Thanks

Bill

(imported comment written by jessewk)

Hi Bill,

In what context are you trying to pass relevance results to Flex? Web reports or the console?

In Web Reports, the most efficient way is to make a Flex URLRequest and hit the SOAP API.

In the console, the most efficient method is to use ExternalInterface. If you anticipate that the size of the data set you plan to pass over ExternalInterface is large (e.g. more than 100K or so) you’ll want to serialize your data before passing it. I recommend using JSON. Let me know if you need a more concrete example.

Jesse

(imported comment written by SystemAdmin)

Hey Bill,

The way you illustrate seems like it will work, though i am not very familiar with it.

We use a variant of that method by using swfobject.js (http://code.google.com/p/swfobject/) to assign parameters when instantiating our swf, then using the same Application.application.parameter call to get the data into flex.

The methods are very similar, and i don’t think there are any practical concerns, so which ever way you feel more comfortable will work just fine.

-Zak

(imported comment written by jessewk)

Bill,

I would do something like this:

In Javascript:

In Flex:

// call this on the Application’s creationComplete event.
private function creationComplete():void
{
ExternalInterface.addCallback(‘setComputerName’ , handleName);
ExternalInterface.addCallback(‘setComputerOS’ , handleOS);
ExternalInterface.call(‘onSWFReady’);
}

private function handleName(name:String):void
{
// do something here
}

private function handleOS(os:String):void
{
// do something here
}

(imported comment written by wnolan91)

So if I understand this correctly: ???

FYI: The only viewable part in the Techicians tab within the BESClientUI is the mx:text… not the mx:label.

I updated the Flex project to include your Flex code, simply adding…

mx:Script

</mx:Script>

<mx:Text x=“41” y=“395” text=“Computer Name” color="#F4F8F9" fontWeight=“bold”/>

<mx:Label id=“labelComputerName” text="{CN}" x=“174” y=“395” enabled=“true” color="#EAF3F5"/>

<mx:Text x=“41” y=“421” text=“Operation System” color="#F4F8F9" fontWeight=“bold”/>

<mx:Label id=“labelOperatingSystem” text="{OperatingSystem}" x=“174” y=“421” enabled=“true” color="#EAF3F5"/>

I take the html file that is created with my Flex Project, rename it to _technician.html

Added the JavaScript you have supplied… I put it right after the /HEAD tag section at the top of the _technician.html.

I modified the ‘theSWF’ to the name of the SWF file I created…

document.getElementById(‘BigFixTest’).setComputerName(name);

document.getElementById(‘BigFixTest’).setComputerOS(os);

I’m also not sure how important the “History” folder is… as it does not get copied into the “C:\program files\BigFix Enterprise\BES Client__BESData__UISession\0” folder, so I’m not sure if I should also be changing the href=“history/history.css” in the HTML file to href=“history.css”…

(imported comment written by jessewk)

Hi Bill,

Is something not working? It looks pretty solid to me but I didn’t test it.

Jesse

(imported comment written by wnolan91)

Yes, it doesn’t import the value… into the Technician’s tab.

I would have thought to see:

Computer Name ABCD192222

Operating System WinXP

but I only see:

Computer Name

Operating System

Thanks

Bill

(imported comment written by jessewk)

Hi Bill,

I had to create an example myself before I noticed the source of your error. You have everything correct except handleOS and handleName are setting a local variable rather than the global bindable variable.

All you need to do is remove the ‘var’ key word from those functions:

public function handleName(name:String):void

{

CN = name;

}

public function handleOS(os:String):void

{

OperatingSystem = os;

}

Jesse

(imported comment written by wnolan91)

Jesse,

I have made the changes… as you stated, but still the same result…

Computer Name

Operation System

{which I guess should really say “Operating System” but I digress}

Note: no values imported. I have checked out the file… C:\program files\BigFix Enterprise\BES Client__BESData__UISession\0_currentTechnician.html and have noticed that the Relevance did change to values.

My latest Flex Code is below… I’m not sure if the BINDABLE PUBLIC VAR CN:String…etc is causing my ills… If you could post the code you have come up with that worked maybe that would help… Also, I’m not sure if my assumptions that I had to change your lines… in the JAVAScript to point to the name of the SWF file is a correct assumption ‘mySWF’ changed to ‘BigFixTest’… or if I need the full ‘BigFixTest.SWF’ either way… it didn’t work.

document.getElementById(‘BigFixTest’).setComputerName(name);

:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx=“http://www.adobe.com/2006/mxml” layout=“absolute” borderColor="#DFECF5" backgroundGradientAlphas="

http://1.0, 1.0

" backgroundGradientColors="

D2D3F6, #0B0C22

">

mx:Script

</mx:Script>

<mx:Text x=“41” y=“395” text=“Computer Name” color="#F4F8F9" fontWeight=“bold”/>

<mx:Label id=“labelComputerName” text="{CN}" x=“174” y=“395” enabled=“true” color="#EAF3F5"/>

<mx:Text x=“41” y=“421” text=“Operation System” color="#F4F8F9" fontWeight=“bold”/>

<mx:Label id=“labelOperatingSystem” text="{OperatingSystem}" x=“174” y=“421” enabled=“true” color="#EAF3F5"/>

</mx:Application>

(imported comment written by jessewk)

I’ve attached a zip of the __UISupport folder that is working for me.

I also included the auto generated source view files so that you can view the action script portion. Just load up index.html in the srcview folder.

Jesse

(imported comment written by jessewk)

OK… I can’t get the attachment to post so here are the pieces. My Flex project is called ClientDashboard and generates ClientDashboard.swf.

You need to place 3 files in the __UISupport folder:

swfobject.js – Available here: http://blog.deconcept.com/swfobject/swfobject.zip

ClientDashboard.swf

_dashboard.html

Here is the contents of _dashboard.html

<html> <head> <link type=
"text/css" rel=
"stylesheet" href=
"offer.css"></link> <title>BigFix Technician Support</title> </head> <body>   <script src=
"swfobject.js" type=
"text/javascript"></script>   <div id=
"SWFHolder" height=
"100%" width=
"100%" margin=
"0" padding=
"0">You need to install/upgrade your Flash Player to version 9 <a href=
"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Download Flash Player from Adobe</a></div> <script type=
"text/javascript"> var so = 

new SWFObject(
"ClientDashboard.swf", 
"ClientDashboardSWF", 
"100%", 
"100%", 9, 
"#FFFFFF"); so.write(
'SWFHolder'); function onSWFReady() 
{ var name = 
"<?relevance computer name ?>"; var os = 
"<?relevance name of operating system ?>"; document.getElementById(
'ClientDashboardSWF').setComputerName(name); document.getElementById(
'ClientDashboardSWF').setComputerOS(os); 
} </script>   </body> </html>

And the MXML for the ClientDashboard project:

<?xml version=
"1.0" encoding=
"utf-8"?> <mx:Application xmlns:mx=
"http://www.adobe.com/2006/mxml" layout=
"absolute" creationComplete=
"creationComplete()" viewSourceURL=
"srcview/index.html"> <mx:Script> <![CDATA[   [Bindable] 

private var CN:String; [Bindable] 

private var OperatingSystem:String;   

private function creationComplete():

void 
{ ExternalInterface.addCallback(
'setComputerName' , handleName); ExternalInterface.addCallback(
'setComputerOS' , handleOS); ExternalInterface.call(
'onSWFReady'); 
} 

private function handleName(name:String):

void 
{ CN = name; 
} 

private function handleOS(os:String):

void 
{ OperatingSystem = os; 
} ]]> </mx:Script> <mx:Text x=
"41" y=
"395" text=
"Computer Name" color=
"#F4F8F9" fontWeight=
"bold"/> <mx:Label id=
"labelComputerName" text=
"{CN}"  x=
"174" y=
"395" enabled=
"true" color=
"#EAF3F5"/> <mx:Text x=
"41" y=
"421" text=
"Operation System" color=
"#F4F8F9" fontWeight=
"bold"/> <mx:Label id=
"labelOperatingSystem" text=
"{OperatingSystem}"  x=
"174" y=
"421" enabled=
"true" color=
"#EAF3F5"/> </mx:Application>

That should do it.

Jesse

(imported comment written by wnolan91)

Jesse,

I hate to drive you crazy like this… but there is no ‘swfobject.swf’ in the attached ZIP file.

(imported comment written by jessewk)

oh sorry, it’s swfobject.js not swfobject.swf. I’ll edit my previous post.

(imported comment written by wnolan91)

Thanks that worked.

Bill