One To Many List Problem

From: Joshua Pyle (joshua.t.pyl..mail.com)
Date: Tue Jan 18 2005 - 17:13:48 EST

  • Next message: Joshua Pyle: "Re: One To Many List Problem"

    This issue seems like it should be rudimentary but I've tried every
    iteration I can imagine and I still get errors. Simply pur here is
    what I need to happen.

    1. I am editing an object that contains a list of serial numbers.

    2. The user submits a web page with a list of the new serial numbers.

    3. I need to basically replace the list associated with the object
    with a new list of serial numbers that get submitted from the web
    page.

    4. The major problem is that its simple to loop through the list of
    serial numbers and add the new ones but its a major pain remove the
    ones that are missing, not to mention time consuming.

    My latest effort has entailed creating the following function on the
    object/class in question...

        public void clearSerialNumbersAffected() {
            SerNbrAffected serialNumberAffected;
            while( this.getSerialNumbersAffected().size() > 0 ){
                serialNumberAffected =
    (SerNbrAffected)currSerialNumbersAffected.get(0);
                this.removeFromSerialNumbersAffected( serialNumberAffected );
                this.getDataContext().deleteObject( serialNumberAffected );
            }
        }

    This is the code I call in my Struts action Class to set the serial numbers...

            String[] serNumbers = workingForm.getSerNumbersAffected();
            String currSerNumber = "";
            SerNbrAffected serNumberAffected;
            n = serNumbers.length;
            modifyRev.clearSerialNumbersAffected();
            System.out.println(
    "modifyRev.getSerialNumbersAffected().size() = " +
    modifyRev.getSerialNumbersAffected().size() );
            for (int i = 0; i < n; i++) {
                //System.out.println("---- doing serNumber # " + serNumbers[i]);
                currSerNumber = serNumbers[i];
                if (!"".equals(currSerNumber)) {
                    serNumberAffected = (SerNbrAffected)
    dbContext.createAndRegisterNewObject(SerNbrAffected.class);
                    modifyRev.addToSerialNumbersAffected(serNumberAffected);
                }
            }

    In case this is neccessary here is the stack trace...

    Validation failure for
    com.ray.rms.it.esolutions.mla.cayenne.SerNbrAffected.serialNumber:
    "serialNumber" is required.
            at org.objectstyle.cayenne.access.ObjectStore.validateUncommittedObjects(ObjectStore.java:950)
            at org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1260)
            at org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1236)
            at com.ray.rms.it.esolutions.mla.view.MLA.ProcModifyMLAAction.doHasNoRevisions(ProcModifyMLAAction.java:443)
            at com.ray.rms.it.esolutions.mla.view.MLA.ProcModifyMLAAction.execute(ProcModifyMLAAction.java:149)
            at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
            at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
            at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
            at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
            at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
            at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
            at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
            at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
            at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
            at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
            at java.lang.Thread.run(Thread.java:534)

    -- 
    Joshua T. Pyle
    Go has always existed.
    



    This archive was generated by hypermail 2.0.0 : Tue Jan 18 2005 - 17:46:49 EST