Sorry, forgot to 'reply-to-all'.
-Josh
---------- Forwarded message ----------
From: josh marotti <marotti@xxxxxxxxx>
Date: Jul 28, 2005 11:59 AM
Subject: Re: [cinjug-users] Simple Struts Tag Question
To: John Olmstead <jolmstead2k@xxxxxxxxx>
The simple answer is use html:optionsCollection instead of html:options. ;)
The complex answer comes from the API docs:
The collection of values actually selected depends on the presence or
absence of the name and property attributes. The following
combinations are allowed:
* Only name is specified - The value of this attribute is the name
of a JSP bean in some scope that is the collection.
* Only property is specified - The value of this attribute is the
name of a property of the ActionForm bean associated with our form,
which will return the collection.
* Both name and property are specified - The value of the name
attribute identifies a JSP bean in some scope. The value of the
property attribute is the name of some property of that bean which
will return the collection.
html:options always confuses me for the reason above, which is why I
tend to use html:optionsCollection when I can.
Hope that helps,
Josh
On 7/28/05, John Olmstead <jolmstead2k@xxxxxxxxx> wrote:
> 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(PageContextImpl.java:825)
>
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.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.java: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.java:1069)
>
> org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.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(ReplyHeaderFilter.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_jsp.java:349)
>
> org.apache.jsp.newuserpage_jsp._jspx_meth_c_if_1(newuserpage_jsp.java:257)
> 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.java: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.java:1069)
>
> org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.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(ReplyHeaderFilter.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
>
>
|