I was wondering where I should execute code to populate my dropdown boxes from my database in my Struts application? I guess I want to do this once and populate the bean and put in the appropriate scope.
You can do that if the number of datas in the list is less and list is constant(will change very rarely).E.g state name etc
What i would do is create a model class and create a static HashMap and store each list into the map.
E.g i would store list of states into ArrayList and then store that array list into hasp map under the key "StateList"
Similarly you can store other list that gonna stay constant int he database.This could avoid hitting database everytime.
But everytime you want to display the list, you have to check the Array list from the haspmap and if it is empty then go to database and retrieve the data and store it inthe hash map and then return the list from the hashmap.
Then you can put the list in the appropriate scope and forward to the requires pages.