You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Gentry, Michael" <mi...@fanniemae.com> on 2004/10/25 16:41:04 UTC
Defining configuration data in a Tapestry application?
I'm trying to figure out how I can define configuration data (my own -- not Tapestry's) in a Tapestry application. I tried something like:
<application>
<property name="my.configuration.key">value</property>
</application>
in the .application file, but I can't seem to find a way to retrieve this value. A few hours of Google searching didn't help (I think the "<" and ">" aren't used, so lots of meaningless results are returned).
Maybe this is more of a servlet question than a Tapestry question. I'm pretty naïve when it comes to servlets, having used mainly WebObjects in the past. In a WO application, I'd just put my configuration data in the info dictionary and request it at run-time, which was pretty painless.
Any suggestions?
Thanks!
/dev/mrg
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Defining configuration data in a Tapestry application?
Posted by Bryan Lewis <br...@maine.rr.com>.
I too was accustomed to the old WebObjects config files, property lists and
userDefaults. I wasn't aware of a built-in way to do it so I wrote some
code to duplicate the userDefaults feature. It does about what you'd
expect... there's a static HashMap that holds the Properties for each
domain, where the domains are my various application names plus "global".
The list of properties is read from a file "user.defaults" at start-up with
getResourceAsStream().
My user.defaults is a simple property list like:
global.EmailExceptions = false
global.ModelPrefix = local
global.VerboseSaveChanges = true
jones.AutoLoginUser = myusername
jones.AutoLoginPassword = mypassword
I could send you the code FWIW.
Bryan
----- Original Message -----
From: "Gentry, Michael" <mi...@fanniemae.com>
To: <ta...@jakarta.apache.org>
Sent: Monday, October 25, 2004 10:41 AM
Subject: Defining configuration data in a Tapestry application?
I'm trying to figure out how I can define configuration data (my own -- not
Tapestry's) in a Tapestry application. I tried something like:
<application>
<property name="my.configuration.key">value</property>
</application>
in the .application file, but I can't seem to find a way to retrieve this
value. A few hours of Google searching didn't help (I think the "<" and ">"
aren't used, so lots of meaningless results are returned).
Maybe this is more of a servlet question than a Tapestry question. I'm
pretty naïve when it comes to servlets, having used mainly WebObjects in the
past. In a WO application, I'd just put my configuration data in the info
dictionary and request it at run-time, which was pretty painless.
Any suggestions?
Thanks!
/dev/mrg
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Defining configuration data in a Tapestry application?
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Oct 25, 2004, at 2:05 PM, Bryan Lewis wrote:
> Right. I used the IPropertySource mechanism for a while. I didn't
> want to
> store developer-specific values in a source-tree file that would get
> checked
> into CVS, which ruled out web.xml or the application spec.
Doesn't rule it out with some Ant trickery. You could have a templated
web.xml or application spec that you token replace at build time.
Check out Ant's <copy>/<filterset> capabilities.
> So I added them
> as system properties in build.xml, reading from a build.properties file
> outside the source tree. The only trouble with that was that I had to
> modify build.xml every time I added a property. Not a big hardship, I
> guess. (Some day maybe I'll learn how Ant can parse an arbitrary
> properties
> list and append the list to a command line.)
I'm not sure I understand what you're doing here. Could you provide a
brief example?
To have Ant read in a properties file from the command line you can :
ant -propertyfile file.properties
But that doesn't quite seem like what you're looking for. I'd be happy
to help with any Ant tricks you might need.
Erik
>
>
>
> ----- Original Message -----
> From: "Erik Hatcher" <er...@ehatchersolutions.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Monday, October 25, 2004 1:07 PM
> Subject: Re: Defining configuration data in a Tapestry application?
>
>
> On Oct 25, 2004, at 10:41 AM, Gentry, Michael wrote:
>> I'm trying to figure out how I can define configuration data (my own
>> -- not Tapestry's) in a Tapestry application. I tried something like:
>>
>> <application>
>> <property name="my.configuration.key">value</property>
>> </application>
>>
>> in the .application file, but I can't seem to find a way to retrieve
>> this value. A few hours of Google searching didn't help (I think the
>> "<" and ">" aren't used, so lots of meaningless results are returned).
>
> Use IPropertySource, obtained from the engine:
>
> http://jakarta.apache.org/tapestry/doc/api/org/apache/tapestry/
> IEngine.html#getPropertySource()
>
> You can get at .application properties this way (among properties from
> elsewhere too).
>
>> Maybe this is more of a servlet question than a Tapestry question.
>> I'm pretty naïve when it comes to servlets, having used mainly
>> WebObjects in the past. In a WO application, I'd just put my
>> configuration data in the info dictionary and request it at run-time,
>> which was pretty painless.
>
> It's painless in Tapestry too :)
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Defining configuration data in a Tapestry application?
Posted by Bryan Lewis <br...@maine.rr.com>.
Right. I used the IPropertySource mechanism for a while. I didn't want to
store developer-specific values in a source-tree file that would get checked
into CVS, which ruled out web.xml or the application spec. So I added them
as system properties in build.xml, reading from a build.properties file
outside the source tree. The only trouble with that was that I had to
modify build.xml every time I added a property. Not a big hardship, I
guess. (Some day maybe I'll learn how Ant can parse an arbitrary properties
list and append the list to a command line.)
----- Original Message -----
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, October 25, 2004 1:07 PM
Subject: Re: Defining configuration data in a Tapestry application?
On Oct 25, 2004, at 10:41 AM, Gentry, Michael wrote:
> I'm trying to figure out how I can define configuration data (my own
> -- not Tapestry's) in a Tapestry application. I tried something like:
>
> <application>
> <property name="my.configuration.key">value</property>
> </application>
>
> in the .application file, but I can't seem to find a way to retrieve
> this value. A few hours of Google searching didn't help (I think the
> "<" and ">" aren't used, so lots of meaningless results are returned).
Use IPropertySource, obtained from the engine:
http://jakarta.apache.org/tapestry/doc/api/org/apache/tapestry/
IEngine.html#getPropertySource()
You can get at .application properties this way (among properties from
elsewhere too).
> Maybe this is more of a servlet question than a Tapestry question.
> I'm pretty naïve when it comes to servlets, having used mainly
> WebObjects in the past. In a WO application, I'd just put my
> configuration data in the info dictionary and request it at run-time,
> which was pretty painless.
It's painless in Tapestry too :)
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Defining configuration data in a Tapestry application?
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Oct 25, 2004, at 2:09 PM, Bryan Lewis wrote:
> Another option is (quoting from the source):
>
> * If the application specification contains an extension
> * named "org.apache.tapestry.property-source" it is inserted
> * in the search path just before
> * the property source for JVM System Properties... to allow
> * application-specific methods of obtaining configuration values.
>
> That would let you have the best of both worlds -- a custom method
> hooking
> into the standard IPropertySource mechanism.
Yes, IPropertySource is quite slick! I use it, along with the
extension to hook in custom application properties read from a
database.
I disagree with the default property load ordering, though. It is
backwards from my Ant-centric view of the world.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Defining configuration data in a Tapestry application?
Posted by Bryan Lewis <br...@maine.rr.com>.
Another option is (quoting from the source):
* If the application specification contains an extension
* named "org.apache.tapestry.property-source" it is inserted
* in the search path just before
* the property source for JVM System Properties... to allow
* application-specific methods of obtaining configuration values.
That would let you have the best of both worlds -- a custom method hooking
into the standard IPropertySource mechanism.
----- Original Message -----
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, October 25, 2004 1:07 PM
Subject: Re: Defining configuration data in a Tapestry application?
On Oct 25, 2004, at 10:41 AM, Gentry, Michael wrote:
> I'm trying to figure out how I can define configuration data (my own
> -- not Tapestry's) in a Tapestry application. I tried something like:
>
> <application>
> <property name="my.configuration.key">value</property>
> </application>
>
> in the .application file, but I can't seem to find a way to retrieve
> this value. A few hours of Google searching didn't help (I think the
> "<" and ">" aren't used, so lots of meaningless results are returned).
Use IPropertySource, obtained from the engine:
http://jakarta.apache.org/tapestry/doc/api/org/apache/tapestry/
IEngine.html#getPropertySource()
You can get at .application properties this way (among properties from
elsewhere too).
> Maybe this is more of a servlet question than a Tapestry question.
> I'm pretty naïve when it comes to servlets, having used mainly
> WebObjects in the past. In a WO application, I'd just put my
> configuration data in the info dictionary and request it at run-time,
> which was pretty painless.
It's painless in Tapestry too :)
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Defining configuration data in a Tapestry application?
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Oct 25, 2004, at 10:41 AM, Gentry, Michael wrote:
> I'm trying to figure out how I can define configuration data (my own
> -- not Tapestry's) in a Tapestry application. I tried something like:
>
> <application>
> <property name="my.configuration.key">value</property>
> </application>
>
> in the .application file, but I can't seem to find a way to retrieve
> this value. A few hours of Google searching didn't help (I think the
> "<" and ">" aren't used, so lots of meaningless results are returned).
Use IPropertySource, obtained from the engine:
http://jakarta.apache.org/tapestry/doc/api/org/apache/tapestry/
IEngine.html#getPropertySource()
You can get at .application properties this way (among properties from
elsewhere too).
> Maybe this is more of a servlet question than a Tapestry question.
> I'm pretty naïve when it comes to servlets, having used mainly
> WebObjects in the past. In a WO application, I'd just put my
> configuration data in the info dictionary and request it at run-time,
> which was pretty painless.
It's painless in Tapestry too :)
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org