You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by landry soules <la...@gmail.com> on 2008/11/20 22:43:20 UTC

Properties file

Hello, i have a question about properties files :
I want to access several variables residing in a property file, from 
various components of my application. What is the best way to achieve 
this trivial need ?
Do you guys use Commons Configuration, or another api ? How do you 
configure it to work with Wicket ?
Is there an example somewhere ?
I know my question sounds dumb, but in my previous job we used an home 
made api to achieve this...
Thanks in advance !

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Properties file

Posted by jWeekend <jw...@cabouge.com>.
This is a good way to achieve the required effect. If you have a custom
session you could set the style in the constructor. 
You could also check some system variable (passed in to the JVM with the -D
switch on the command line) so you don't have to recompile your app every
time you want to switch mode.

Regards - Cemal
http://www.jWeekend.co.uk http://jWeekend.co.uk 




Srikanth.NT wrote:
> 
> I think you could use setStyle of Session object with a text "test",
> "prod".
> And rename your files into MyApplication.properties (default when you dont
> set the style), 
> MyApplication_test.properties(when style = "test") and
> MyApplication_prod.properties (when style="prod")
> 
> Regards,
> Srikanth NT
> 

-- 
View this message in context: http://www.nabble.com/Properties-file-tp20610610p20620313.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Properties file

Posted by "Srikanth.NT" <nt...@gmail.com>.
I think you could use setStyle of Session object with a text "test", "prod".
And rename your files into MyApplication.properties (default when you dont
set the style), 
MyApplication_test.properties(when style = "test") and
MyApplication_prod.properties (when style="prod")

Regards,
Srikanth NT

-----
http://ntsrikanth.blogspot.com/
-- 
View this message in context: http://www.nabble.com/Properties-file-tp20610610p20617707.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Properties file

Posted by landry soules <la...@gmail.com>.
Thanks a lot, Cemal. As always, you gave me a quick and brilliant answer.
I tried your first solution, and it works as a charm.

However, i wonder if there is a way to overload this properties file
according to the deployment environment (typically, i will have a file named
MyApplication.properties, another MyApplication.test.properties, and a 3rd
MyApplication.prod.properties) ?
Landry
2008/11/20 jWeekend <jw...@cabouge.com>

>
> Landry,
>
> If your properties are application wide, create MyApplication.properties
> (assuming you called your WebApplication subclass MyApplication) in the
> same
> package as your MyApplication class and use getString if you have a
> Component (or subclass, like a Page) to talk to, otherwise use
> Applicaion.get().getResourceSettings().getLocalizer().getString ...
>
> Regards - Cemal
> http://www.jWeekend.co.uk <http://www.jweekend.co.uk/>
> http://jWeekend.co.uk <http://jweekend.co.uk/>
>
>
> landry soules wrote:
> >
> > Hello, i have a question about properties files :
> > I want to access several variables residing in a property file, from
> > various components of my application. What is the best way to achieve
> > this trivial need ?
> > Do you guys use Commons Configuration, or another api ? How do you
> > configure it to work with Wicket ?
> > Is there an example somewhere ?
> > I know my question sounds dumb, but in my previous job we used an home
> > made api to achieve this...
> > Thanks in advance !
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Properties-file-tp20610610p20611147.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Properties file

Posted by jWeekend <jw...@cabouge.com>.
Landry,

If your properties are application wide, create MyApplication.properties
(assuming you called your WebApplication subclass MyApplication) in the same
package as your MyApplication class and use getString if you have a
Component (or subclass, like a Page) to talk to, otherwise use
Applicaion.get().getResourceSettings().getLocalizer().getString ... 

Regards - Cemal
http://www.jWeekend.co.uk http://jWeekend.co.uk 


landry soules wrote:
> 
> Hello, i have a question about properties files :
> I want to access several variables residing in a property file, from 
> various components of my application. What is the best way to achieve 
> this trivial need ?
> Do you guys use Commons Configuration, or another api ? How do you 
> configure it to work with Wicket ?
> Is there an example somewhere ?
> I know my question sounds dumb, but in my previous job we used an home 
> made api to achieve this...
> Thanks in advance !
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Properties-file-tp20610610p20611147.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org