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\)" <>
Subject Problem with re displaying optionsCollection
Date Sun, 03 Dec 2006 17:49:59 GMT

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 ( for displaying the form with
prepopulated values from database. A second Action( 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
	at org.apache.struts.taglib.TagUtils.lookup(

Code snapshots are below

ApproveAction class

labelvaluePairs2.add(new LabelValueBean("Select One", "Select One"));
		while(iter.hasNext()){ //this is a result set from
			String val = (String);
			labelvaluePairs2.add(new LabelValueBean(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"));


    <action path="/Approve" name="ApproveForm"
type="approve.ApproveAction" scope="request" validate="false">
    	<forward name="approve" path="exs.approve"></forward>
    <action path="/SaveApprove" name="ApproveForm"
type="approve.SaveApproveAction" parameter="methodToCall"
scope="request" input="exs.approve">
    	<forward name="success" path="exs.success"></forward>

<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"/>

For good measure I added this in Action Form with getter and setter
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.


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