Another possible approach is to create a DefaultValues class, something along these lines:
public class DefaultValues { private HashMap defaultValues; { setDefaultValues(); } public static HashMap getDefaultValues() { return defaultValues; } private static void setDefaultValues() { // Insert code to read in property file here // and store them in defaultValues } public static void resetDefaultValues() { setDefaultValues(); } } The benefit I think is that it keeps your default values independant of the Actions. Having the resetDefaultValues() method gives you a way to reinitialize the values without taking your app down (i.e., maybe on an Admin page you provide a "Reset Default Values" button that results in that method being called). By putting the property file read in the Action constructor, I'm not sure you'd be able to do this since Struts creates the one instance of your Action and gets a reference to it per request. I suppose you could do the above in an Action essentially and call setDefaultValues() from the constructor rather than a static initializer, but then you get into the question of whether that's thread-safe, since an Action has to be. In either case, just mentioning another possibility. :) -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Mon, January 24, 2005 8:13 am, Larry Meadors said: > OK, I think i understand what you are trying to do. You could override > the constructor of your action to read in a properties file. If you > have multiple actions, you could make it a base class that uses some > common naming convention, that may simplify things. > > > On Mon, 24 Jan 2005 08:02:04 +0000 (UTC), <[EMAIL PROTECTED]> wrote: >> On 2005-01-24, Larry Meadors <[EMAIL PROTECTED]> wrote: >> >> > Maybe we are approaching this from the wrong direction. what is >> > the problem you are trying to solve? >> >> Perhaps I am. I have an action which retrieves a couple of values >> from a database. If the retreival fails, it return some reasonable >> default values instead. It is these defaults which I want to be >> user configurable, that is, configurable from some initialization >> file. >> >> The introspection/set-parameter feature, found in PlugIns, would >> solve my problem, but it isn't available for actions, only >> actionmappings. >> > > --------------------------------------------------------------------- > 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]