2.7. Accessing Message Resources from a Database
Problem
You want to store all labels, messages, and other static text in a
database rather than a properties file, while still being able to
access the values using the
bean:message
tag.
Solution
Download the OJBMessageResources distribution from http://prdownloads.sourceforge.net/struts/ojb-message-resources.zip?download.
Extract the ZIP file into a directory on your computer.
Copy the ojb-msg-res.jar file from the ojb-message-resources/dist folder into your application's WEB-INF/lib folder.
Copy the properties, XML, and DTD files from the ojb-message-resources/config folder to your application's src folder. When you build your application, these files must be copied to the WEB-INF/classes folder.
Create the tables to hold the Objec Relational Bridge (OJB) metadata tables. OJB uses these tables to keep internal mapping information. Example 2-12 shows the data definition SQL that creates these tables for the MySQL database. These statements for other databases are included with the OJB distribution.
Example 2-12. OJB metadata DDL (MySQL)
CREATE TABLE ojb_dlist ( ID int NOT NULL default '0', SIZE_ int default NULL, PRIMARY KEY (ID) ) TYPE=MyISAM; CREATE TABLE ojb_dlist_entries ( ID int NOT NULL default '0', DLIST_ID int NOT NULL default '0', POSITION_ int default NULL, OID_ longblob, PRIMARY KEY (ID) ) TYPE=MyISAM; CREATE TABLE ojb_dmap ( ID int NOT NULL default '0', SIZE_ int default NULL, PRIMARY KEY (ID) ) TYPE=MyISAM; CREATE TABLE ojb_dmap_entries ...
Get Jakarta Struts Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.