struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Prakash Inuganti -X \(pinugant - Digital-X, Inc. at Cisco\)" <pinug...@cisco.com>
Subject Problem with re displaying optionsCollection
Date Sun, 03 Dec 2006 17:49:59 GMT
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(OptionsCol
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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message