Re: Struts and Result Beans

2006-03-27 Thread Asad Habib



On Mon, 27 Mar 2006, Dave Newton wrote:


Asad Habib wrote:

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.


You need that anyway, as a user might be on the site over the midnight hour.

The bean can just return the current date every time the accessor is called.


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?


Sure.

Just out of curiosity, what other design patterns were you considering?


This is the only one that I could think of that was applicable. If you 
know of any others, please let me know. Thanks.



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]



Re: Struts and Result Beans

2006-03-27 Thread Dave Newton
Asad Habib wrote:
> 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.

You need that anyway, as a user might be on the site over the midnight hour.

The bean can just return the current date every time the accessor is called.

> 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?

Sure.

Just out of curiosity, what other design patterns were you considering?

Dave



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



Re: Struts and Result Beans

2006-03-27 Thread Asad Habib


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]



Re: Struts and Result Beans

2006-03-27 Thread Dave Newton
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.

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 ;)

> (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]