struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "M Nadzaruddin Kahar" <mnadzarud...@hotmail.com>
Subject Message Resources From Database
Date Fri, 02 May 2003 08:00:10 GMT
Hi.

I found the thread with regards to creating message resources from a
database. I couldn't get to the sample that James Mitchell has worked on.
That's why I am posting this message. Another reason is that I got
frustrated trying to find the proper message id for a particular message in
nagoya.apache.org archive list. I only used the msgId given in the URL. I
guess it doesn't work that way because each time I sent a request to
struts-dev-get.xxx@jakarta.apache.org (xxx=msgId) I kept getting the wrong
message.

Anyway, I followed the struts documentation in trying to create a custom
MessageResources from a database. According to the documentation, we need to
subclass both MessageResources and MessageResourcesFactory. I did that and I
named both of them DatabaseMessageResources and
DatabaseMessageResourcesFactory respectively. However, later on I realized
that method MessageResourcesFactory.createResources only accepts a string.
Since every time a factory is created it's casted to
MessageResourcesFactory, no matter what we do the subclass ( add some
methods to accept servlet context for example ) won't be seen. So all I
could do was to play around with String config parameter. It was pretty much
useless because I wanna make use the datasource created from
struts-config.xml. Since the datasource is stored in the servlet context,
and if I can't pass the servlet context to my DatabaseMessageResources, I
couldn't do anything. Then I thought perhaps I could simply hard code the
connection details within DatabaseMessageResources itself. This proved
pointless because if I do it that way, I won't be using the connection pool
since the connection pool is stored in the servlet context as well. So I am
pretty much stuck.

Later on I found out James Mitchell has implemented some sort of work around
for this. So I am kind of curious as to how he managed to do it. I don't
know why the design of MessageResources is pretty much limited in
perspective. It only looks at retrieving the resources from properties
files. It's not flexible at all. To be honest I am not a fan of storing
resources in files. It's going to get cumbersome to maintain and besides
it's difficult to enforce data security on them. If we put them in a
database, it's a lot easier to establish their relationship with the rest of
the data model of an application.

The framework of a company that I have worked for used cache to store the
resources. It puts it in the session and it's initialized by the controller
servlet. I think someone mentioned about using cache as well, which I think
is definitely a good idea. I don't know a whole lot about fulcrum but I must
have stumbled upon some message in a forum or something that we can actually
synchronize it with the current data in our database.

So can someone tell me how to work around this problem please.

Thanks.
Naz

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Mime
View raw message