struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathew, Manoj" <Mathew.Ma...@principal.com>
Subject RE: ArrayList and DynaActionForm--need help very badly
Date Wed, 28 Apr 2004 15:24:05 GMT
can you explain little more please. I am a dumb.

  I didn't get the second parameter
	  new Factory() {
                                       public Object create() {
                                           return new CreditCost();
                                       }
                                    }

Thank-you,
Manoj Mathew



-----Original Message-----
From: Hubert Rabago [mailto:jakartauser@yahoo.com]
Sent: Wednesday, April 28, 2004 10:17 AM
To: Struts Users Mailing List
Subject: RE: ArrayList and DynaActionForm--need help very badly


Create a DynaActionForm subclass, then do the reset there.
Try something like this:

import org.apache.commons.collections.Factory;
public class MathewDynaActionForm extends DynaActionForm {
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        List creditCosts =
                ListUtils.lazyList(new ArrayList(),
                                   new Factory() {
                                       public Object create() {
                                           return new CreditCost();
                                       }
                                    });
        set("creditCosts", creditCosts);
    }
}

<form-bean name="creditCostsForm" type="MathewDynaActionForm">
         <form-property name="creditCosts" type="java.util.ArrayList" />
         ...
</form-bean>


Hubert

--- "Mathew, Manoj" <Mathew.Manoj@principal.com> wrote:
> Guys
> 
>   Let me explain little more.. But man i am running out of time.
> I still didn't get how to do this. since i am uwing Dynaactionform, I am
> nto asure where to write the reset().
> 
> I a having the bean in the request scope as well as my list has variable
> size.
> my struts config entry is this.
> 
> <form-bean name="creditCostsForm" type="...">
>         <form-property name="creditCosts" type="java.util.ArrayList" />
> 
> the issue i am facing is,
> 
> from the jsp when you submit the form, the struts is calling the
> setmyList(key value).
> But it is using the key not in order, for example it might call setmyList(2
> value1)  before calling setmyList(1 value1)..
> sonce the implementation use myList.add(), IT blows off and throwing
> ArrayIndexout ofBOnd exception.
> 
> I have implemented the same in my Action for by coding the set in this way.
> 	public void setEmpVTLMaxPercOfSalaryValues(int key, Object value) {
> 		int size = empVTLMaxPercOfSalaryValues.size();
> 		if (size <= key) {
> 			for (int i = size; i < key + 1; i++) {
> 				empVTLMaxPercOfSalaryValues.add(value);
> 			}
> 		}
> 		empVTLMaxPercOfSalaryValues.set(key, value);
> 	}
> 
> but since in Dynaactionform, I don't have my setters and getters , i have
> this issue. Please help me out..Time is running out.
> 
> Thank-you,
> Manoj Mathew
> 
> -----Original Message-----
> From: Richard Yee [mailto:ryee@cruzio.com]
> Sent: Tuesday, April 27, 2004 8:01 PM
> To: Struts Users Mailing List
> Subject: RE: ArrayList and DynaActionForm
> 
> 
> Mathew,
> Take what I wrote and combine it with what Sandeep wrote and you have a 
> solution that uses request scope but does not require the use of the 
> LazyList. In your FormBean reset method, if you have a list that has a 
> variable size, then use a form bean attribute to store the # of elements 
> you need to put into the ArrayList and use that value in the reset method 
> to populate the list.
> 
> Regards,
> 
> Richard
> 
> At 12:32 PM 4/27/2004, you wrote:
> >I a m using request scope.
> >So i need to go for lazylist implementation.
> >
> >Would you go little more in detail?
> >
> >
> >
> >Thank-you,
> >Manoj Mathew
> >-----Original Message-----
> >From: Takhar, Sandeep [mailto:Sandeep.Takhar@CIBC.ca]
> >Sent: Tuesday, April 27, 2004 2:23 PM
> >To: Struts Users Mailing List
> >Subject: RE: ArrayList and DynaActionForm
> >
> >
> >form.set("list", new ArrayList());
> >
> >should work
> >
> >Problem is that unless you are using a lazy list implementation of some 
> >sort or session scope, the list won't be initialized for your populate.
> >
> >sandeep
> >
> >-----Original Message-----
> >From: Mathew, Manoj [mailto:Mathew.Manoj@principal.com]
> >Sent: Tuesday, April 27, 2004 3:16 PM
> >To: Struts Users Mailing List
> >Subject: RE: ArrayList and DynaActionForm
> >
> >
> >Richard
> >
> >   Actually i have implemented Action forms which have List as element. 
> > It's fine.
> >But my issue is when i put List as an element of DynaActionForm? In this 
> >case i don't have setters and getters and i cannot prepopulate it.
> >
> >Thank-you,
> >Manoj Mathew
> >
> >-----Original Message-----
> >From: Richard Yee [mailto:ryee86@yahoo.com]
> >Sent: Tuesday, April 27, 2004 1:13 PM
> >To: Struts Users Mailing List
> >Subject: RE: ArrayList and DynaActionForm
> >
> >
> >Mathew,
> >See:
> >http://marc.theaimsgroup.com/?l=struts-user&m=108261575210769&w=2
> >
> >The thread subject is:  Re: How to pre-populate values
> >to <nested:radio> buttons from
> >
> >The date was 4/22/04.
> >
> >Regards,
> >
> >Richard
> >
> >--- "Mathew, Manoj" <Mathew.Manoj@principal.com>
> >wrote:
> > >
> > >
> > > Narayan
> > >
> > > you got the answer for this? Can you please share
> > > that with me?
> > > I searched the Archive, but couldn't find Richard's
> > > earlier solution.
> > > I am using
> > > <form-bean name="creditCostsForm" type="...">
> > >         <form-property name="creditCosts"
> > > type="java.util.ArrayList" />
> > >
> > > but gettingArrayIndexoutofBond while setting...
> > >
> > > matt
> > >
> > >
> > > -----Original Message-----
> > > From: Richard Yee [mailto:ryee86@yahoo.com]
> > > Sent: Monday, April 26, 2004 4:45 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: ArrayList and DynaActionForm
> > >
> > >
> > > If you have a fixed # of elements or if you put the
> > > count of elements in your form bean, you can put
> > > code
> > > in your reset() method to initialize the List
> > > attribute with the proper # of elements. This will
> > > enable you to use request scope and not use the
> > > LazyList. If you check the archives, I answered
> > > another question about a week ago on this and
> > > provided
> > > step-by-step instructions.
> > >
> > > Regards,
> > >
> > > Richard
> > >
> > >
> > > --- narayanan a <sna_narayanan@yahoo.com> wrote:
> > > > All,
> > > >
> > > > I have an ArrayList in a DynaActionForm. I am
> > > > populating the ArrayList in my Action class and
> > > > displaying the list as text boxes in the JSP page.
> > > > When the user clicks on the submit button, Struts
> > > is
> > > > not able to put back the values into the ArrayList
> > > > and
> > > > it throws IndexOutOfBoundsException. The form bean
> > > > is
> > > > in request scope. This problem can be solved by
> > > > putting the form bean in session scope, but I do
> > > not
> > > > want to do that.
> > > >
> > > > Any help would be appreciated.
> > > >
> > > > Thanks
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Do you Yahoo!?
> > > > Yahoo! Photos: High-quality 4x6 digital prints for
> > > > 25ยข
> > > > http://photos.yahoo.com/ph/print_splash
> > > >
> > > >
> > >
> >---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > > user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail:
> > > > user-help@struts.apache.org
> 
=== message truncated ===



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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


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


Mime
View raw message