struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Skeim <gsk...@yahoo.com>
Subject DynaActionForm and optionsCollection get exception Cannot create iterator...
Date Tue, 28 Dec 2004 21:57:15 GMT
I having been trying to convert existing pages from
extending ActionForm to DynaActionForm so that I donít
have to provide the set and get.  I am having problems
with the optionsCollection trying to get the iterator.
The correct values are being obtained from the
database and store via the LabelValueBean class.  The
getIterator method in OptionsCollectionTag should have
a Collection, but it throw exception at line 351. Not
sure, what is wrong. Thanks for you help.

Greg


  
My configuration is as follows:

       <form-bean name="SiteEditorForm"
type="com.wsa.core.view.SiteEditorForm">
            <form-property name="site"       
type="java.lang.String"/>
            <form-property name="arraylist"  
type="com.blacklake.business.db.Site"/>
            <form-property name="sitename"   
type="java.lang.String" initial=""/>
            <form-property name="sitedesc"   
type="java.lang.String" initial=""/>
        </form-bean>


Partial listing of Site class that I am using:

  
/**************************************************************************
    *  
    *
   
**************************************************************************/
    public static Collection getArraylist() {
        
        Collection          sitecollection = new
ArrayList();
        DatabaseConnection  conn = null;
        String              emessage = "";
        tbSite              dbsitelist = null;
        tbSite              dbsite = null;
        
        try {
            
            // Initialize the database and tbAddress
class.
            conn = new DatabaseConnection(
"development" );
            dbsitelist = new tbSite(
conn.getConnection(), "default" );
            
            // Get the list from the database.
            sitecollection.add( new LabelValueBean(
"--add--","0") );
            for( Iterator
e=dbsitelist.searchAndRetrieveList().iterator();
e.hasNext(); ) {
                
                dbsite = (tbSite)e.next();
                sitecollection.add( new
LabelValueBean(dbsite.getField("SiteName"),
                                                      
                           dbsite.getField("PK_Site"))
);
           }//for
            
       }//try
        catch( Exception e ) {
            emessage += e.getMessage();
        }//catch
        finally {
            // Release the object for GC.
            dbsitelist = null;
            dbsite = null;

            // Close the database cleanly.
            conn.closeConnection();
            conn = null;
        }//finally
        
return( sitecollection );
	    
    } // getArraylist
    

   
/**************************************************************************
    *  
    *
   
**************************************************************************/
    public String toString() {

        ArrayList sites =
(ArrayList)Site.getArraylist();
        return( sites.toString() );

    } // toString


   
/**************************************************************************
    *  
    *
   
**************************************************************************/
    public Iterator iterator() {

        ArrayList sites =
(ArrayList)Site.getArraylist();
        return( sites.iterator() );
        
        //Vector sites = Site.getSiteOptions();
        //return( sites.iterator() );

    } // toString




Reported exception:

javax.servlet.ServletException: Cannot create iterator
for [LabelValueBean[--add--, 0],
LabelValueBean[development, 1], LabelValueBean[test,
2], LabelValueBean[production, 3]]

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)

org.apache.jsp.wsa.siteEditor_jsp._jspService(siteEditor_jsp.java:140)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

root cause

javax.servlet.jsp.JspException: Cannot create iterator
for [LabelValueBean[--add--, 0],
LabelValueBean[development, 1], LabelValueBean[test,
2], LabelValueBean[production, 3]]

org.apache.struts.taglib.html.OptionsCollectionTag.getIterator(OptionsCollectionTag.java:351)

org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:185)

org.apache.jsp.wsa.siteEditor_jsp._jspx_meth_html_optionsCollection_0(siteEditor_jsp.java:386)

org.apache.jsp.wsa.siteEditor_jsp._jspx_meth_html_select_0(siteEditor_jsp.java:358)

org.apache.jsp.wsa.siteEditor_jsp._jspx_meth_html_form_0(siteEditor_jsp.java:257)

org.apache.jsp.wsa.siteEditor_jsp._jspService(siteEditor_jsp.java:101)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

note The full stack trace of the root cause is
available in the Apache Tomcat/5.0.28 logs.






		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message