Trying to avoid re-inventing the wheel here. I have a Google Web Toolkit page that I'm preparing to deploy, but the webservice that I'm communicating with will have a different relative address on the deployed server than my local test machine.
As such, I'm looking for a simple way to deploy with some sort of easily editable configuration file that I can put basic settings in server side. I have a couple of ideas about how to do that, but they seem somewhat hacky and it seems to me like there must already be a solution for this kind of problem (after all, per-server settings are a VERY common thing!)
Any ideas?
Edit: Since this doesn't seem to be attracting much attention, let me outline my initial thoughts: Store a static file local to the GWT files that I query with an AJAX call before any other logic. When the file is returned I parse out my data and store them as globally accessible vars, then allow the page building logic to run. Seems clunky, and there's the big downside of waiting for the AJAX to return before any loading, but it would work. Any better suggestions? (Please?)
My Solution: I've found a solution on my own, but it's pretty specific to my exact scenario so I don't know how useful it would be to the general user. I'll post it here anyway on the off chance that someone finds it useful.
The page I am working on is actually a GWT control embedded in a ASP.net site. Taking advantage of this, and my discovery of the GWT Dictionary class, I put together a "settings" system like this:
First, the setting I want (in this case an address to a webservice) is set in the ASP.net Web.Config file
<appSettings>
<add key="serviceUrl" value="http://mySite.com/myService.asmx"/>
</appSettings>
In the ASP page that's embedding the GWT control, I add a "static" javascript object that contains the config settings I need:
<head runat="server">
<title>Picklist Manager</title>
<script type="text/javascript" language="javascript">
var AppConfig = {
serviceUrl: "<%= ConfigurationManager.AppSettings["serviceUrl"] %>"
};
</script>
<script type="text/javascript" language="javascript" src="gwtcontrol.nocache.js"></script> <!-- Include my GWT control -->
</head>
Finally, in GWT I create a static "AppConfig" class that exposes this setting like so:
public class AppConfig {
public static String serviceUrl = "defaultUrl";
public static void Initialize() {
Dictionary appConfig = Dictionary.getDictionary("AppConfig");
if(appConfig == null) { return; }
servicePath = appConfig.get("serviceUrl");
}
}
From there I can call AppConfig.serviceUrl anywhere in my code to get the setting... whew! So yeah, that's a nice long complicated way of going about it but it works for me. Of the answers given Alexander's seems most inline with what I was looking for, so the bounty goes to him, but thank you to everyone who pitched in on my sticky little problem!