You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Cheung <vi...@justware.co.jp> on 2006/08/15 07:51:39 UTC
how do struts resolve the variable?
Hi, all;
I create some action which have form on it.
Sometime I can access the ActionForm bean via classname,
sometime I can access it via variablename(*1), and sometime
I have to set it into request object (*2) to access it.
*1:
in Action, write this code, and access ActionForm via myForm.
MyActionForm myForm = (MyActionForm) form;
*2:
request.setAttribute("myForm",myForm);
Anyone can tell me the reason?
Regards;
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how do struts resolve the variable?
Posted by Li <am...@gmail.com>.
for your *1 (step 1?)
You can get ActionForm object from a set of parameters that passed to
your Action class
You can cast according to your form type (e.g. MyActionForm) accordingly.
for your *2 (step 2?)
You save the form to your session with a key called "myForm", after
that, you are using your "myForm" as bean not a ActionForm any more.
Which means, the ActionForm object that passed to your current action
class is totally different from the one you saved in the session ...
On 8/15/06, Michael Cheung <vi...@justware.co.jp> wrote:
> Hi, all;
>
> I create some action which have form on it.
> Sometime I can access the ActionForm bean via classname,
> sometime I can access it via variablename(*1), and sometime
> I have to set it into request object (*2) to access it.
>
> *1:
> in Action, write this code, and access ActionForm via myForm.
> MyActionForm myForm = (MyActionForm) form;
>
> *2:
> request.setAttribute("myForm",myForm);
>
> Anyone can tell me the reason?
>
> Regards;
> Michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
When we invent time, we invent death.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org