If you set 'validate="true"' in your action mapping, of course you will have
this error because the validation in that case will fail, it will SKIP the
action and go straight to the "input" (JSP) attribute for error displaying.
This setup would skip the action execute() method and no "eventTypes" object
would have been put into request scope for the JSP to see/find/use.  If you
are doing it that way, I recommend you set 'validate="false"' and add the
call for validation into your execute() method to ensure you always create
your "eventTypes" vector/object before you invoke validation (manually
invoking validation in this case).

If "eventTypes" never changes, you would be better off creating a
ServletContextListener to initialize the vector and put it in Application
scope for every JSP to use without recreating it every time.  I suggest this
since the names "StartFailure" and "LowMemory" label names sound like
something you would probably keep constant for all users.

Regards,
David

-----Original Message-----
From: Pankaj Gupta [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 17, 2006 12:29 AM
To: user@struts.apache.org
Subject: Problem with prepoulating form


Hi,

I am facing a problem with prepoulating the form. I am using following code
to prepopulate the form in my Action class:

Vector eventTypes = new Vector();
eventTypes.add(new LabelValueBean("StartFailure", "Value 0"));
eventTypes.add(new LabelValueBean("LowMemory", "Value 1"));
request.setAttribute("eventTypes", eventTypes );

and the following code in my jsp:
<html:select property="eventTypes" size="2" titleKey="
alarmEventFilter.selectKey.eventType" multiple="true">
<html:options collection="eventTypes" property="value" labelProperty="label"
/>
</html:select><html:errors property="eventType"/><br/>

The application works well when the validate() returns null but when the
validate() returns errors, it gives the following error:

SEVERE: Servlet.service() for servlet jsp threw exception
*

javax.servlet.jsp.JspException*: Cannot find bean under name *eventTypes*

I have no clue about it. Pl help.

regards,
Pankaj

**


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

Reply via email to