aspose file tools*
The moose likes Struts and the fly likes Single class for collection/select lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Single class for collection/select lists" Watch "Single class for collection/select lists" New topic
Author

Single class for collection/select lists

andrew bills
Greenhorn

Joined: Dec 07, 2004
Posts: 1
Hi

I'm new to struts and want to know if it's possible like webwork to store all my html select lists (collections) in a single class to have them loaded at startup (which I also don't know how to do)

In workwebwork I can do this
public class DataList extends ActionSupport
{
static List states = new ArrayList();
static List hospitalTypes = new ArrayList();
static List extrasTypes = new ArrayList();

}

ActionSupport is webwork specific, does Struts have something like this?

I know the method of putting the collection object in the session or request in the Action but I think that's just unnecessary coding and memory use.

Using the struts select tag for a collection is it possible to access the static lists that I have defined in a class?

<html:select name="employeeForm" property="department">
<html ptions collection="departments" property="id" labelProperty="description"/>
</html:select>

I don't want to have to create bean classes for every single select list in my website, and I don't want to have to put the lists in session/request in every Action. I know there must be way. Thanks!
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
As far as I know that method doesn't work with a list as struts needs to know the type of bean in the list in order to find the getter methods. If you change your data to being stored in arrays then you just do a bean efine before your select box on the array ensuring you set the type attribute of the tag to be your array type eg. com.myCompany.myBean [], the id of this define tag goes into your collection field and you can now access the properties.
[ December 07, 2004: Message edited by: John Smith ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Single class for collection/select lists