Then I retrive optionsCollection from DAO "order by some_sort_colum_for_order". This puts them in order.
The data is accessed once for the application context ('cuase of DAO).
hth, .V
Haroon Rafique wrote:
Hi,
Long time lurker, first time poster.
I'm using struts 1.1. My question is rather general and may even be off-topic.
I use a ServletContextListener class for populating certain application-wide settings inside the contextInitialized() method. One of the requirements is that I need to maintain the order of the drop-down values. Might need to separate them by locale at a future stage as well.
So, for example my "phone types" collection looks as follows:
// set up list of phone types
Collection col = new ArrayList();
// FIXME: read from a properties resource bundle instead
col.add(new LabelValueBean("Business Tel.", "B"));
col.add(new LabelValueBean("Cell Phone", "C"));
col.add(new LabelValueBean("Pager", "D"));
col.add(new LabelValueBean("Fax - Mailing (local) address", "F"));
col.add(new LabelValueBean("Fax - Permanent (home) address", "G"));
col.add(new LabelValueBean("Fax - Business", "H"));
// place under PHONE_TYPE_KEY in application scope
servletContext.setAttribute(Constants.PHONE_TYPE_KEY,
col);
Later on, in my view, I can use the <html:options> tag to populate the drop-down. Hah! I used <html:options> in the previous sentence, so that makes this post partially on-topic.
So, far so good, as this is only development.
In production, I'm really supposed to get these values and labels from a database. It is acceptable to only load this once upon application startup as is the case now by using ServletContextListener. Making the call to the database upon application startup is not an option, however, a cron job is able to pull these values out and store them in a file.
Now my question to you is "what is the most convenient file structure which will let me meet my above-stated requirements?"
So, far I have thought of (and discounted):
1. ResourceBundle (since it will not keep the original order)
Likely candidates are:
1. custom code to read a .properties file which maintains the order (something along the lines of using getResourceAsStream() - have to think about locales).
2. Use Digester to read XML data (have to think about locales).
I'm pretty certain some of you must have run into this problem beforehand.
Can I call upon your experience to provide me with some input or point out something obvious that I may have missed?
Cheers, -- Haroon Rafique <[EMAIL PROTECTED]>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

