You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Amrinder Sandhu <am...@ucdavis.edu> on 2008/11/10 00:29:19 UTC

Cannot find bean in any scope when form contains errors

Hi,

I have an ExecuteTest action which returns a view. The action also sets up
some beans that the view will use to display data to the user. The view also
contains a form. Everything works when I go to the action, which shows me
the view. The page contains the data from the beans and the textbox inside
the form tag. If I enter valid data into the texbox and hit submit,
everything works great. But if I leave the textbox empty or type in invalid
data, I should get back error messages from the validate method of the form.
But instead I get a HTTP 500 error message saying Cannot find bean in any
scope. I see why I get this error message, but I can't seem to fix it.

How can I have that bean be set again if the validation fails? This seems
like a common issue, but did not find anything using google. Thanks in
advance.

Regards,
Amrinder

Re: Cannot find bean in any scope when form contains errors

Posted by Burton Rhodes <bu...@gmail.com>.
Can't help you there. Sorry.

On 11/9/08, Amrinder Sandhu <am...@gmail.com> wrote:
> Hi,
>
> Thank you for your response. It seems like Preparable is for Struts 2. I am
> using Struts 1.3.8. Any ideas for Struts 1.x?
>
> Regards,
> Amrinder Sandhu
>
>
> On Sun, Nov 9, 2008 at 3:51 PM, Burton Rhodes <bu...@gmail.com>wrote:
>
>> You need to have your action object implement Preparable (and perhaps
>> ModelDriven depending on your implementation) and set your action
>> member variables (or bean) in the Prepare method.  If there are
>> validation errors, this method will take care of your issue before
>> that error is recognized and since the 'execute' method won't be
>> called.
>>
>> On 11/9/08, Amrinder Sandhu <am...@ucdavis.edu> wrote:
>> > Hi,
>> >
>> > I have an ExecuteTest action which returns a view. The action also sets
>> up
>> > some beans that the view will use to display data to the user. The view
>> also
>> > contains a form. Everything works when I go to the action, which shows
>> > me
>> > the view. The page contains the data from the beans and the textbox
>> inside
>> > the form tag. If I enter valid data into the texbox and hit submit,
>> > everything works great. But if I leave the textbox empty or type in
>> invalid
>> > data, I should get back error messages from the validate method of the
>> form.
>> > But instead I get a HTTP 500 error message saying Cannot find bean in
>> > any
>> > scope. I see why I get this error message, but I can't seem to fix it.
>> >
>> > How can I have that bean be set again if the validation fails? This
>> > seems
>> > like a common issue, but did not find anything using google. Thanks in
>> > advance.
>> >
>> > Regards,
>> > Amrinder
>> >
>>
>> --
>> Sent from my mobile device
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

-- 
Sent from my mobile device

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Cannot find bean in any scope when form contains errors

Posted by Amrinder Sandhu <am...@gmail.com>.
Hi,

Thank you for your response. It seems like Preparable is for Struts 2. I am
using Struts 1.3.8. Any ideas for Struts 1.x?

Regards,
Amrinder Sandhu


On Sun, Nov 9, 2008 at 3:51 PM, Burton Rhodes <bu...@gmail.com>wrote:

> You need to have your action object implement Preparable (and perhaps
> ModelDriven depending on your implementation) and set your action
> member variables (or bean) in the Prepare method.  If there are
> validation errors, this method will take care of your issue before
> that error is recognized and since the 'execute' method won't be
> called.
>
> On 11/9/08, Amrinder Sandhu <am...@ucdavis.edu> wrote:
> > Hi,
> >
> > I have an ExecuteTest action which returns a view. The action also sets
> up
> > some beans that the view will use to display data to the user. The view
> also
> > contains a form. Everything works when I go to the action, which shows me
> > the view. The page contains the data from the beans and the textbox
> inside
> > the form tag. If I enter valid data into the texbox and hit submit,
> > everything works great. But if I leave the textbox empty or type in
> invalid
> > data, I should get back error messages from the validate method of the
> form.
> > But instead I get a HTTP 500 error message saying Cannot find bean in any
> > scope. I see why I get this error message, but I can't seem to fix it.
> >
> > How can I have that bean be set again if the validation fails? This seems
> > like a common issue, but did not find anything using google. Thanks in
> > advance.
> >
> > Regards,
> > Amrinder
> >
>
> --
> Sent from my mobile device
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Cannot find bean in any scope when form contains errors

Posted by Burton Rhodes <bu...@gmail.com>.
You need to have your action object implement Preparable (and perhaps
ModelDriven depending on your implementation) and set your action
member variables (or bean) in the Prepare method.  If there are
validation errors, this method will take care of your issue before
that error is recognized and since the 'execute' method won't be
called.

On 11/9/08, Amrinder Sandhu <am...@ucdavis.edu> wrote:
> Hi,
>
> I have an ExecuteTest action which returns a view. The action also sets up
> some beans that the view will use to display data to the user. The view also
> contains a form. Everything works when I go to the action, which shows me
> the view. The page contains the data from the beans and the textbox inside
> the form tag. If I enter valid data into the texbox and hit submit,
> everything works great. But if I leave the textbox empty or type in invalid
> data, I should get back error messages from the validate method of the form.
> But instead I get a HTTP 500 error message saying Cannot find bean in any
> scope. I see why I get this error message, but I can't seem to fix it.
>
> How can I have that bean be set again if the validation fails? This seems
> like a common issue, but did not find anything using google. Thanks in
> advance.
>
> Regards,
> Amrinder
>

-- 
Sent from my mobile device

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org