On Mon, 27 Mar 2006, Dave Newton wrote:

Asad Habib wrote:
What is the best way to use result beans with Struts (i.e. beans that
are not associated with a form). In particular, I have a plugin class
that's called by the Struts action servlet upon startup and this class
calculates the current date. This date needs to be stored in a bean
having session scope and displayed on all pages in the application.
Currently, this bean is being instantiated in one of my actions and
placed in session scope.

Um... well, I would probably just place an instance of the "date
calculator bean" in the application scope unless you anticipate the date
being different for different users and not bother with the session
scope for something like this.

Well, your right since the date will be shared by all sessions. However, if I go this route I will need a method to update the date every time it changes.

I suppose a plugin is as good a place as any to instantiate a date
calculation bean.

Lastly, is there a design pattern that I could follow to achieve this?

A design pattern for putting a date calculation bean into a scope? You
might be over-analyzing this ;)

Sorry, I mean a design pattern that outlines how non-form beans should be used with Struts actions. Is a DTO applicable in this case?


(i.e. EJB is overkill).

Ya' think?

IIRC Frank's Java WebParts has a class (filter?) that will make sure
things are put into the appropriate scope based on a set of rules (I
like filters for things like this since they're not attached to Struts)
and it beats re-inventing it like I have several times and you don't
need to use a larger framework like Spring for "mini-IoC" things.

http://javawebparts.sourceforge.net/

Dave



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



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

Reply via email to