Hi Robert, You're best of in this scenario just creating your Channels directly. The ChannelSet, in its auto-configured mode, lazily fills in its list of Channels as needed based on their ids. That's why your code below is returning 'undefined'.
Alternately, you could take a look at the mx.messaging.config.ServerConfig class and do something similar to bootstrap your channels based on baked in config (if you compile with -services). Best, Seth From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Csiki Sent: Tuesday, May 20, 2008 8:50 AM To: [email protected] Subject: [flexcoders] Re: Is the context-root value burnt into SWF? Hi Seth, Sorry to bother you again... how to get the channel sets before connecting? This is what I'm trying to do: _remoteObject = new RemoteObject(); _remoteObject.destination = remoteObjectDestination; var cs:ChannelSet = ServerConfig.getChannelSet(remoteObjectDestination); cs.channels.forEach( function(channel:*, index:uint, array:Array):void { Channel(channel).uri.replace("{context.root}", contextRoot); }); This approach does not work, all the channels from the channel set are marked as "undefined". remoteObjectDestination and contextRoot are both String properties. Thanks, Robert --- In [email protected], "Seth Hodgson" <[EMAIL PROTECTED]> wrote: > > What about allowing your customers to edit the HTML wrapper to pass a > flashvar in to the swf that explicitly defines the context root they're > deploying to? > Your code could check for this value and do your own string replace of any > {context.root} tokens in your channel uris with this value before connecting > (be careful when handling empty context root values). > > Seth > > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of > Robert Csiki > Sent: Friday, May 16, 2008 2:33 PM > To: [email protected] > Subject: [flexcoders] Re: Is the context-root value burnt into SWF? > > > Thanks Seth, I understand it's different in Flex world. > > So does this mean customers are stuck with the context root we used when > compiling the applic! ation (e.g. which is equals to the application WAR > filename, less the extension)? We do not package the source code, all > they get is the SWFs and some html wrappers. > > Robert > > --- In [email protected], "Seth Hodgson" shodgson@ wrote: > > > > A context root is a Java servlet-ism, which allows the container to > route incoming requests to the correct web app. In HTML-land if you're > using relative URLs, you generally never have to worry about this > because the right value will be used automatically. It's a little more > complicated for a non-HTML client. The context root for a web app can > either be empty (i.e. /) or non-empty (i.e. /MyApp), and on the client > when a swf loads, it can inspect its URL but it doesn't have any way to > know what the server-side context root is. The MessageBrokerServlet that > processes HTTP-based requests from F! lex clients is not relative to where > the swf was loade! d from. You can define its path, which will generally > be something like: > http://{server}:{port}/{context.root}/messagebrokerservlet, but it could > be anything. To send a request to it successfully, the client needs to > use the correct context root. Take your URL below for example, > http://localhost:8080/MyApp/..., is the context root / or is it /MyApp - > who knows? Only the server. So unlike server name and port, the swf > can't dynamically determine the correct context root value at runtime on > the client. > > > > This means you need to either: > > 1. Specify it at compile time by hardcoding the proper context root > into the URL in your services-config.xml file, or by using a > {context.root} token in your URL in services-config.xml and passing the > desired value at compile time using the mxmlc -context-root flag. > > 2. Hardcode i! t into your client side ActionScript code. > > 3. Use the web tier mxmlc compiler which can replace a {context.root} > token with the correct value using HttpServletRequest#getContextPath() > when you request a .mxml in the browser > > > > Seth > > > > From: [email protected] [mailto:[EMAIL PROTECTED] > On Behalf Of Robert Csiki > > Sent: Friday, May 16, 2008 1:45 PM > > To: [email protected] > > Subject: [flexcoders] Is the context-root value burnt into SWF? > > > > Hi there, > > Say I'm using a context root value "MyApp" when compiling my > LCDS-based Flex application. I package everything into an archive called > "MyApp.war", depoly it on my Tomcat, startup tomcat, access the > application using http://localhost:8080/MyApp, everything works fine (I > have an index.html t! here that serves up the SWF) > > Now, if I want to de! ploy usi ng a different context root for my > application (say "MyApp1")... call it using the URL > http://localhost:8080/MyApp1 ... nothing would work this time. The SWF > still gets loaded, and that's it. It seems this context-root value > that's set in flex_config.xml gets somehow burnt in the SWF? what can I > do to have the app running under a different context root, without the > need to rebuild the SWF? > > Also, a question: why this context-root configuration is required in > Flex environment? An application normally auto-detects it's context root > at runtime. An application is usually untied from a specific context > root and can be deployed using any context root. > > Thanks, Robert > > >

