Thanks - the real issue is that the Collections are added to scope in
the action class. When validation fails on the form bean, the action
class (I think) is bypassed and so the Collection are not re-added to
the request and go out of scope. I thought the bean define tag would do
the trick, but it is not working.

-----Original Message-----
From: Keith Bacon [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 07, 2001 2:17 AM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: Problem using <bean:define> toScope parameter

I hope I have this right! 
What that <bean:define says is:-
Get the bean industrySectortList(name=) from the
request(scope=) & add it to the request(toScope=) as
industrySectortList(id=).

You don't need that whole <bean:define.

The <html:select looks for your bean in the request by
default (as you haven't mentioned scope in the
html:select)

You have to remember to re-add your bean to the
request after validation that fails - so the
re-display of the original form has access to it.
I hope this makes sense & helps.
Keith.

--- Rob Parker <[EMAIL PROTECTED]> wrote:
> I am having trouble with the <bean:define> tag,
> specifically the toScope
> parameter.
> 
> Here is the situation:
> 
> I set up some collections in an action class to use
> as <select> options in a
> form and set them as attributes on the request
> object. These collections
> contain information pulled from a database,
> customized for different sets of
> users. Everything works perfectly unless there is a
> problem with validation
> in the associated user form. In that case, the
> collection "beans" go out of
> scope and and the jsp call results in an exception
> saying that the
> collection bean cannot be found in the request
> scope. Here is some example
> code to hopefully make everything a bit clearer.
> 
> In the action class:
> 
> ...
> Collection industrySectorList =
> optionGenerator.getIndustrySectorList(connection,
> userID);
> request.setAttribute("industrySectortList",
> industrySectorList);
> ...
> 
> In the jsp:
> ...
> <bean:define id="industrySectorList"
> name="industrySectorList"
> scope="request" toScope="request"
> type="java.util.Collection"/>
> ...
> <html:select value="applicantForm"
> property="industrySectorID" >
>       <html:options collection="industrySectorList"
> property="value"
> labelProperty="label"/>
> </html:select>
> ...
> 
> If I understand correctly, when user form validation
> fails, the associated
> action is bypassed and the request is forwarded back
> to the originating jsp
> page. How can I make sure that the collection beans
> necessary to display
> option lists stay in scope so that I don't get an
> exception? Why doesn't the
> toScope parameter in the <bean:define> tag work in
> this case? Thanks,
> 
> Rob
> 
> By the way, the exact exception that I get is:
> javax.servlet.jsp.JspException: Cannot find bean
> industrySectorList in scope
> request
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to