Nice, clean, elegant solution - thanks a lot, Matt! -----Original Message----- From: Raible, Matt [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 12:54 PM To: 'Struts Users Mailing List' Subject: RE: How do you access an application.properties value directly fr om within a class?
I forgot to add the simplest way in an Action class: MessageResources resources = getResources(request); resources.getMessage("keyName"); -----Original Message----- From: Raible, Matt Sent: Tuesday, July 15, 2003 10:51 AM To: 'Struts Users Mailing List' Subject: RE: How do you access an application.properties value directly fr om within a class? If you're just looking for the values, grab it as a resource bundle. Here's how I grab it in a Business Delegate: // Get the application's messages resources ResourceBundle resources = ResourceBundle.getBundle("ApplicationResources"); String appDBVersion = resources.getString("webapp.db_version"); And then of course, there's errors and messages - where it grabs it automagically: errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.existing.user", userForm.getUsername(), userForm.getEmail())); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("user.deleted", userForm.getEmail())); And lastly, you can get it from the servlet context in a servlet outside of struts: MessageResources resources = ((MessageResources) getServletContext().getAttribute(Globals.MESSAGES_KEY)); resources.getMessage("userFormEx.username"); HTH, Matt -----Original Message----- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 10:28 AM To: 'Struts Users Mailing List' Subject: How do you access an application.properties value directly from within a class? When Struts load, it grabs application.properties and stores it's keys and values somewhere. From within an action class I need to access a value in application.properties. How could one do this? tia, mark --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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]