You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "CRANFORD, CHRIS" <ch...@setechusa.com> on 2004/06/23 19:31:49 UTC

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

Re: LabelValueBeans

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
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" <ch...@setechusa.com>
>To: <us...@struts.apache.org>
>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: 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


Re: LabelValueBeans

Posted by James Mitchell <jm...@apache.org>.
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" <ch...@setechusa.com>
To: <us...@struts.apache.org>
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: LabelValueBeans

Posted by Joe Germuska <Jo...@JGSullivan.com>.
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:

<c:forEach begin="0" end="5" varStatus="status">
Label: <html:text property="labelValueBeans[${status.count}].label" /><br />
Value: <html:text property="labelValueBeans[${status.count}].value" /><br />
</c:forEach>

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.
Joe.Germuska@JGSullivan.com	312/943-1600 x2488 (v)	312/943-9675 (f)
pagejoe@jgsullivan.com	312/404-3783 (m)

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