You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arron Bates <ar...@pacific.net.au> on 2002/03/26 05:45:17 UTC

Re: OptionsTag bug using nested property?

Your work-around is that much of a work-around, as it was the only 
solution up until a couple of weeks ago.

If you're running 1.1beta or something near it, you'll have the 
optionsCollection tag. It's a more natural fit to the system. Use the 
name attribute, to select the bean, the property attribute to get to the 
collection, label attribute which is the bean property of the item in 
the collection that is the label, and the value attribue the bean 
property of the item in the collection that is the value. If you're 
running this struts you could use...

<html:select property="province">
 <html:options name="beanName" property="provinceLookup.lookupData"
     label="provinceCode"
     value="provinceName" />
</html:select>

And the nested version, naturally works against the same bean as all the 
other tags, the property attribute relative to the others etc etc etc.
But your workaround is the standard solution for most people.

Arron.

Vladimir Levin wrote:

> I seem to have run into a bug with the struts OptionsTag custom
> tag when using a nested property. I am including the problem and my
> workaround, but if someone here has any advice or help, I'd love to
> have a cleaner solution than my workaround, so if someone here
> could help me out, it would be appreciated.
> By the way, I tried to use the nested tag library, and slammed into
> a brick wall... so if someone can show me code to make this work
> with nested taglib, also much appreciated.
>
> Here is my situation:
>
> I want to show a drop-down list of
> provinces in my JSP pages via the html:select and html:options tags.
> I have a class called ProvinceLookup, which caches a java.util.List.
> This list contains Province objects which expose a getProvinceCode and
> a getProvinceName method.
>
> The Evil Bug?: cannot reference nested properties in 'OptionsTag' using
> the 'collection' attribute.
>
> ProvinceLookup has a method called getLookupData which returns a List.
>
> At the top of my JSP page, I create a ProvinceLookup object which
> contains the lookupData in cached form:
>
> <jsp:useBean
>    id="provinceLookup"
>    scope="page"
>    class="ca.tcpl.ris.web.ProvinceLookup"/>
>
> Further down, I try to reference the lookupData nested in my
> provinceLookup object:
>
>  <html:select property="province">
>        <html:options collection="provinceLookup.lookupData"
>            labelProperty="provinceCode"
>            property="provinceName" />
>      </html:select>
>
> This generates the exception trace (shown at the bottom of this email).
>
> My workaround is to use the bean:define custom tag to expose the
> lookupData directly in the page scope. Then my select JSP looks like the
>
> following (and works):
>
>  <html:select property="province">
>        <html:options collection="lookupData"
>            labelProperty="provinceCode"
>            property="provinceName" />
>      </html:select>
>
>
> type Exception report
> message Internal Server Error
> description The server encountered an internal error (Internal Server
> Error) that prevented it from fulfilling this request.
>
> exception
>
> javax.servlet.ServletException: Cannot find bean under name
> provinceLookup.lookupData
>        at
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457) 
>
>
>        at
> org.apache.jsp.WellSearch$jsp._jspService(WellSearch$jsp.java:1321)
>        at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>        at
> org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.service(IDEJspServlet.java:172) 
>
>
>        at
> org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.serviceJspFile(IDEJspServlet.java:234) 
>
>
>        at
> org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(IDEJspServlet.java:326) 
>
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) 
>
>
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) 
>
>
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.netbeans.modules.web.monitor.catalina.MonitorValve.invoke(MonitorValve.java:144) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) 
>
>
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011) 
>
>
>        at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106) 
>
>
>        at java.lang.Thread.run(Thread.java:484)
>
> root cause
>
> javax.servlet.jsp.JspException: Cannot find bean under name
> provinceLookup.lookupData
>        at
> org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:383)
>
>        at
> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:222)
>        at
> org.apache.jsp.WellSearch$jsp._jspService(WellSearch$jsp.java:303)
>        at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>        at
> org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.service(IDEJspServlet.java:172) 
>
>
>        at
> org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.serviceJspFile(IDEJspServlet.java:234) 
>
>
>        at
> org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(IDEJspServlet.java:326) 
>
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) 
>
>
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) 
>
>
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.netbeans.modules.web.monitor.catalina.MonitorValve.invoke(MonitorValve.java:144) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) 
>
>
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) 
>
>
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) 
>
>
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>        at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011) 
>
>
>        at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106) 
>
>
>        at java.lang.Thread.run(Thread.java:484)
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at 
> http://explorer.msn.com/intl.asp.
>
>
> -- 
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>