Internationalization of codetables.

2001-08-15 Thread Juraj Kazda

Hello friends,

first, I would like to thank you for answers to my previous quetion.

Now I have another problem - half architectural, half implementational. 

Imagine the situation (example):
One table is dedicated to data about 'pub' (name, address, kinds of
beer, ...). Kinds of beer is reference to code table, where I have
columns: code, type_en, type_de, ... - for every language I would like
to localize my application to there is one column with appropriate
translation of beer kind (bottle - Flasche - ...). This all is because I
would like to show to visitors of my page the kind of beer they can have
in selected pub in their language. What should be the best architectural
solution for retrieving data from code table (I will fill with them a
combo box)? Because code tables are almost (or long-time lasting) static
data, I was thinking about putting a Vector of beans with attributes
corresponding/matching the structure of code table. That means to make
one start-up servlet which will fill all the Vectors of code tables and
puts them in application scope context when the application starts. But
there is a problem: how to access connection pool defined by
struts-config.xml to obtain connection to database? Or dou you know how
to solve the whole problem better?


Thank you very much for help

With best regards

--jerry



Re: Internationalization of codetables.

2001-08-15 Thread Gregor Rayman

"Juraj Kazda" [EMAIL PROTECTED] wrote:

  Because code tables are almost (or long-time lasting) static
 data, I was thinking about putting a Vector of beans with attributes
 corresponding/matching the structure of code table. That means to make
 one start-up servlet which will fill all the Vectors of code tables and
 puts them in application scope context when the application starts. But
 there is a problem: how to access connection pool defined by
 struts-config.xml to obtain connection to database? Or dou you know how
 to solve the whole problem better?

You can either use JNDI connection pool. Or you can read the data in an
action and cache them then. I'd use the double checked singleton pattern:

Thing getThing() {
if (null == this.thing) {
synchronized(this) {
if (null == this.thing) {
// read the thing form the database
}
}
}
return thing;
}




Off-topic: double-checking (Was: Internationalization of codetables.)

2001-08-15 Thread John Yu

I think I read somewhere (javaworld?) that the double-checking pattern
for object locking is unsafe in Java. I can't remember the details. It's
something related to the way Java compiler optimising the generate code
by swapping statements silently.

At 01:52 pm 15-08-2001 +0200, you wrote:
You can either use JNDI connection
pool. Or you can read the data in an
action and cache them then. I'd use the double checked singleton
pattern:
Thing getThing() {
 if (null == this.thing) {
 synchronized(this) {
 if
(null == this.thing) {

// read the thing form the database
 
}
 }
 }
 return thing;
}

-- 
John
Yu
Scioworks Technologies 
e: [EMAIL PROTECTED] w:
+(65) 873 5989
w:
http://www.scioworks.com
 m: +(65) 9782 9610