Rama-o-Rama wrote:
Hello,

I am trying to read the property file like test.properties in the wicket.
I have done previously like servletcontext.getresouceasstream().

what is the wicket way of reading the file.

~Rama
If the properties file 'belongs' to a Component, like MyComponent.properties, I'd recommend using PackageResource. To load a Properties object you would do

Properties.load(PackageResouce.get(MyComponent.class, "MyComponent.properties").getResourceStream().getInputStream()));

I think using an IResourceStream implementation is more wickety than getting the servlet context. Only use javax.servlet.* classes when you really really need them. Who knows, maybe one day someone implements wicket on top of AWT (crazy but probably possible) and then you're in trouble (not really, but you get the point right?).

BTW, you can get a resource from any Class or ClassLoader instance, so you could also do this.getClass().getClassLoader().getResouceAsStream(..) but I would still recommend PackageResource.

Cheers,
Matthijs

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to