Re: Cannot Find Bean in Scope Request
What about putting the object PageBeans, which is actually a Collection, in an application scope. When the object is no longer in use, code: getComputer().getPlug().pull(); Do you think this approach is going to work? --- Jeff Beal <[EMAIL PROTECTED]> wrote: > Caroline Jen wrote: > > Q1. How come I do not see validation warning > messages? > > I have prepared validation.xml and put it > together > > with the validator-rules.xml in the > AppName/WEB-INF > > directory. I have also prepared the warning > messages > > in the > > > AppName/WEB-INF/classes/resources/application.properties > > corresponding to the value of the 'key' > > attributes. > > The idea with form validation is that validation > errors should be > displayed close to where the errors occurred -- that > is, on the input > form. When Struts detects validation errors, > control is returned to the > resource identified in the input attribute of the > ActionMapping, which > is typically coded in such a way that the form is > populated with exactly > what the user typed into them (which is why form > bean attributes are > usually all Strings) and the errors are displayed > next to each field in > error. > > In your case, part of the JSP page is trying to read > from a request bean > that was originally populated in some other action > as part of another > request. When the tag is called from > the JSP page, it > throws a ServletException. Struts at this point is > completely out of > the picture (it forwarded control to the JSP page), > so the default JSP > exception handling mechanism kicks in and you get > something ugly. > > > > Q2. What should I do? My action servlet passes > this > > Collection PageBeans in a request scope to create > a > > drop-down menu in the 'content.jsp'. If > validation > > errors occur and the control returns to the > > 'content.jsp', I have the error message 'cannot > find > > bean PageBeans' in scope request'. How to handle > this > > kind of situation? > > That's a trickier question and depends a lot on how > the PageBeans bean > was originally populated. You will probably need to > write an Action > whose execute method reads something like: > > public ActionForward execute(...) { > if (request.getAttribute("PageBeans") == null) > request.setAttribute("PageBeans", > model.getPageBeans()); > return mapping.findForward("success"); > } > > Then, create an action mapping like: > type="new.action.from.above"> > > > > > and change all references to .frame.Content to the > new action path. > > > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot Find Bean in Scope Request
Caroline Jen wrote: Q1. How come I do not see validation warning messages? I have prepared validation.xml and put it together with the validator-rules.xml in the AppName/WEB-INF directory. I have also prepared the warning messages in the AppName/WEB-INF/classes/resources/application.properties corresponding to the value of the 'key' attributes. The idea with form validation is that validation errors should be displayed close to where the errors occurred -- that is, on the input form. When Struts detects validation errors, control is returned to the resource identified in the input attribute of the ActionMapping, which is typically coded in such a way that the form is populated with exactly what the user typed into them (which is why form bean attributes are usually all Strings) and the errors are displayed next to each field in error. In your case, part of the JSP page is trying to read from a request bean that was originally populated in some other action as part of another request. When the tag is called from the JSP page, it throws a ServletException. Struts at this point is completely out of the picture (it forwarded control to the JSP page), so the default JSP exception handling mechanism kicks in and you get something ugly. Q2. What should I do? My action servlet passes this Collection PageBeans in a request scope to create a drop-down menu in the 'content.jsp'. If validation errors occur and the control returns to the 'content.jsp', I have the error message 'cannot find bean PageBeans' in scope request'. How to handle this kind of situation? That's a trickier question and depends a lot on how the PageBeans bean was originally populated. You will probably need to write an Action whose execute method reads something like: public ActionForward execute(...) { if (request.getAttribute("PageBeans") == null) request.setAttribute("PageBeans", model.getPageBeans()); return mapping.findForward("success"); } Then, create an action mapping like: and change all references to .frame.Content to the new action path. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot Find Bean in Scope Request
Yeah, thank you for sheding light on the problem I have. My code had worked fine until form validation was added. I was testing if validation worked. Therefore, I intentionally left all text fields blank, menu not selected, and submit the form. Apprarently, the control returned to the 'content.jsp' due to validation errors. Q1. How come I do not see validation warning messages? I have prepared validation.xml and put it together with the validator-rules.xml in the AppName/WEB-INF directory. I have also prepared the warning messages in the AppName/WEB-INF/classes/resources/application.properties corresponding to the value of the 'key' attributes. Q2. What should I do? My action servlet passes this Collection PageBeans in a request scope to create a drop-down menu in the 'content.jsp'. If validation errors occur and the control returns to the 'content.jsp', I have the error message 'cannot find bean PageBeans' in scope request'. How to handle this kind of situation? --- Jeff Beal <[EMAIL PROTECTED]> wrote: > Caroline Jen wrote: > > The message is confusing because PageBeans > (plural) is > > a Collection of PageBean (singular). Upon > successful > > execution of a servlet, PageBeans (plural) is > passed > > in a request scope to help creating a drop down > menu > > in 'content.jsp'. And the 'content.jsp' with the > > drop-down menu (see the code below) is displayed > > successfully. PageBean is a regular JavaBean, > which > > currently has only one property called 'name' (I > keep > > it simple for testing purpose). > > > > This problem occurred when I click on the Submit > > button of this form in the 'content.jsp'. > Althouth > > PageBeans (plural) is used to create a drop-down > menu > > in this form, PageBeans (plural) is irrelevant in > the > > subsequest steps. Why do I get '[ServletException > > in:/frame/content/content.jsp] Cannot find bean > > PageBeans in scope request' by clicking on the > Submit > > button of the form? > > Is it possible there is a form validation error > occurring on submit? > That would return control to content.jsp and cause > the error you are > seeing, I think. > > -- Jeff Beal > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot Find Bean in Scope Request
I tried your suggestion: 1. deleted the tag; and 2. use the tags. The drop-down menu gets displayed without problem. But, when I click on the Submit button to submit that form, I still get the same error message 'cannot find bean PageBeans in scope request'. PageBeans (plural) is a Collection of individual JavaBean; in my case, it is PageBean (singular). --- Wendy Smoak <[EMAIL PROTECTED]> wrote: > From: "Caroline Jen" <[EMAIL PROTECTED]> > > The error message that appears in the browser > (runtime > > problem, not compilation problem) is: > > '[ServletException in:/frame/content/content.jsp] > > Cannot find bean PageBeans in scope request' > > Partial content.jsp code: > > > scope="request" type="java.util.ArrayList" /> > > FWIW, I have lots of things in session scope, some > in request scope, and I > have *no* tags. I place them in the > appropriate scope in the > Action code. > > Example... > > property="key" > labelProperty="value"/> > > > It works fine... the tags find the collection in > whatever scope it's in. I > believe it looks in order: > page|request|session|application scope and uses > the first one it finds, but I could be making that > up. :) > > -- > Wendy Smoak > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot Find Bean in Scope Request
Caroline Jen wrote: The message is confusing because PageBeans (plural) is a Collection of PageBean (singular). Upon successful execution of a servlet, PageBeans (plural) is passed in a request scope to help creating a drop down menu in 'content.jsp'. And the 'content.jsp' with the drop-down menu (see the code below) is displayed successfully. PageBean is a regular JavaBean, which currently has only one property called 'name' (I keep it simple for testing purpose). This problem occurred when I click on the Submit button of this form in the 'content.jsp'. Althouth PageBeans (plural) is used to create a drop-down menu in this form, PageBeans (plural) is irrelevant in the subsequest steps. Why do I get '[ServletException in:/frame/content/content.jsp] Cannot find bean PageBeans in scope request' by clicking on the Submit button of the form? Is it possible there is a form validation error occurring on submit? That would return control to content.jsp and cause the error you are seeing, I think. -- Jeff Beal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot Find Bean in Scope Request
From: "Caroline Jen" <[EMAIL PROTECTED]> > The error message that appears in the browser (runtime > problem, not compilation problem) is: > '[ServletException in:/frame/content/content.jsp] > Cannot find bean PageBeans in scope request' > Partial content.jsp code: > scope="request" type="java.util.ArrayList" /> FWIW, I have lots of things in session scope, some in request scope, and I have *no* tags. I place them in the appropriate scope in the Action code. Example... It works fine... the tags find the collection in whatever scope it's in. I believe it looks in order: page|request|session|application scope and uses the first one it finds, but I could be making that up. :) -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]