You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/01/17 21:40:38 UTC

cannot find bean error, when cliked on submit button

Created a jsp, whose struts config
<action
        path="/PrepareFacilityAction"
        type="PrepareFacilityAction"
        name="FacilityForm"
        scope="session"
        validate="false"
        input="/pages/Facility.jsp">
        <forward name="success" path="/pages/Facility.jsp" 
redirect="false"/>
     </action>
     <action
        path="/DispatchFacilityAction"
        type="DispatchFacilityAction"
        name="FacilityForm"
        scope="session"
        validate="true"
        input="/pages/Facility.jsp"
        parameter="method">
        <forward name="successSave" path="/PrepareFacilityAction.do" 
redirect="false"/>
        <forward name="successReturn" path="/PrepareSummAction.do" 
redirect="false"/>
     </action>


In the JSP have comboboxes.

PrepareFacilityAction

.....
....
request.setAttribute("List1", getList1(form));
...........
...........

The Jsp the combox is filled
...........
..........
<html:select name="FacilityForm" property="selected">
                            <html:options collection="List1" 
property="value" labelProperty="label"/>
                        </html:select>

..............
................



The JSP displayes fine with all the values in it. This JSP has required 
fields in it. Used validator.xml to define al lthe required fields.

There is a Save Button which is the submit button in the JSP. When clicked 
on Save want the validations to be done and be in the same JSP.

When Clicked on Save, it is not going into the DispatchFacilityAction

But getting the error in JSP
Cannot find bean under name List1 ------ This List1 was in the request when 
the JSP originally displayed.

Why is this?

How to fix this.

I hope I am clear with my explanation.

Thanks.

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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


Re: cannot find bean error, when cliked on submit button

Posted by Rick Reumann <st...@reumann.net>.
fea jabi wrote the following on 1/18/2006 9:24 AM:

>        request.set("List1 ", List1 );

Is this exactly what you are trying to type? (Is there even a set method 
in Request? Also note the extra space you have before the closing quote.)

You want request.setAttribute("List1", List1 );

Don't forget if you use "List1" as the name you'll have to pull it out 
as "List1" on the JSP.

(Side note, in Java instance variables are usually declared starting 
with a lowercase letter so I'd declare ArrayList Lis1 as 'list1')

-- 
Rick

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


Re: cannot find bean error, when cliked on submit button

Posted by fea jabi <zy...@hotmail.com>.
Initially I tried to do the same i.e placing the List1 in the form. But for 
some reason the options were not displaying.

I am using DynaValidatorForm and form-bean is defined in the struts config.

In my prepare action I have
LabelValueBean lblValueBean1 = new LabelValueBean("Visa", "V");
        LabelValueBean lblValueBean2 = new LabelValueBean("MasterCard", 
"M");
        LabelValueBean lblValueBean3 = new LabelValueBean("American 
Express", "AE");

        //Options
        ArrayList List1 = new ArrayList();
        List1 .add(lblValueBean1);
        List1 .add(lblValueBean2);
        List1 .add(lblValueBean3);

        request.set("List1 ", List1 );

> > The Jsp the combox is filled
> > ...........
> > ..........
> > <html:select name="FacilityForm" property="selected">
> >                             <html:options collection="List1"
> > property="value" labelProperty="label"/>
> >                         </html:select>

can you tell me how to define the collection in the form-bean so that it can 
be accessed by the JSP? As I tried this before and was not successful.

Thanks.


>From: Michael Jouravlev <jm...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: cannot find bean error, when cliked on submit button
>Date: Tue, 17 Jan 2006 13:20:42 -0800
>
> > In the JSP have comboboxes.
> >
> > PrepareFacilityAction
> >
> > .....
> > ....
> > request.setAttribute("List1", getList1(form));
> > ...........
> > ...........
> >
> > The Jsp the combox is filled
> > ...........
> > ..........
> > <html:select name="FacilityForm" property="selected">
> >                             <html:options collection="List1"
> > property="value" labelProperty="label"/>
> >                         </html:select>
> >
> > ..............
> > ................
> >
> >
> >
> > The JSP displayes fine with all the values in it. This JSP has required
> > fields in it. Used validator.xml to define al lthe required fields.
> >
> > There is a Save Button which is the submit button in the JSP. When 
>clicked
> > on Save want the validations to be done and be in the same JSP.
> >
> > When Clicked on Save, it is not going into the DispatchFacilityAction
> >
> > But getting the error in JSP
> > Cannot find bean under name List1 ------ This List1 was in the request 
>when
> > the JSP originally displayed.
> >
> > Why is this?
>
>Maybe because Struts tries to set current selection in the List1
>object, which has request scope and is already gone. Not sure about it
>though, I need to look into how Struts sets selected item for
>list-type property.
>
> > How to fix this.
>
>I would not create any objects outside ActionForm like you did with
>List1. Instead, I would define all objects that are needed to be
>displayed/updated as properties of ActionForm. This approach will keep
>all page-related objects in one place, and they all will be available
>at once.
>
>Michael.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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


Re: cannot find bean error, when cliked on submit button

Posted by Michael Jouravlev <jm...@gmail.com>.
> In the JSP have comboboxes.
>
> PrepareFacilityAction
>
> .....
> ....
> request.setAttribute("List1", getList1(form));
> ...........
> ...........
>
> The Jsp the combox is filled
> ...........
> ..........
> <html:select name="FacilityForm" property="selected">
>                             <html:options collection="List1"
> property="value" labelProperty="label"/>
>                         </html:select>
>
> ..............
> ................
>
>
>
> The JSP displayes fine with all the values in it. This JSP has required
> fields in it. Used validator.xml to define al lthe required fields.
>
> There is a Save Button which is the submit button in the JSP. When clicked
> on Save want the validations to be done and be in the same JSP.
>
> When Clicked on Save, it is not going into the DispatchFacilityAction
>
> But getting the error in JSP
> Cannot find bean under name List1 ------ This List1 was in the request when
> the JSP originally displayed.
>
> Why is this?

Maybe because Struts tries to set current selection in the List1
object, which has request scope and is already gone. Not sure about it
though, I need to look into how Struts sets selected item for
list-type property.

> How to fix this.

I would not create any objects outside ActionForm like you did with
List1. Instead, I would define all objects that are needed to be
displayed/updated as properties of ActionForm. This approach will keep
all page-related objects in one place, and they all will be available
at once.

Michael.

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


Re: cannot find bean error, when cliked on submit button

Posted by fea jabi <zy...@hotmail.com>.
thanks for sugesting the article.

I did implement the way you suggested.

Thanks.


>From: Rick Reumann <st...@reumann.net>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: cannot find bean error, when cliked on submit button
>Date: Tue, 17 Jan 2006 16:08:01 -0500
>
>fea jabi wrote the following on 1/17/2006 3:40 PM:
>
>>The JSP displayes fine with all the values in it. This JSP has required 
>>fields in it. Used validator.xml to define al lthe required fields.
>>
>>There is a Save Button which is the submit button in the JSP. When clicked 
>>on Save want the validations to be done and be in the same JSP.
>>
>>When Clicked on Save, it is not going into the DispatchFacilityAction
>>
>>But getting the error in JSP
>>Cannot find bean under name List1 ------ This List1 was in the request 
>>when the JSP originally displayed.
>>
>>Why is this?
>
>My guess is validation is failing and you are being returned to the page 
>where your List no longer is in scope. This is a classic problem when you 
>do not either a) use Session scope for your form or b) do not call your 
>form's validate method manually or c) aren't providing a way in the reset 
>method of your form bean to populate the request. I like solve it with 
>option b. More on it here: 
>http://www.learntechnology.net/validate-manually.do
>
>--
>Rick
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: cannot find bean error, when cliked on submit button

Posted by Rick Reumann <st...@reumann.net>.
fea jabi wrote the following on 1/17/2006 3:40 PM:

> The JSP displayes fine with all the values in it. This JSP has required 
> fields in it. Used validator.xml to define al lthe required fields.
> 
> There is a Save Button which is the submit button in the JSP. When 
> clicked on Save want the validations to be done and be in the same JSP.
> 
> When Clicked on Save, it is not going into the DispatchFacilityAction
> 
> But getting the error in JSP
> Cannot find bean under name List1 ------ This List1 was in the request 
> when the JSP originally displayed.
> 
> Why is this?

My guess is validation is failing and you are being returned to the page 
where your List no longer is in scope. This is a classic problem when 
you do not either a) use Session scope for your form or b) do not call 
your form's validate method manually or c) aren't providing a way in the 
reset method of your form bean to populate the request. I like solve it 
with option b. More on it here: 
http://www.learntechnology.net/validate-manually.do

-- 
Rick

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