4

Is it possible to run a Flex client in IntelliJ internally and have it talk to a separately deployed server instance? The server's a java webapp. This will make developing, especially debugging, much easier. What I'm trying to avoid is having to rebuild and redeploy the webapp to get the updated Flex code in it. I want to just build flex and run it against the server.

The flex client is embedded in an HTML page on the server, so in production the users access the client by going to a web page. We're using GraniteDS if that's important.

Update

I'm managed to cobble something together, but it's ugly.

  1. I made a copy of our wrapper HTML page and fixed the links to refer to the SWF in target
  2. I setup the IntelliJ run config to point to that HTML page
    • I set the 'Place SWF file in a local-trusted sandbox' to true
  3. Hardcoded the {server.name}, {server.port}, and {context.root} values in the service-config.xml GraniteDS config file to localhost, etc.

I can mavenize #1, but #3's isn't really a permanent solution. That part is still a problem because I can't check this in. Any improvements or alternative solutions?

sblundy
  • 60,628
  • 22
  • 121
  • 123
  • I have no idea what this sentence means: "We have a webapp with flex clients that talk to the webapp" How is a Flex client different from a web app? Is your webapp implemented in Flex? And you're trying to communicate to it w/ another Flex app? What does "deploying a Flex Module internally" mean? – JeffryHouser May 10 '11 at 23:52
  • @www.Flextras.com: It's a client & server arrangement. The client's in Flex, the server webapp's in Java. I'll try and clarify – sblundy May 11 '11 at 01:39
  • I'm still not understanding. Usually a Flex client is completely independent of the server side software. What makes you think you have to recompile / deploy your Java app every time the Flex client changes? – JeffryHouser May 11 '11 at 13:02
  • @www.Flextras.com: that's sort of my point, I shouldn't have to rebuild and redeploy the webapp. To the webapp, the swf just a file. And I can get IntelliJ to exec our maven build. What I can't get to happen is for IntelliJ to run the swf and have it talk to the webapp. I have gotten it to run in Flashplayer, but it throws an error about requiring ExternalInterface, which is provided by a browser. – sblundy May 11 '11 at 13:19
  • @sblundy in Flash Builder, I have the option to "launch" my project in a browser. I'd be very surprised if IntelliJ didn't offer something similar. I do have a development environment set up that mimics the server; so I'm never actually deploying anything beyond my local machine for testing purposes. I just have my server set up and running 'in the background'. – JeffryHouser May 11 '11 at 13:25
  • @www.Flextras.com: That's what I'm trying to get to. Maybe 10.5... – sblundy May 11 '11 at 14:59
  • @sblundy Why do you need to hard code those items in the Services-config file for this to work? I have no time to install IntelliJ right now; but I suspect you're overcomplicating things. – JeffryHouser May 11 '11 at 15:11
  • @www.Flextras.com: So that the GraniteDS connection will point to the server correctly. If I don't, the client complains when I try to login. – sblundy May 11 '11 at 15:32
  • @sblundy Are you running GraniteDS on a different domain than the one you are serving the SWF off of? IF so, that can definitely cause connection problems w/ the default services-config settings. I set up my development environment so that the server software and compiled SWF are served off the same domain. I modify a hosts file which points back to the machine; so it may be something like local.flextras.com. I also use Apache and host headers to handle multiple web domains w/ a single web server instance. – JeffryHouser May 11 '11 at 19:02
  • @www.Flextras.com: The 'Place SWF file in a local-trusted sandbox' flag handles that. The problem is that granite doesn't resolve the URL placeholders ({server.name}, etc) correctly unless it was downloaded from the webapp directly. – sblundy May 11 '11 at 20:22
  • personally, I never use the services-config xml. Either hard code the url or use flashvars to set the url. The rest should be done in the code. – J_A_X May 13 '11 at 16:02

1 Answers1

1

Most Flex apps don't really use the services-config.xml for client channel configuration because this hard codes the urls into the SWF. A better solution is to externalize the configuration. Most of the Flex frameworks (Swiz, Robotlegs, etc) provide a nice way to externalize the channel config to an XML file. However you can also roll your own XML-based client channel configuration.

James Ward
  • 29,283
  • 9
  • 49
  • 85