John,
I generally use a "setup" action that sets up the option lists and then
calls the forward to display. For example, a link to a form on page 1
goes to an action class that sets up the form values and populates the
form object, sets default values, then forwards to the display (JSP
page).
My setup action may have something like:
optionQueries op = new optionQueries();
optionList olform = new optionList();
ArrayList CountryOptions = op.getCountrys(false,null); // I have my own
helper classes to build option list arrays...
olform.setOptions((String[]) CountryOptions.get(0), (String[])
CountryOptions.get(1));
// The gist of it is that I put the optionlist in the form object
theForm.setValue("SupplierOptionList",olform);
// Set the value of the form element itself on the display page
theForm.setValue("county_list","");
return (mapping.findForward("yourformpage"));
Assuming you have a struts form element on your display page with the
name of country_list
<html:text property="value(country_list)" size="15"/>
BTW, this example uses a map backed form, which is why it uses value()
and setValue(), but the example should work the same on a regular
ActionForm.
Hope this helps,
Rich
-----Original Message-----
From: John Olmstead [mailto:jolmstead2k@xxxxxxxxx]
Sent: Thursday, July 28, 2005 11:44 AM
To: users@xxxxxxxxxx
Subject: [cinjug-users] Simple Struts Tag Question
Ladies and Gentlemen;
I am trying to populate an html drop down with the Struts select and
options tags. The countryList bean referenced in the collection is an
ArrayList of struts LabelValue beans.
Here is the tag snippet:
<html:select name="userInfoForm" property="citizenship">
<html:options name="countryList" property="value"
labelProperty="label"/>
<html:option value="">OTHER</html:option>
</html:select>
The stack trace(below) indicates that the Struts options tag is trying
to call getValue() method on the list object itself. Omitting the
property and labelProperty attributs of the tag results in the Object
toString() being invoked with the correct values of the labal and value
properties of the LabelValue Bean.
Any assistance is much appreciated.
Thanks;
John Olmstead
The resulting Stack Trace is:
javax.servlet.ServletException: No getter method available for property
value for bean under name countryList
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageCont
extImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContex
tImpl.java:758)
org.apache.jsp.newuserpage_jsp._jspService(newuserpage_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
va:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav
a:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestPr
ocessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
r.java:75)
root cause
javax.servlet.jsp.JspException: No getter method available for property
value for bean under name countryList
org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:425
)
org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:289)
org.apache.jsp.newuserpage_jsp._jspx_meth_html_options_0(newuserpage_jsp
.java:729)
org.apache.jsp.newuserpage_jsp._jspx_meth_html_select_0(newuserpage_jsp.
java:696)
org.apache.jsp.newuserpage_jsp._jspx_meth_html$1el_form_0(newuserpage_js
p.java:349)
org.apache.jsp.newuserpage_jsp._jspx_meth_c_if_1(newuserpage_jsp.java:25
7)
org.apache.jsp.newuserpage_jsp._jspService(newuserpage_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
va:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav
a:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestPr
ocessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
r.java:75)
John Olmstead
jolmstead2k@xxxxxxxxx
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------
You may unsubscribe from this mailing list by sending a blank email
addressed to:
users-unsubscribe@xxxxxxxxxx
--
Find additional help by sending a blank email addressed to:
users-help@xxxxxxxxxx
|