You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by James Mitchell <jm...@telocity.com> on 2002/10/11 01:25:56 UTC

DBMessageResources - It's finally finished.

What is it?
-----------
If you've followed recent discussions on the struts-user list.  There has
been a flurry of discussion over getting ApplicationResources messages from
a database.

I have finally finished a release of an implementation of MessageResources
that grabs the key-value pairs from a database.  It uses the popular (and
FREE) O/R Mapping Tool OJB for the persistence layer, so if you are already
using it, or considering it in the future, it will fit seemlessly into your
project.

Setup is easy and converting your current application should take no more
than an hour.  Most of the work is getting your .properties file into the
database.

Databases supported are only limited by what OJB supports.  It currently
supports every major vendor.


What can it do?
---------------
  - As mentioned above, storing and retrieving your application resources
from a RDBMS
  - Full support for Locale and Sub Application Modules
  - Configurable database mapping (OJB style)
  - Changes are immediately available to your application, when using OJB's
    persistence broker to modify them.  (I will have samples of doing this
soon.)


Where can I get it?
-------------------
I've posted a zip file on my server which will extract into a buildable
project that I've setup which is the struts-example (1.1b) modified to use
this extension.

For detailed setup, please read the readme.txt in the project-files folder.

I have tested this on Tomcat 4.0.4, JBoss3.0.3 w/embedded Tomcat 4.1.12, and
Tomcat 4.1.12 using MySql database.  Full database scripts are provided.

To download, go to:

  http://www.open-tools.org/struts-atlanta/downloads

  *If my DSL craps out on me, just shoot me an email, and I'll send it
   to you via e-mail.


ToDo Items:
-----------
 - Convert the code to load as a struts plugin for better management and
lifecycle support.
 - Administrative actions/jsp (possibly a subapp) for managing the data.
 - Conversion utility to parse a .properties file and create a .sql file.
 - Support for GlobalDebugMode, when this is enabled, all messages
   are returned as "###" or some configurable value.

     This helps on large projects when, under pressure of time contraints,
     developers quickly (and without meaning to - Honest;) hard code values
     while cranking out code, and can assist in quickly determining if all
     messages are actually coming from the bundle.




James Mitchell
Software Engineer/Struts Evangelist
http://www.open-tools.org


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DBMessageResources - It's finally finished.

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
James Mitchell wrote:
> What is it?
> -----------
> If you've followed recent discussions on the struts-user list.  There has
> been a flurry of discussion over getting ApplicationResources messages from
> a database.

Well done James!

>   - Changes are immediately available to your application, when using OJB's
>     persistence broker to modify them.  (I will have samples of doing this
> soon.)

Now thats a handy feature.

> ToDo Items:
> -----------
>  - Conversion utility to parse a .properties file and create a .sql file.

I used Ant's <replaceregexp> to build the file I needed (it wasn't a 
.sql, but a .xml file - I'm using a different O/R tool).  It was quite 
simple and I could provide an example of this if folks are interested.

>  - Support for GlobalDebugMode, when this is enabled, all messages
>    are returned as "###" or some configurable value.
> 
>      This helps on large projects when, under pressure of time contraints,
>      developers quickly (and without meaning to - Honest;) hard code values
>      while cranking out code, and can assist in quickly determining if all
>      messages are actually coming from the bundle.

Indeed this is very handy, but there is one gotcha here, and I had to 
make a special case in my DbResources implementation to account for it. 
  The org.apache.struts..[can't remember the exact details].format keys 
that the <bean:write> tag looks for must return null or a valid 
formatting string.  I just coded a 
key.startsWith("org.apache.struts....") special case to ensure it 
returns null if the key is not found, rather than my regular default 
value of not found keys of "<locale> : <config> : <key>".

A debug mode would be handy, and it was quite interesting to see my 
first iteration of my DbResources which did not do database lookup but 
rather returned the key it was looking up.  It made it readily apparent 
where we were using resources and where strings were hardcoded in the JSP.

	Erik



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>