I was interested in the same issue and did not find a good solution, so
I submitted a bug report:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1289

It does make sense for an ActionForm to have access to the context: not
just the session, but also request, response, servlet context and
servlet config.  ActionForms need to be able to access other beans held
in the context, participate in i18n and do other context-dependent
operations.

However, I understand that the whole issue of associating forms with the
context is a gnarly one. These forms are accessed by both actions and
JSPs.  JSPs access their context via PageContext, which conveniently
aggregates all relevant pieces of context: request, response, session,
servlet context and servlet config.  Actions, on the other hand do not
have anything of that sort, they get all these pieces separately.  As a
result of all this, it is unclear what the context-binding API on
ActionForm should be.

Maybe we need to create a whole new object: StrutsContext and make it
aggregate all levels of the context.

What do you think?

Dmitri Plotnikov
CTO
PLOTNIX, Inc

[EMAIL PROTECTED] wrote:

> I want to add a function to all of my forms in which the
> form is capable of initialising its contents. e.g.
>
> public void initUsingSession(HttpSession session)
>
> I want to pass the session to this function so that I can
> populate values on the form depending on what is
> stored in the session.
>
> The trouble with this is that when would I call this
> function?  I looked in the FormTag class, and I noticed
> that if it couldn't find the form class then it just created
> a new instance of it.  This means I can't call that
> function.
>
> Any ideas?
>
> Cheers
> Kris


Reply via email to