You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/06/05 15:10:02 UTC
Struts
Subject: Struts <select>/<options> tags usage...
From: "Scott Curtis" <sc...@smart421.com>
===
Hi,
I have a JSP with the following scriplet:
<%
// Set up the server names list
ServerNamesForm form =
(ServerNamesForm)request.getAttribute("serverNamesForm");
ArrayList list = form.getServerNames();
pageContext.setAttribute("serverNames", list);
%>
The List list contains a collection of beans with value/labelProperty values
in them. This code sets the list collection as an attribute of the
pageContext, ready for use in the following code:
<html:select name="serverNamesForm" property="theServerName">
<html:options collection="serverNames" property="value"
labelProperty="label" />
</html:select>
This works fine when simply loading the page. I then want the user to select
an option from the displayed combo box and click a button whose action maps
to anAction.do and subsequently an Action class that uses the selected
values (hopefully now stored in the ServerNamesForm). The button looks like
the following:
<input type="button" name="submit" value="Submit"
onclick="javascript:location='./anAction.do';"/>
Unfortunately when I click the button I get the following error message:
javax.servlet.jsp.JspException: Cannot find bean under name serverNames
at
org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:343)
at
org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:194)
at /serverNames.jsp._jspService(/serverNames.jsp.java:327)
I don't understand this as the page loads therefore the bean serverNames is
clearly found. I am not sure what could be the problem with it?
If that makes any sense and anyone can help I would be extremely grateful.
Thanks
- scott
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>