|
|
Daniel
Loading database properties using a Tapestry page smells a little funky to me.
A common approach is to create a servlet, override it's init() method and put
code there to read your properties file and configure your database
manager/connection pool/etc. Be sure to set the servlet to load on startup via
web.xml.
Jon
> -----Original Message-----
> From: Cyril Godefroy [mailto:cyril@xxxxxxxxxxxxx]
> Sent: Wednesday, October 20, 2004 9:46 AM
> To: Tapestry users
> Subject: Re: Reading .properties file values
>
> I don't know what you're attempting to do, but you shouldn't
> be using properties resource bundles as a mechanism to
> configure db connection .
> web.xml or a spring applicationcontext are much better places
> to do such a thing.
>
> I suspect that your CreateDbConnection is not read because
> it's not found. Do you have a debugger? Did you print out
> found values for this.getMessage("Whatever")?
>
> Cyril
>
> Le Oct 20, 2004, à 4:40 PM, Maldonado, Daniel CW2 CTARNG a écrit :
>
> > I took a look at the workbench demo app and I could not find a good
> > example.
> > Why am I having so many problems reading a .properties file?
> >
> > The funny thing is that another class I have no problem reading the
> > file.
> >
> > All files are in the same location.
> >
> > #===================== This one works no problem ================
> > public abstract class Home extends BasePage {
> > public abstract String getUserName();
> > public abstract String getPassword();
> > public abstract void setMessage(String message);
> > private String loginMessage = "";
> >
> > public void login(IRequestCycle cycle){
> > if ( isValidLogin(getUserName(), getPassword()) ){
> > Main page = (Main)cycle.getPage("Main");
> > page.setMessage(loginMessage);
> > cycle.activate("Main");
> > }
> >
> > setMessage(loginMessage + " " +
> > (String)this.getMessage("db.driver"));
> >
> > }
> >
> //////////////////////////////////////////////////////////////////////
> > /
> >
> > Argggghghh... This one does not work!!!
> > #================== CreateDbConnection.properties ================
> > db.driver=MyDriver.whatever db.database=myDatabase
> > db.host=myhost.mydomain.anywhere
> > db.port=2771
> > #================ CreateDbConnection.java file =========== public
> > class CreateDbConnection extends BasePage {
> > public String connect(String login, String password) throws
> > SQLException
> > {
> > String dbDriver = (String)this.getMessage("db.driver");
> > String dbHost = (String) this.getMessage ("db.host");
> > String dbPort = (String) this.getMessage ("db.port");
> > String dbDatabase = (String) this.getMessage ("db.database");
> >
> > What in the world am I missing here?
> >
> > Daniel Maldonado
> > Programmer Analyst
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> > For additional commands, e-mail:
> tapestry-user-help@xxxxxxxxxxxxxxxxxx
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
|
|