On 01/04/2013, at 2:01 PM, Theodore Petrosky <[email protected]> wrote:

> is there a way to populate my username and password field through a property?
> 
> normally, I would use the setter:
> 
> 
> //            this.setUsername("sysadmin");
> //            this.setPassword("4004");
>       
> 
> in the Main constructor and comment it out when I compile for deploy. I 
> thought that setting it in a developer property file would be neat and tidy.

I won't touch on the meta-issue of whether or not this is a good idea—to answer 
your question: Sure, you can make properties for whatever you like.  In 
Properties.ted (substitute your actual username on your development machine for 
'ted'):

com.example.YourApp.devMode.username=sysadmin
com.example.YourApp.devMode.password=4004

(The keys there are entirely arbitrary.  You could just use 'username' and 
'password' if you want.)  Then, wherever you like in your app:

private static final String USERNAME_KEY = 
"com.example.YourApp.devMode.username";
private static final String PASSWORD_KEY = 
"com.example.YourApp.devMode.password";
...
        if (ERXApplication.isDevelopmentMode()) {
                this.setUsername(ERXProperties.stringForKey(USERNAME_KEY));
                this.setPassword(ERXProperties.stringForKey(PASSWORD_KEY));
        }


-- 
Paul Hoadley
http://logicsquad.net/




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to