You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nick Westgate <ni...@key-planning.co.jp> on 2005/03/01 03:12:32 UTC

Re: IUploadFile fileName - the reason

Hi.

Just a quick follow-up on this, since I recently had a quick look.

Tapestry uses java.io.File.GetName() to trim the path. If the
application is hosted on Windows it's in a Windows JVM, so that
is aware of (and expecting) Windows path separator characters.

Problems only occur when the browser sends the full path _and_ the
client and server platforms use different path separator characters.

It would be nice if this was handled inside the upload component.

Cheers,
Nick.


Cyril Godefroy wrote:
> Unfortunately, the mac version of ie 5 is far superior to the windows 
> version :-).... I too thought that everything was smooth until a friend 
> of ours came with IE to upload files. I must apologize to Laurent Rouvay 
> for not taking into account his remarks.
> 
> If I remember well, on a win machine with win ie, there was not issue 
> about that.
> 
> On Feb 2, 2005, at 12:14 PM, Todd O'Bryan wrote:
> 
>> That's interesting. In my case, the app server is an XServe running 
>> Mac OS X Server. The most recent (fairly old) version of IE on the Mac 
>> doesn't do this.
>>
>> Thanks for validating my approach (and reminding me to check Unix 
>> paths, too),
>> Todd
> 
> 
> 
> ---------------------------------------------------------------------
> 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: What/Where is the best way/place to read properties file?

Posted by "matthew c. mead" <m-...@goof.com>.
I often read a set of properties into a singleton class upon startup - I 
do it by subclassing the ApplicationServlet from Tapestry and adding my 
own code in init(), making sure to also call super.init().



-matt

Cin Peng wrote:

> I am trying to make my tapestry apps a little more flexible, therefore 
> I am trying to make it read a properties file upon startup.
>
> Where/How is the place/method to do this? I search in Google for a 
> sample to do this, I also examine example apps that comes with 
> Tapestry distribution, but found nothing.
>
> I am thinking of reading the properties file once upon startup and 
> then storing it in Global object. Is this the correct way to do it?
>
> I am sure somebody use/did this, anyone can give me a pointer? tq.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>

-- 
matthew c. mead

http://www.goof.com/

Re: What/Where is the best way/place to read properties file?

Posted by Cin Peng <ro...@onepixel.com.my>.
I ended up overriding createGlobal and then I call 
getApplicationSpecification().getProperty(String) from there.

Since I need to read the properties only once, I figured createGlobal is 
more appropriate since it is called only once... no?

I will then be able to call global.get("whatever") and use it whenever I 
wish from any component.. is this the purpose of Global after all? to store 
general information that will be shared among components?

Anyway your tips is very helpfull.. thanks.. this mailing list is very 
active and full with kind developers.. I will try to do my parts later on 
once I am confident enough with Tapestry.

TQ.

----- Original Message ----- 
From: "Shawn Church" <sh...@boxity.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, March 02, 2005 12:16 AM
Subject: Re: What/Where is the best way/place to read properties file?


> This is one way to get an application property from within
> setupForRequest():
>
> String savePath =
> context.getServlet().getApplicationSpecification().getProperty("savePath");
>
> You could also specify a custom property source as an application
> extension, using the property name
> "org.apache.tapestry.property-source".  The value of this property must
> implement IPropertySource.
>
> I tend to prefer defining custom application properties in web.xml, and
> then retrieving them in my Engine, such as:
>
> context.getServlet().getServletConfig().getInitParameter("savePath");
>
> In web.xml, you might have:
>  <init-param>
>     <param-name>savePath</param-name>
>     <param-value>c:\\myapps_data</param-value>
>  </init-param>
>
>
> As a side point, unless you really need to get your application
> properties from the file system, you might want to consider keeping them
> within your application classpath (ie - WEB-INF/classes) to ease
> deployment, testing, etc.
>
> Shawn
>
>
> Quoting Cin Peng <ro...@onepixel.com.my>:
>
>> Thanks... that helps a lot. I override setupForRequest and all seems
>> happy
>> and dandy.
>>
>> Now as opossed of using  getResourceAsStream to read the properties
>> in
>> 'somefile.properties', I noticed that the application specs allow us
>> to do
>> something like this;
>>
>> <application name="MyEngine" engine-class="com.myapps.MyEngine">
>>         <property name="savePath" value="c:\\myapps_data"/>
>>          ...
>>
>> I then declare my engine as abstract;
>>
>> public abstract class MyEngine extends BaseEngine {
>>
>>     public abstract String getSavePath();
>>
>>     protected void setupForRequest(RequestContext context) {
>>         super.setupForRequest(context);
>>         System.out.println(getSavePath());  //does it work? I want to
>> avoid
>> reading a properties file manually!
>>         .....
>>
>>
>> However tapestry throws me with ServletException right on my
>> face....
>>
>> I must be doing something very-very stupid, but as stupid as I am.. I
>>
>> couldn't figure what. *sigh*
>>
>>
>>
>>
>> ----- Original Message ----- 
>> From: "Shawn Church" <sh...@boxity.com>
>> To: "Tapestry users" <ta...@jakarta.apache.org>
>> Sent: Tuesday, March 01, 2005 11:00 AM
>> Subject: RE: What/Where is the best way/place to read properties
>> file?
>>
>>
>> >I should have added that setupForRequest is invoked on each request,
>> so if
>> > you put your initialization code there you will want to check your
>> global
>> > property for null (or whatever is appropriate for your app) to
>> prevent
>> > re-initialization on each request.
>> >
>> > Shawn
>> >
>> > -----Original Message-----
>> > From: Shawn Church [mailto:shawn@boxity.com]
>> > Sent: Monday, February 28, 2005 8:53 PM
>> > To: Tapestry users
>> > Subject: RE: What/Where is the best way/place to read properties
>> file?
>> >
>> >
>> > I tend to put this sort of thing in a custom Engine class,
>> overriding
>> > setupForRequest():
>> >
>> >   protected void setupForRequest(RequestContext context)
>> >   {
>> >      super.setupForRequest(context);
>> >
>> >      Map global = (Map)getGlobal();
>> >      ...
>> >
>> > If you don't have your own Engine defined yet, you will also want
>> to
>> > register your Engine class in your .application file:
>> >
>> > <property name="org.apache.tapestry.engine-class"
>> > value="com.whatever.Engine" />
>> >
>> >
>> > Shawn
>> >
>> >
>> > -----Original Message-----
>> > From: Cin Peng [mailto:rosdi@onepixel.com.my]
>> > Sent: Monday, February 28, 2005 8:33 PM
>> > To: Tapestry users
>> > Subject: What/Where is the best way/place to read properties file?
>> >
>> >
>> > I am trying to make my tapestry apps a little more flexible,
>> therefore I
>> > am
>> > trying to make it read a properties file upon startup.
>> >
>> > Where/How is the place/method to do this? I search in Google for a
>> sample
>> > to
>> > do this, I also examine example apps that comes with Tapestry
>> > distribution,
>> > but found nothing.
>> >
>> > I am thinking of reading the properties file once upon startup and
>> then
>> > storing it in Global object. Is this the correct way to do it?
>> >
>> > I am sure somebody use/did this, anyone can give me a pointer? tq.
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > 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
>> >
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> 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: What/Where is the best way/place to read properties file?

Posted by Shawn Church <sh...@boxity.com>.
This is one way to get an application property from within 
setupForRequest():

String savePath =
context.getServlet().getApplicationSpecification().getProperty("savePath");

You could also specify a custom property source as an application
extension, using the property name
"org.apache.tapestry.property-source".  The value of this property must
implement IPropertySource.

I tend to prefer defining custom application properties in web.xml, and
then retrieving them in my Engine, such as:
 
context.getServlet().getServletConfig().getInitParameter("savePath");

In web.xml, you might have:
  <init-param>
     <param-name>savePath</param-name>
     <param-value>c:\\myapps_data</param-value>
  </init-param>


As a side point, unless you really need to get your application
properties from the file system, you might want to consider keeping them
within your application classpath (ie - WEB-INF/classes) to ease
deployment, testing, etc.

Shawn


Quoting Cin Peng <ro...@onepixel.com.my>:

> Thanks... that helps a lot. I override setupForRequest and all seems
> happy 
> and dandy.
> 
> Now as opossed of using  getResourceAsStream to read the properties 
> in 
> 'somefile.properties', I noticed that the application specs allow us
> to do 
> something like this;
> 
> <application name="MyEngine" engine-class="com.myapps.MyEngine">
>         <property name="savePath" value="c:\\myapps_data"/>
>          ...
> 
> I then declare my engine as abstract;
> 
> public abstract class MyEngine extends BaseEngine {
> 
>     public abstract String getSavePath();
> 
>     protected void setupForRequest(RequestContext context) {
>         super.setupForRequest(context);
>         System.out.println(getSavePath());  //does it work? I want to
> avoid 
> reading a properties file manually!
>         .....
> 
> 
> However tapestry throws me with ServletException right on my
> face....
> 
> I must be doing something very-very stupid, but as stupid as I am.. I
> 
> couldn't figure what. *sigh*
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "Shawn Church" <sh...@boxity.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Tuesday, March 01, 2005 11:00 AM
> Subject: RE: What/Where is the best way/place to read properties
> file?
> 
> 
> >I should have added that setupForRequest is invoked on each request,
> so if
> > you put your initialization code there you will want to check your
> global
> > property for null (or whatever is appropriate for your app) to
> prevent
> > re-initialization on each request.
> >
> > Shawn
> >
> > -----Original Message-----
> > From: Shawn Church [mailto:shawn@boxity.com]
> > Sent: Monday, February 28, 2005 8:53 PM
> > To: Tapestry users
> > Subject: RE: What/Where is the best way/place to read properties
> file?
> >
> >
> > I tend to put this sort of thing in a custom Engine class,
> overriding
> > setupForRequest():
> >
> >   protected void setupForRequest(RequestContext context)
> >   {
> >      super.setupForRequest(context);
> >
> >      Map global = (Map)getGlobal();
> >      ...
> >
> > If you don't have your own Engine defined yet, you will also want
> to
> > register your Engine class in your .application file:
> >
> > <property name="org.apache.tapestry.engine-class"
> > value="com.whatever.Engine" />
> >
> >
> > Shawn
> >
> >
> > -----Original Message-----
> > From: Cin Peng [mailto:rosdi@onepixel.com.my]
> > Sent: Monday, February 28, 2005 8:33 PM
> > To: Tapestry users
> > Subject: What/Where is the best way/place to read properties file?
> >
> >
> > I am trying to make my tapestry apps a little more flexible,
> therefore I 
> > am
> > trying to make it read a properties file upon startup.
> >
> > Where/How is the place/method to do this? I search in Google for a
> sample 
> > to
> > do this, I also examine example apps that comes with Tapestry 
> > distribution,
> > but found nothing.
> >
> > I am thinking of reading the properties file once upon startup and
> then
> > storing it in Global object. Is this the correct way to do it?
> >
> > I am sure somebody use/did this, anyone can give me a pointer? tq.
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
> >
> >
> > 
> 
> 
> ---------------------------------------------------------------------
> 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: What/Where is the best way/place to read properties file?

Posted by Cin Peng <ro...@onepixel.com.my>.
Thanks... that helps a lot. I override setupForRequest and all seems happy 
and dandy.

Now as opossed of using  getResourceAsStream to read the properties  in 
'somefile.properties', I noticed that the application specs allow us to do 
something like this;

<application name="MyEngine" engine-class="com.myapps.MyEngine">
        <property name="savePath" value="c:\\myapps_data"/>
         ...

I then declare my engine as abstract;

public abstract class MyEngine extends BaseEngine {

    public abstract String getSavePath();

    protected void setupForRequest(RequestContext context) {
        super.setupForRequest(context);
        System.out.println(getSavePath());  //does it work? I want to avoid 
reading a properties file manually!
        .....


However tapestry throws me with ServletException right on my face....

I must be doing something very-very stupid, but as stupid as I am.. I 
couldn't figure what. *sigh*




----- Original Message ----- 
From: "Shawn Church" <sh...@boxity.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, March 01, 2005 11:00 AM
Subject: RE: What/Where is the best way/place to read properties file?


>I should have added that setupForRequest is invoked on each request, so if
> you put your initialization code there you will want to check your global
> property for null (or whatever is appropriate for your app) to prevent
> re-initialization on each request.
>
> Shawn
>
> -----Original Message-----
> From: Shawn Church [mailto:shawn@boxity.com]
> Sent: Monday, February 28, 2005 8:53 PM
> To: Tapestry users
> Subject: RE: What/Where is the best way/place to read properties file?
>
>
> I tend to put this sort of thing in a custom Engine class, overriding
> setupForRequest():
>
>   protected void setupForRequest(RequestContext context)
>   {
>      super.setupForRequest(context);
>
>      Map global = (Map)getGlobal();
>      ...
>
> If you don't have your own Engine defined yet, you will also want to
> register your Engine class in your .application file:
>
> <property name="org.apache.tapestry.engine-class"
> value="com.whatever.Engine" />
>
>
> Shawn
>
>
> -----Original Message-----
> From: Cin Peng [mailto:rosdi@onepixel.com.my]
> Sent: Monday, February 28, 2005 8:33 PM
> To: Tapestry users
> Subject: What/Where is the best way/place to read properties file?
>
>
> I am trying to make my tapestry apps a little more flexible, therefore I 
> am
> trying to make it read a properties file upon startup.
>
> Where/How is the place/method to do this? I search in Google for a sample 
> to
> do this, I also examine example apps that comes with Tapestry 
> distribution,
> but found nothing.
>
> I am thinking of reading the properties file once upon startup and then
> storing it in Global object. Is this the correct way to do it?
>
> I am sure somebody use/did this, anyone can give me a pointer? tq.
>
>
> ---------------------------------------------------------------------
> 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
>
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: What/Where is the best way/place to read properties file?

Posted by Shawn Church <sh...@boxity.com>.
I should have added that setupForRequest is invoked on each request, so if
you put your initialization code there you will want to check your global
property for null (or whatever is appropriate for your app) to prevent
re-initialization on each request.

Shawn

-----Original Message-----
From: Shawn Church [mailto:shawn@boxity.com]
Sent: Monday, February 28, 2005 8:53 PM
To: Tapestry users
Subject: RE: What/Where is the best way/place to read properties file?


I tend to put this sort of thing in a custom Engine class, overriding
setupForRequest():

   protected void setupForRequest(RequestContext context)
   {
      super.setupForRequest(context);

      Map global = (Map)getGlobal();
      ...

If you don't have your own Engine defined yet, you will also want to
register your Engine class in your .application file:

<property name="org.apache.tapestry.engine-class"
value="com.whatever.Engine" />


Shawn


-----Original Message-----
From: Cin Peng [mailto:rosdi@onepixel.com.my]
Sent: Monday, February 28, 2005 8:33 PM
To: Tapestry users
Subject: What/Where is the best way/place to read properties file?


I am trying to make my tapestry apps a little more flexible, therefore I am
trying to make it read a properties file upon startup.

Where/How is the place/method to do this? I search in Google for a sample to
do this, I also examine example apps that comes with Tapestry distribution,
but found nothing.

I am thinking of reading the properties file once upon startup and then
storing it in Global object. Is this the correct way to do it?

I am sure somebody use/did this, anyone can give me a pointer? tq.


---------------------------------------------------------------------
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: What/Where is the best way/place to read properties file?

Posted by Shawn Church <sh...@boxity.com>.
I tend to put this sort of thing in a custom Engine class, overriding
setupForRequest():

   protected void setupForRequest(RequestContext context)
   {
      super.setupForRequest(context);

      Map global = (Map)getGlobal();
      ...

If you don't have your own Engine defined yet, you will also want to
register your Engine class in your .application file:

<property name="org.apache.tapestry.engine-class"
value="com.whatever.Engine" />


Shawn


-----Original Message-----
From: Cin Peng [mailto:rosdi@onepixel.com.my]
Sent: Monday, February 28, 2005 8:33 PM
To: Tapestry users
Subject: What/Where is the best way/place to read properties file?


I am trying to make my tapestry apps a little more flexible, therefore I am
trying to make it read a properties file upon startup.

Where/How is the place/method to do this? I search in Google for a sample to
do this, I also examine example apps that comes with Tapestry distribution,
but found nothing.

I am thinking of reading the properties file once upon startup and then
storing it in Global object. Is this the correct way to do it?

I am sure somebody use/did this, anyone can give me a pointer? tq.


---------------------------------------------------------------------
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


What/Where is the best way/place to read properties file?

Posted by Cin Peng <ro...@onepixel.com.my>.
I am trying to make my tapestry apps a little more flexible, therefore I am 
trying to make it read a properties file upon startup.

Where/How is the place/method to do this? I search in Google for a sample to 
do this, I also examine example apps that comes with Tapestry distribution, 
but found nothing.

I am thinking of reading the properties file once upon startup and then 
storing it in Global object. Is this the correct way to do it?

I am sure somebody use/did this, anyone can give me a pointer? tq. 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org