What I do is this. I take advantage of Java language, create a static final of a
default primitive array
list
public final static String [] DEFAULT_STR_LIST = new String[0]
I can use that to initialise every form attribute that is a primitive string array.
This is useful for say `DefaultActionForm' base class, especially if you have
accessor and mutators that support multiple selection elements like checkbox, or
multiple
selection list boxes
public String [] getSelectionItems() { .... }
public void setSelectionItems( String [] ) { .... }
The same idea is can be used for Collections.
public final static List DEFAULT_LIST = new ArrayList();
PS: But be careful if your List are not meant to be shared!
I fill up all the select elements from the database, so I query the database with SQL
and
save the data using the accessor/mutators of nested business objects.
I also store the action form as `session' objects.
Now I have a question? Has any one implemented at `LeaseTimeContainer' that
effectively removes old `session' attributes from the HttpSession.
I have thinking of writing a super SessionLeaseTimeContainer that does this:
(1) Knows how to iterate through every httpsession in the wep app.
(2) Knows how to remove object from the HttpSession
that have the interface `LeaseTimeAttribute'
public interface LeaseTimeAttribute() {
public void unlease( HttpSession session );
}
I have not done this, because we do not have say 1000's of users and 50 different
action forms. But I can see that this would be a problem for some big user sites?
How would you clean all those "Session" bean form objects that have not
been used for more 25 minutes or so? Assume the users stay log on the web app
for more than 30 minutes default.
--
Peter Pilgrim ++44 (0)207-545-9923
............................................ Swamped under electronic mails
---------------------------------------- Message History
----------------------------------------
From: Rick R <[EMAIL PROTECTED]> on 22/04/2002 13:30 AST
Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:
Subject: Where is it best to populate default form bean collections etc?
The question I have is it ok to set up the default select lists inside the form bean
by calls to some other business logic? For example...
private dogsArray = business.getDogsArray();
then your normal set and get method.
I tend to thin this probably isn't a good idea and it would be best to have some
action class create the array and then call the appropriate form bean set method. I'm
not sure though.
--
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorized copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>