Another potentially interesting possibility, although one I have to admit
I have not tried yet, is using the DependencyFilter in Java Web Parts.

Since an ActionForm is no different from any other class as far as the
filter would be concerned, it can instantiate it and place it in the
appropriate scope, which would really only mean session, since I'm pretty
sure Struts would overwrite it if it was request-scoped... as long as you
name it the same way Struts would name it, it should work, Struts should
find it in session and everything would work as usual.

The benefit is that you can do all sorts of initialization on it in a
declarative fashion, including calling certain methods on it, or passing
it off to some other object to configure it for you.  It's what I call a
"hybrid IoC" implementation... the dependencies are injected into either
request or session, not directly into a client object.  Different, but
still quite useful.

The only problem I can think of off the top of my head is that the filter,
while it can be configured a little more extensively than a standard
filter in terms of what paths cause it to fire, it still is an
all-or-nothing proposition, i.e., whatever objects are configured for it
to create will ALL be created for every path it is configured to fire on. 
Hmm, might be a nice enhahcement to make the dependencies have a path
attribute, but I digress...

Just a though anyway.  Might work, might not, I have to try it myself!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, September 22, 2005 2:39 pm, Wendy Smoak said:
> From: "ojay78" <[EMAIL PROTECTED]>
>
>> Could you give a example Code for that?
>
> You can see an example of form pre-population in the code for the
> MailReader
> example app:
>
> http://svn.apache.org/viewcvs.cgi/struts/apps/trunk/shared/src/java/org/apache/struts/apps/mailreader/actions/EditSubscriptionAction.java?rev=149010&view=markup
>
> This line:
>     PropertyUtils.copyProperties(subform, subscription);
> is what copies the values from the 'subscription' object to the form bean.
>
> --
> Wendy Smoak
>
>
> ---------------------------------------------------------------------
> 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