I managed to get the problem working, unfortunately that fix is by doing
something that is against best practices (if I understand them correctly).
To get this to work what I ended up doing was pulling the results from the
search and putting that in the reset of the resultsAction.  I am pretty
certain your question about the setting the value on the set and not the get
hit the nail on the head.  I will work on the suggestions that you made and
see what progress I can make.

Thanks again so much for all the time and effort.


On 10/19/06, Adam K <[EMAIL PROTECTED]> wrote:

It's more likely that I don't understand.  This is my first struts project
and I am learning as I go.


Here is all of the getters/setters that I have so far.  It is quite
possible that I am missing some, but the previous page that I created that
works used only those listed, and it works fine.  The main difference being
that the working one only has 1 form on the page, and that I use the reset
method to pre-populate the page (which I have since learned is bad, but I
haven't gotten back to fixing it).

   public int getNumProducts() {
        return numProducts;
    }

    public void setNumProducts(int numProducts)
    {
        this.numProducts = numProducts;
    }


    public int getNumProducts(int index)
    {
        if(this.results== null)
        {
            this.results = new ArrayList();
        }
        while(index >= this.results.size() +1)
        {
            this.results.add(new Product());
        }

        Product p = (Product) results.get(index);
        return p.getNumProducts();
    }


On 10/19/06, Puneet Lakhina <[EMAIL PROTECTED]> wrote:
>
> On 10/20/06, Adam K <[EMAIL PROTECTED]> wrote:
> >
> > Getter and setter methods for ?  (Sorry if it should be obvious but I
> want
> > to clarify as it isn't obvious to me)
>
>
> for numProducts indexed property. And i dont understand why are you
> populating blank values in the getter methods..I mean you should be
> doing
> that in your setter methods..something like
>
> public void setNumProducts(int index,String val) {
> while(index <= results.size()) {
> results.add(new Product());
> }
> Product p = (Product)results.get(index);
> p.setNumProducts(val);
> }
> maybe i dont understnad the context of your problem properly, but this
> what
> i do with indexed properties.
>
> As far the error message here is what I recieve:
> >
> > javax.servlet.ServletException: BeanUtils.populate
> >         org.apache.struts.util.RequestUtils.populate(RequestUtils.java
> > :495)
> >         org.apache.struts.action.RequestProcessor.processPopulate(
> > RequestProcessor.java:816)
> >         org.apache.struts.action.RequestProcessor.process(
> > RequestProcessor.java :203)
> >         org.apache.struts.action.ActionServlet.process(
> ActionServlet.java
> > :1196)
> >         org.apache.struts.action.ActionServlet.doPost(
> ActionServlet.java
> > :432)
> >         javax.servlet.http.HttpServlet.service (HttpServlet.java:727)
> >         javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> >         com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
> >         com.sun.enterprise.web.VirtualServerPipeline.invoke (
> > VirtualServerPipeline.java:120)
> >         org.apache.coyote.tomcat5.CoyoteAdapter.service(
> CoyoteAdapter.java
> > :231)
> >
> > com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter (
> > ProcessorTask.java:667)
> >
> >
> com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked
> (
> > ProcessorTask.java:574)
> >         com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(
> > ProcessorTask.java:844)
> >
> > com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask
> (
> > ReadTask.java:287)
> >         com.sun.enterprise.web.connector.grizzly.ReadTask.doTask (
> > ReadTask.java:212)
> >         com.sun.enterprise.web.connector.grizzly.TaskBase.run(
> > TaskBase.java:252)
> >         com.sun.enterprise.web.connector.grizzly.WorkerThread.run(
> > WorkerThread.java :75)
> >
> > *root cause*
> >
> > java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
> >         java.util.ArrayList.RangeCheck(ArrayList.java:546)
> >         java.util.ArrayList.get(ArrayList.java :321)
> >
> org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(
> > PropertyUtilsBean.java:433)
> >
> org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(
> > PropertyUtilsBean.java :340)
> >
> org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(
> > PropertyUtilsBean.java:684)
> >         org.apache.commons.beanutils.PropertyUtilsBean.getProperty(
> > PropertyUtilsBean.java :715)
> >         org.apache.commons.beanutils.BeanUtilsBean.setProperty(
> > BeanUtilsBean.java:884)
> >         org.apache.commons.beanutils.BeanUtilsBean.populate(
> > BeanUtilsBean.java:811)
> >         org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java
> > :298)
> >         org.apache.struts.util.RequestUtils.populate(RequestUtils.java
> > :493)
> >         org.apache.struts.action.RequestProcessor.processPopulate (
> > RequestProcessor.java:816)
> >         org.apache.struts.action.RequestProcessor.process(
> > RequestProcessor.java:203)
> >         org.apache.struts.action.ActionServlet.process(
> ActionServlet.java
> > :1196)
> >         org.apache.struts.action.ActionServlet.doPost(
> ActionServlet.java
> > :432)
> >         javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
> >         javax.servlet.http.HttpServlet.service (HttpServlet.java:820)
> >         com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
> >         com.sun.enterprise.web.VirtualServerPipeline.invoke(
> > VirtualServerPipeline.java:120)
> >         org.apache.coyote.tomcat5.CoyoteAdapter.service(
> CoyoteAdapter.java
> > :231)
> >
> > com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(
> > ProcessorTask.java:667)
> >
> >
> com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(
> > ProcessorTask.java:574)
> >         com.sun.enterprise.web.connector.grizzly.ProcessorTask.process
> (
> > ProcessorTask.java:844)
> >
> > com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(
> > ReadTask.java:287)
> >         com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(
> > ReadTask.java:212)
> >         com.sun.enterprise.web.connector.grizzly.TaskBase.run(
> > TaskBase.java :252)
> >         com.sun.enterprise.web.connector.grizzly.WorkerThread.run(
> > WorkerThread.java:75)
> >
> >
>
>
> --
> Puneet
>
>

Reply via email to