Nate, I had sent an email to the list suggesting that there might be a classpath issue. But I sent it from the wrong account so it never got here. I'm glad you figured it out.
robert > -----Original Message----- > From: Nate Drake [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 09, 2003 11:05 AM > To: Struts Users Mailing List > Subject: RE: Create new nested bean instance > > > Figured it out. I had two copies of the class containing the FormFile > in the ear. One in a jar in the ear's library directory and one in the > war file. > > Removed the one in library and all is well. > > Thanks again. > > Nate > > On Tue, 2003-09-09 at 08:39, Nate Drake wrote: > > By static include, you mean <% include file="filename" %>, right? Yes, > > there is one of those. The included file just has some html (two > > <script src="blah.js"></script> elements). > > > > Thanks. > > > > n > > > > > > > > > > On Mon, 2003-09-08 at 21:52, Robert Taylor wrote: > > > What's in addimporteddlist.jsp? > > > Are you using a static include anywhere? > > > > > > robert > > > > > > > -----Original Message----- > > > > From: Nate Drake [mailto:[EMAIL PROTECTED] > > > > Sent: Monday, September 08, 2003 5:19 PM > > > > To: Struts Users Mailing List > > > > Subject: RE: Create new nested bean instance > > > > > > > > > > > > Thanks a million, Robert! I got it 99% working the way you > described. > > > > > > > > The object in the list (PhoneNumber) has an > > > > org.apache.struts.upload.FormFile property. When I go to the > > > > AddNewPhoneNumber.jsp I get: > > > > > > > > java.lang.NoClassDefFoundError: org/apache/struts/upload/FormFile > > > > > > > > I tried adding a <@page import%> to include > > > > org.apache.struts.upload.FormFile in the jsp, but that > didn't help. If > > > > I remove the FormFile property from the bean/jsp everything works > > > > great. I don't understand how it can't find this class. > It seems to > > > > find the Struts taglib classes fine, but not FormFile. The taglib > > > > classes and org.apache.struts.upload.FormFile are in the > same jar. I > > > > really hate Classloader related problems. > > > > > > > > Any ideas? > > > > > > > > Thanks again for all your help. > > > > > > > > Nate > > > > > > > > > > > > Here is the stack trace: > > > > > > > > java.lang.NoClassDefFoundError: org/apache/struts/upload/FormFile > > > > at java.lang.Class.getDeclaredMethods0(Native Method) > > > > at > java.lang.Class.privateGetDeclaredMethods(Class.java:1647) > > > > at java.lang.Class.getDeclaredMethods(Class.java:1131) > > > > at java.beans.Introspector$1.run(Introspector.java:1126) > > > > at > java.security.AccessController.doPrivileged(Native Method) > > > > at > > > > > java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1124) > > > > at > > > > java.beans.Introspector.getTargetMethodInfo(Introspector.java:989) > > > > at > java.beans.Introspector.getBeanInfo(Introspector.java:370) > > > > at > java.beans.Introspector.getBeanInfo(Introspector.java:144) > > > > at > > > > org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors( > > > > PropertyUtils.java:949) > > > > at > > > > org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors( > > > > PropertyUtils.java:979) > > > > at > > > > org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(P > > > > ropertyUtils.java:887) > > > > at > > > > org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(Prope > > > > rtyUtils.java:1172) > > > > at > > > > org.apache.commons.beanutils.PropertyUtils.getNestedProperty(Prope > > > > rtyUtils.java:772) > > > > at > > > > org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUti > > > > ls.java:801) > > > > at > > > > org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:952) > > > > at > > > > org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag > > > > .java:176) > > > > at > > > > org.apache.jsp.addimporteddlist_jsp._jspx_meth_html_text_0(addimpo > > > > rteddlist_jsp.java:690) > > > > at > > > > org.apache.jsp.addimporteddlist_jsp._jspService(addimporteddlist_j > > > > sp.java:279) > > > > at > > > > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) > > > > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > > > at > > > > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrap > > > > per.java:210) > > > > at > > > > > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) > > > > at > > > > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) > > > > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > > > at > > > > > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360) > > > > at > > > > org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplic > > > > ationHandler.java:294) > > > > at > > > > org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:192) > > > > at > > > > org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:129) > > > > at > > > > org.apache.struts.action.RequestProcessor.doForward(RequestProcess > > > > or.java:1069) > > > > at > > > > org.apache.struts.action.RequestProcessor.processForwardConfig(Req > > > > uestProcessor.java:455) > > > > at > > > > org.apache.struts.action.RequestProcessor.process(RequestProcessor > > > > .java:279) > > > > at > > > > > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) > > > > at > > > > org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507) > > > > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > > > > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > > > at > > > > > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360) > > > > at > > > > org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplic > > > > ationHandler.java:294) > > > > at > > > > > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558) > > > > at > org.mortbay.http.HttpContext.handle(HttpContext.java:1714) > > > > at > > > > org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicat > > > > ionContext.java:507) > > > > at > org.mortbay.http.HttpContext.handle(HttpContext.java:1664) > > > > at org.mortbay.http.HttpServer.service(HttpServer.java:863) > > > > at org.jboss.jetty.Jetty.service(Jetty.java:460) > > > > at > > > > org.mortbay.http.HttpConnection.service(HttpConnection.java:775) > > > > at > > > > org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939) > > > > > > > > > > > > > > > > On Mon, 2003-09-08 at 15:09, Robert Taylor wrote: > > > > > Sorry Nate, I can't help you with updating your > structures using the > > > > > nested taglib. I haven't done it before. Maybe someone > else can provide > > > > > you some guidance there so that you don't have to jump through the > > > > > indexed properties "hoops". > > > > > > > > > > On the other hand, using indexed properties: > > > > > > > > > > Your form must have getPhoneNumbers(int index) and > setPhoneNumbers(int > > > > > index) > > > > > methods. > > > > > > > > > > Ultimately you want the HTML syntax to be something like: > > > > > > > > > > <input type="text" name="phoneNumbers[2].countryCode" ..../> > > > > > <input type="text" name="phoneNumbers[2].areaCode" ..../> > > > > > <input type="text" name="phoneNumbers[2].number" ..../> > > > > > <input type="text" name="phoneNumbers[2].description" ..../> > > > > > > > > > > Where the index of 2 is the nth location for your new > phone number. > > > > > You could pass 'n' as a request parameter when the user clicks on > > > > > the "Add New Phone Number" link. > > > > > > > > > > Since the nth location doesn't exist, the lazy list will > create an empty > > > > > PhoneNumberBean object and add it to the list in the nth > > > > location anytime > > > > > when a get() or set() is invoked on a location that does > not exist. > > > > > This is all in the documentation which I'm sure you've > read by now. > > > > > > > > > > So one way to achieve the HTML syntax listed above, is > something like > > > > > the following where 'n' is a request parameter named > 'topLevelIndex': > > > > > > > > > > <%String prefix = "phoneNumbers[" + > > > > request.getParameter("topLevelIndex") + > > > > > "]";%> > > > > > <html:text property="<%=prefix + ".countryCode"%>"/> > > > > > <html:text property="<%=prefix + ".areaCode"%>"/> > > > > > <html:text property="<%=prefix + ".number"%>"/> > > > > > <html:text property="<%=prefix + ".description"%>"/> > > > > > > > > > > There are more slick ways to do this using JTSL or Struts-el > > > > but if you just > > > > > want to > > > > > get it working first, you can try the above. > > > > > > > > > > What should happen when your form is displayed is that the > > > > <html:text .../> > > > > > tag will > > > > > look up (finally delegating to PropertyUtils) the indexed > properties and > > > > > attempt to get any existing value by invoking > > > > > the getPhoneNumbers{index). The List implementation > provided by the lazy > > > > > list > > > > > will determine that no object exists at the specified location > > > > and it will > > > > > create an empty PhoneNumberBean object and populate the > list and then > > > > > delegate to the > > > > > get(index) which will retrieve the empty bean property. This > > > > prevents the > > > > > dreaded > > > > > ArrayIndexOutOfBoundsException. > > > > > > > > > > When your form is submitted, Struts sets the appropriate > > > > PhoneNumberBean and > > > > > then you can > > > > > procede with your business logic. > > > > > > > > > > > > > > > Nate, I hope this makes sense. Sorry I couldn' help you with > > > > using nested > > > > > taglib to accomplish > > > > > this. I assume you have already looked here: > > > > > > > > > > http://www.keyboardmonkey.com/next/index.jsp > > > > > > > > > > robert > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Nate Drake [mailto:[EMAIL PROTECTED] > > > > > > Sent: Monday, September 08, 2003 1:14 PM > > > > > > To: [EMAIL PROTECTED] > > > > > > Subject: RE: Create new nested bean instance > > > > > > > > > > > > > > > > > > Ok, the thing I don't understand now is how to setup the > > > > > > AddNewPhoneNumber jsp so that is uses the lazy list to > create a new > > > > > > PhoneNumber instance bean. > > > > > > > > > > > > I'm trying to use the nested taglib, but I don't really > understand how > > > > > > to set the top level object to be a new instance out of > the list. > > > > > > > > > > > > I've tried something like this: > > > > > > > > > > > > <nested:nest property="phoneNumbers"> > > > > > > <nested:text property="countryCode" /> > > > > > > <nested:text property="areadCode" /> > > > > > > <nested:text property="number" /> > > > > > > <nested:text property="description" /> > > > > > > </nested:nest> > > > > > > > > > > > > The thing I can't figure out is how you set the top-level > > > > object to be a > > > > > > new instance of the PhoneNumber bean (which should be > created from the > > > > > > lazy list). I tried using <nested:nest > property="phoneNumbers">, but > > > > > > that gives me an error stating "No getter for property > > > > > > phoneNumbers.countryCode of bean customerForm". I > figure that is > > > > > > because the <nested:nest> sets the top-level object to be the > > > > List, and > > > > > > doesn't actually attempt to get an item out of the list > (which would > > > > > > cause the lazy list factory to create a new PhoneNumber > instance). > > > > > > > > > > > > How is this supposed to work? Am I on the right track > at all? Anyone > > > > > > have a link to an example like what I'm trying to do? > > > > > > > > > > > > Thanks. > > > > > > > > > > > > Nate > > > > > > > > > > > > > > > > > > On Mon, 2003-09-08 at 11:41, Robert Taylor wrote: > > > > > > > Yep. You could create the new lazy list in the form reset(). > > > > > > > > > > > > > > robert > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Nate Drake [mailto:[EMAIL PROTECTED] > > > > > > > > Sent: Monday, September 08, 2003 9:29 AM > > > > > > > > To: Struts Users Mailing List > > > > > > > > Subject: RE: Create new nested bean instance > > > > > > > > > > > > > > > > > > > > > > > > Robert, > > > > > > > > > > > > > > > > Thanks for the links. I already read the Indexed > > > > Property FAQ (and I > > > > > > > > just re-read it again), but I didn't really see anything > > > > in it that > > > > > > > > relates to my problem. > > > > > > > > > > > > > > > > The lazyList stuff looks more promising. I have a > > > > question about it, > > > > > > > > though. Where do I create the new LazyList? In the > > > > > > ActionForms reset() > > > > > > > > method? > > > > > > > > > > > > > > > > Thanks again. > > > > > > > > > > > > > > > > Nate > > > > > > > > > > > > > > > > On Mon, 2003-09-08 at 06:18, Robert Taylor wrote: > > > > > > > > > Nate, you may want to look into indexed properties: > > > > > > > > > http://jakarta.apache.org/struts/faqs/indexedprops.html > > > > > > > > > > > > > > > > > > and ListUtils.lazyList(): > > > > > > > > > > > > > > > > > > http://jakarta.apache.org/commons/collections/api/org/apache/commo > > > > > > > > ns/collect > > > > > > > > > ions/ListUtils.html > > > > > > > > > > > > > > > > > > robert > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > > > From: Nate Drake [mailto:[EMAIL PROTECTED] > > > > > > > > > > Sent: Sunday, September 07, 2003 9:32 PM > > > > > > > > > > To: [EMAIL PROTECTED] > > > > > > > > > > Subject: Create new nested bean instance > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > > > > > > > > > What is the "proper" Struts way to implement > create/update > > > > > > > > pages in the > > > > > > > > > > following scenario. > > > > > > > > > > > > > > > > > > > > You've got a Customer Form bean with the > following properties: > > > > > > > > > > > > > > > > > > > > - First Name > > > > > > > > > > - Last Name > > > > > > > > > > - List of PhoneNumber Beans > > > > > > > > > > > > > > > > > > > > A PhoneNumber bean with these properties: > > > > > > > > > > > > > > > > > > > > - Country Code > > > > > > > > > > - Area Code > > > > > > > > > > - Number > > > > > > > > > > - Description > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I'd like it to be set up like this: > > > > > > > > > > > > > > > > > > > > CreateCustomer.jsp has text fields for first and last > > > > name, and it > > > > > > > > > > displays the list of added phone numbers. It > also has an > > > > > > > > "Add New Phone > > > > > > > > > > Number" link. This link takes you to > AddPhoneNumber.jsp. > > > > > > > > This page has > > > > > > > > > > fields for all the phone number properties, and an "Add" > > > > > > button. When > > > > > > > > > > you press the "Add" button it returns you to the > > > > > > CreateCustomer.jsp. > > > > > > > > > > The list of phone numbers on this page will reflect the > > > > > > newly added > > > > > > > > > > phone number. > > > > > > > > > > > > > > > > > > > > The part of this I'm having trouble figuring out is how > > > > > > the List of > > > > > > > > > > phone number beans gets updated. Is there a way to tell > > > > > > > > Struts to add a > > > > > > > > > > new PhoneNumberBean to CustomerBean's list of phone > > > > > > numbers? Or do I > > > > > > > > > > have to do it myself in an Action? > > > > > > > > > > > > > > > > > > > > I haven't been able to find any examples like this with > > > > > > nested beans. > > > > > > > > > > All the nested examples I find just show you how to > > > > display nested > > > > > > > > > > data. I need to create new nested data and add it to > > > > the parent. > > > > > > > > > > > > > > > > > > > > Any help would be greatly appreciated. > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > Nate > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > To unsubscribe, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > For additional commands, e-mail: > > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > To unsubscribe, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > For additional commands, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > > > > > > For additional commands, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]