You need to set the collection to actionform every time when page loads if
there are many actionforms in request scope.

If the actionform is in session then it is required to set the collection
when page loads.

It depends on how your application is designed in terms of actionforma and
their properties



*************************
        TestUtil.Java
*************************
    public static Vector vechospitals;   // holds hospitals
    static
    {
        vechospitals= new Vector();

        vecRFQView.addElement(new LabelValueBean("Select Hospital ","0"));
// default selected

         // if the hospitals are predifined
        vecRFQView.addElement(new LabelValueBean("hospital 1","1"));
        vecRFQView.addElement(new LabelValueBean("hospital 2","2"));
         // if the hospitals are from database

         vecRFQView.addElement(new
LabelValueBean(resultset.getString("hospital_name"),resultset.getString("hos
pital_id")));


    }
        *************************
        In action class
        *************************
        // set View Collection for Dropdownbox in actinform

        testActionForm.setHospitals(TestUtil.vechospitals);
        *************************
        In actionForm class
        *************************

     /**
      * Holds list of Hospitals Collection
      */
     private Vector vechospitals=null;

 /**
      * @return Returns the vechospitals.
      */
     public Vector getHospitals() {
         return vechospitals;
     }



     /**
      * @param vechospitalsThe vechospitals to set.
      */
     public void setHospitals(Vector vechospitals) {
         this.vechospitals= vechospitals;
     }






-----Original Message-----
From: Leon Rosenberg [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 03, 2007 12:28 AM
To: Struts Users Mailing List
Subject: Re: Performance issue


The easiest way is to initialize the data once in the
init(ServletConfig) method of the servlet and put them into the
application scope (servletcontext). The struts tags will be able to
access the data directly, so you don't need to change a bit.
Of course the data structures theirself must be threadsafe to access,
which shouldn't be a problem if you are only reading them.

Alternatively you can perform this in a static initializer in a action
and put them in the request scope of each request (if you have a
common code block all actions are passing through, like authorization)
or into the application scope on first request (which would need a bit
of synchronization with double checked locking)

regards
leon

On 1/2/07, Daniel Chacón Sánchez <[EMAIL PROTECTED]> wrote:
> Hi all, I'm using struts framework on my application, but I have a
> perfomance question.
>
> When my application starts I load objects in session that may or may not
> will be used (depends on what the user does),  for example I load the
health
> centers, hospitals, countries, etc, that will be available for the users
in
> html:selects, I know that to had many objects in session is not good, in
> fact each time the user click on one application option (menu) all the
> objects in session are erased, except the ones that I load on the start of
> the application. Is there a way (maybe a pattern) to load this objects in
> the moment that are needed, and not load all at the start of the
> application. This object are use on differents modules so I load them on
the
> start of the aplication and put them in sesion for not to go to the
database
> each time I need to load them on a html:select.
>
> any solution, idea? or that is the only way?
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to