Thank you Sam! You have given me the obvious solution. Why complicate things?
Thanks :) On 11/14/06, Sam Gendler <[EMAIL PROTECTED]> wrote:
depends on what kind of infrastructure you want. In the simplest case, just hardcode a file path into a class, open it and read its contents in a static block, and then just access from an Insert component (<binding name="value" value="ognl:myFileReaderObject.randomLine"/>) One step up would be to place the filepath in a config file included with your webapp. Either stick it in a hivemind config as a parameter to a service object, do something similar with a spring application-context, or even push it into your servlet from the web.xml file. If you absolutely must have a component and the component really must be passed a data source at each render time, presumably because you want to be able to choose from many sources, I would just have your component receive a model object which adheres to some interface, then provide an instance of that class to your page via hivemind (or spring), and configure the filepath in the hivemind.spring config. It still seems easier to me to have some kind of service object which can provide a line of text at random, and then just insert the text into the page via an Insert component. The only reason to make it a standalone component is if you need to wrap the text in some custom html, and that is simple enough. --sam On 11/13/06, Malin Ljungh <[EMAIL PROTECTED]> wrote: > I wish I had a tapestry component that would read a text file and randomly > output one of the rows. > Like a "quote rotator"... does anyone know if it exists out there or will I > have to write it myself? > > If I'd write it myself... how would I do - any suggestions? > I suppose I'd wan't to read the file (which is small) in a static variable > so I only need to do this once per class loader? > How do I specify the asset file and how will my component find it...hmmm > > Any help highly appreciated! > > Malin > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]