Thanks Paul, Putting Bean in scope and manually calling validate worked
for me. Appreciate your help. 


Thanks
Prakash

-----Original Message-----
From: Paul Benedict [mailto:[EMAIL PROTECTED] On Behalf Of
Paul Benedict
Sent: Sunday, December 03, 2006 2:12 PM
To: Struts Users Mailing List
Subject: Re: Problem with re displaying optionsCollection

If you put the list in request scope, it disappears when the request is
finished. That's why you're probably getting the error: the second
request (failed validation) is trying to re-display the collection, but
it no longer exists.

You should either (1) put the list in sesssion scope or (2) turn off
automatic validation, and put the list back into request scope before
calling form.valdiate()

Paul

Prakash Inuganti -X (pinugant - Digital-X, Inc. at Cisco) wrote:
> Hi,
> 
> I am having an issue with select list and not able to figure out a 
> resolution. Any help is greatly appreciated. Here is the scenario.
> 
> I have 2 action classes. One (Approve.do) for displaying the form with

> prepopulated values from database. A second Action(SaveApprove.do) to 
> take the form values and do validations and then do further business 
> process. The first action populates all select lists fine. But when I 
> submit the screen with new values and if any validation fails, it 
> gives me an error
> Servlet.service() for servlet jsp threw exception
> javax.servlet.jsp.JspException: Cannot find bean: "agreeStatus" in any

> scope
>       at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:935)
>       at
> org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsC
> ol
> lectionTag.java:173)
> 
> Code snapshots are below
> 
> ApproveAction class
> 
> labelvaluePairs2.add(new LabelValueBean("Select One", "Select One"));
>               while(iter.hasNext()){ //this is a result set from
database
>                       String val = (String) iter.next();
>                       labelvaluePairs2.add(new LabelValueBean(val,
val));
>               }
> //aForm.setAgreeStatus(labelvaluePairs2); -- this did not help where 
> aForm is the form instance and agreeStstus is list in Form.
>               request.setAttribute("agreeStatus", labelvaluePairs2);
return 
> (mapping.findForward("approve"));
> 
> SaveApproveAction class
> 
> if (!errors.isEmpty()) {
>       return (mapping.getInputForward());
> }
> 
> //save the form values to database
> And I am repeating the labelvaluePairs2 code above.(I started without 
> it but thought doing this would put it in scope, but it did not help) 
> return (mapping.findForward("success"));
> 
> Struts-config.xml
> 
>     <action path="/Approve" name="ApproveForm"
> type="approve.ApproveAction" scope="request" validate="false">
>       <forward name="approve" path="exs.approve"></forward>
>     </action>
>     <action path="/SaveApprove" name="ApproveForm"
> type="approve.SaveApproveAction" parameter="methodToCall"
> scope="request" input="exs.approve">
>       <forward name="success" path="exs.success"></forward>
>     </action>
> 
> Approve.jsp
> <bean:define id="appr" name="approveInfo" property="approveDetails"
> />//This is a bean with list of classes <html:select 
> property="agreementStatus" name="appr">
>       
> <html:optionsCollection name="agreeStatus" value="value"
label="label"/>
>                                               </html:select>
> 
> For good measure I added this in Action Form with getter and setter 
> methods List agreeStatus = null;
> 
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request) {
>               //request.setAttribute("agreeStatus", agreeStatus); --
This did not 
> help
>               //return super.validate(mapping, request);
>               ActionErrors errors = new ActionErrors();
>               return errors;
>       }
> 
> I have no idea how to redisplay the form when validations fail. Any 
> advise would be a great help. Thanks in advance.
> 
> 
> Thanks
> Prakash
> 
> 

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

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

Reply via email to