Problem with FormBean containing Lists of LabelValueBeans or something equivalent
Hi all, I have a problem mapping my form bean to a jsp that contains javascript to add html inputs dynamically. I already found out that i can use BeanUtils to add the input values to an ArrayList like this public void setProperty(int iIndex, String inputString) { this.propertyList.add(inputString); } The Problem is that there should be the chance to add whole groups of inputs dynamically. Inside these groups single inputs also should be reproducible. So i would have something like that in my DOM afterwards: hoch mittel niedrig hoch mittel niedrig I thought about putting several LabelValueBeans or LazyDynaBeans to an ArrayList named teachtarget. When i use public void setTeachtarget(int index, LabelValueBean teachtargetProperty) { this.teachtarget.add(teachtargetProperty); } as the set method and than try to read the list, I always receive an empty list. I'm wondering if I'm on the right way, I don't have an idea if this should work or not. If someone has any other ideas to work with two dimensional arrays (or lists of LabelValueBeans) containing values of inputs that have been created by javascript I would really appreciate it... Thanks for help! Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: LabelValueBeans
At 1:31 PM -0400 6/23/04, CRANFORD, CHRIS wrote: Is there anyway to have a property in my ActionForm class be defined as follows: private LabelValueBean[] myItems; And be able to have struts automatically populate this collection when the form is submitted? If so, how do I go about storing those values in the form so they're seen and populated properly upon submission? Well, a LabelValueBean has two string properties -- how would you automatically populate even a single instance, let alone an array? Or are you suggesting that the form presents the user with a series of paired input fields, essentially "label1", "value1", "label2", "value2", etc? If so, you could essentially do it by exposing an indexed property, "labelValueBeans" and then arranging to have your request parameters be named as such: labelValueBeans[0].label labelValueBeans[0].value labelValueBeans[1].label labelValueBeans[1].value I would do this using c:forEach and the struts-el tags, roughly like this: Label: Value: If you aren't using the EL, there are other ways to do this, but frankly, I never learned how to do them and I think it's cleaner with the JSTL. Joe -- -- Joe Germuska Vice President, Software Development JGSullivan Interactive, Inc. [EMAIL PROTECTED] 312/943-1600 x2488 (v) 312/943-9675 (f) [EMAIL PROTECTED] 312/404-3783 (m) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: LabelValueBeans
You can rewrite or extend the class to suit yourself, of course. At 10:52 AM 6/23/2004, James Mitchell wrote: No, look at the source for the class and you'll see why. -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 1:31 PM Subject: LabelValueBeans > Is there anyway to have a property in my ActionForm class be defined as > follows: > > private LabelValueBean[] myItems; > > And be able to have struts automatically populate this collection when the > form is submitted? If so, how do I go about storing those values in the > form so they're seen and populated properly upon submission? > > Thanks! > Chris > - 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]
RE: LabelValueBeans
Found my problem. I didn't have a getter method: public LabelValueBean getManufacturers(int index) { } Thanks Chris -Original Message- From: CRANFORD, CHRIS [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 2:05 PM To: 'Struts Users Mailing List' Subject: RE: LabelValueBeans I think 1.2. When I look at the properties in my editor on this object, I do see: setLabel(java.lang.String) setValue(java.lang.String) So how would one create a form element in their JSP to populate an array of LabelValueBeans? I'm getting the following error: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1098) at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j ava:816) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) And my form uses Thanks Chris -Original Message- From: James Mitchell [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 2:04 PM To: Struts Users Mailing List Subject: Re: LabelValueBeans Last time I looked there were getters but no setters. What version are you running? -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 1:57 PM Subject: RE: LabelValueBeans > I saw an example somewhere using indexed properties like: > > labelvalue[index].label > labelvalue[index].value > > If I can get at the data this way, there is no way to set it? Chris > > -Original Message- > From: James Mitchell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 23, 2004 1:52 PM > To: Struts Users Mailing List > Subject: Re: LabelValueBeans > > > No, look at the source for the class and you'll see why. > > > > -- > James Mitchell > Software Engineer / Open Source Evangelist > EdgeTech, Inc. > 678.910.8017 > AIM: jmitchtx > > - Original Message - > From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, June 23, 2004 1:31 PM > Subject: LabelValueBeans > > > > Is there anyway to have a property in my ActionForm class be defined > > as > > follows: > > > > private LabelValueBean[] myItems; > > > > And be able to have struts automatically populate this collection > > when the form is submitted? If so, how do I go about storing those > > values in the form so they're seen and populated properly upon > > submission? > > > > Thanks! > > Chris > > > > > > - > 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]
RE: LabelValueBeans
I think 1.2. When I look at the properties in my editor on this object, I do see: setLabel(java.lang.String) setValue(java.lang.String) So how would one create a form element in their JSP to populate an array of LabelValueBeans? I'm getting the following error: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1098) at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j ava:816) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) And my form uses Thanks Chris -Original Message- From: James Mitchell [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 2:04 PM To: Struts Users Mailing List Subject: Re: LabelValueBeans Last time I looked there were getters but no setters. What version are you running? -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 1:57 PM Subject: RE: LabelValueBeans > I saw an example somewhere using indexed properties like: > > labelvalue[index].label > labelvalue[index].value > > If I can get at the data this way, there is no way to set it? Chris > > -Original Message- > From: James Mitchell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 23, 2004 1:52 PM > To: Struts Users Mailing List > Subject: Re: LabelValueBeans > > > No, look at the source for the class and you'll see why. > > > > -- > James Mitchell > Software Engineer / Open Source Evangelist > EdgeTech, Inc. > 678.910.8017 > AIM: jmitchtx > > - Original Message - > From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, June 23, 2004 1:31 PM > Subject: LabelValueBeans > > > > Is there anyway to have a property in my ActionForm class be defined > > as > > follows: > > > > private LabelValueBean[] myItems; > > > > And be able to have struts automatically populate this collection > > when the form is submitted? If so, how do I go about storing those > > values in the form so they're seen and populated properly upon > > submission? > > > > Thanks! > > Chris > > > > > > - > 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]
Re: LabelValueBeans
Hmm...sorry for the misinformation, seems it has had them for a whilenot sure what I was thinking (need more coffee) So, ignore me. -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "James Mitchell" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 2:04 PM Subject: Re: LabelValueBeans > Last time I looked there were getters but no setters. What version are you > running? > > > > -- > James Mitchell > Software Engineer / Open Source Evangelist > EdgeTech, Inc. > 678.910.8017 > AIM: jmitchtx > > - Original Message - > From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> > To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> > Sent: Wednesday, June 23, 2004 1:57 PM > Subject: RE: LabelValueBeans > > > > I saw an example somewhere using indexed properties like: > > > > labelvalue[index].label > > labelvalue[index].value > > > > If I can get at the data this way, there is no way to set it? > > Chris > > > > -----Original Message- > > From: James Mitchell [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, June 23, 2004 1:52 PM > > To: Struts Users Mailing List > > Subject: Re: LabelValueBeans > > > > > > No, look at the source for the class and you'll see why. > > > > > > > > -- > > James Mitchell > > Software Engineer / Open Source Evangelist > > EdgeTech, Inc. > > 678.910.8017 > > AIM: jmitchtx > > > > - Original Message - > > From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, June 23, 2004 1:31 PM > > Subject: LabelValueBeans > > > > > > > Is there anyway to have a property in my ActionForm class be defined > > > as > > > follows: > > > > > > private LabelValueBean[] myItems; > > > > > > And be able to have struts automatically populate this collection when > > > the form is submitted? If so, how do I go about storing those values > > > in the form so they're seen and populated properly upon submission? > > > > > > Thanks! > > > Chris > > > > > > > > > > > - > > 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]
Re: LabelValueBeans
Last time I looked there were getters but no setters. What version are you running? -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 1:57 PM Subject: RE: LabelValueBeans > I saw an example somewhere using indexed properties like: > > labelvalue[index].label > labelvalue[index].value > > If I can get at the data this way, there is no way to set it? > Chris > > -Original Message- > From: James Mitchell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 23, 2004 1:52 PM > To: Struts Users Mailing List > Subject: Re: LabelValueBeans > > > No, look at the source for the class and you'll see why. > > > > -- > James Mitchell > Software Engineer / Open Source Evangelist > EdgeTech, Inc. > 678.910.8017 > AIM: jmitchtx > > - Original Message ----- > From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, June 23, 2004 1:31 PM > Subject: LabelValueBeans > > > > Is there anyway to have a property in my ActionForm class be defined > > as > > follows: > > > > private LabelValueBean[] myItems; > > > > And be able to have struts automatically populate this collection when > > the form is submitted? If so, how do I go about storing those values > > in the form so they're seen and populated properly upon submission? > > > > Thanks! > > Chris > > > > > > - > 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]
RE: LabelValueBeans
I saw an example somewhere using indexed properties like: labelvalue[index].label labelvalue[index].value If I can get at the data this way, there is no way to set it? Chris -Original Message- From: James Mitchell [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 1:52 PM To: Struts Users Mailing List Subject: Re: LabelValueBeans No, look at the source for the class and you'll see why. -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 1:31 PM Subject: LabelValueBeans > Is there anyway to have a property in my ActionForm class be defined > as > follows: > > private LabelValueBean[] myItems; > > And be able to have struts automatically populate this collection when > the form is submitted? If so, how do I go about storing those values > in the form so they're seen and populated properly upon submission? > > Thanks! > Chris > - 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]
Re: LabelValueBeans
No, look at the source for the class and you'll see why. -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "CRANFORD, CHRIS" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 23, 2004 1:31 PM Subject: LabelValueBeans > Is there anyway to have a property in my ActionForm class be defined as > follows: > > private LabelValueBean[] myItems; > > And be able to have struts automatically populate this collection when the > form is submitted? If so, how do I go about storing those values in the > form so they're seen and populated properly upon submission? > > Thanks! > Chris > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
LabelValueBeans
Is there anyway to have a property in my ActionForm class be defined as follows: private LabelValueBean[] myItems; And be able to have struts automatically populate this collection when the form is submitted? If so, how do I go about storing those values in the form so they're seen and populated properly upon submission? Thanks! Chris