But the page'a constructor is called by the page pool when it creates new page instances. Besides the proposed solution used lazy loading of the file to a property which is more correct than using the constructor.

My problem with this approach is that multiple instances of one page may exist because of pooling. Therefore the file reading operation should be "synchronized" somehow if you don't want every page instance to read the same file (causing unnecessary memory usage and file operations).
I recommend some other approach instead:
- if the file contains global data for the application then store it in the "global" object (or let it be managed by a hivemind service)
- if the file is user specific then store it in the "session"

Of course if the file is read while rendering (when it is needed) and discarded right after rendering is finished then it is correct to store it in the page class.

Br,
Norbi

----- Original Message ----- From: "The Chris Method" <[EMAIL PROTECTED]>
To: "Tapestry users" <[email protected]>
Sent: Saturday, June 18, 2005 12:02 AM
Subject: Re: Read data from a file


Please don't laugh at my question about your question...
Why are you using a page's constructor method? We've always used
cycle.getPage to pull pages out of the pool.

On 6/16/05, Joerg Bergner <[EMAIL PROTECTED]> wrote:

Hello to everybody!

Please don't laugh about my question. But I didn't find any answers to it.

I want to read in data from a xml-file, which is stored in
'webapps/myWebApp/
data' folder. I want to do that in the constructor of the java class of a
page.

Is that possible? If yes, how can I do that?

Thank you!

Joerg Bergner
[EMAIL PROTECTED]


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





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

Reply via email to