You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jamie Orchard-Hays <ja...@dang.com> on 2003/08/05 19:35:42 UTC

Re: Using an Array For Foreach/Selected

I'm trying something similar. I'm creating a multiple select box. How can I have the selected items selected after I submit the
form? Like Michael, I don't want to have the selected property in my data object. Perhaps you can point me to a good code example.
I've been trying some ideas based on your comments below, but without success.

Jamie


----- Original Message -----
From: "Michael Nestler" <mn...@whoglue.com>
To: "'Tapestry users'" <ta...@jakarta.apache.org>
Sent: Thursday, July 24, 2003 4:28 PM
Subject: RE: Using an Array For Foreach/Selected


> Thank you for your quick answer. The suggested solution is really lean.
> I did not know that you can name components, and that Foreach has an
> index property. I am learning every day more about Tapestry :-)
>
> Thanks again,
> Michael
>
>
> > -----Original Message-----
> > From: Howard M. Lewis Ship [mailto:hlship@comcast.net]
> > Sent: Thursday, July 24, 2003 3:33 PM
> > To: 'Tapestry users'; mnestler@whoglue.com
> > Subject: RE: Using an Array For Foreach/Selected
> >
> >
> >
> > > -----Original Message-----
> > > From: Michael Nestler [mailto:mnestler@whoglue.com]
> > > Sent: Thursday, July 24, 2003 3:27 PM
> > > To: tapestry-user@jakarta.apache.org
> > > Subject: Using an Array For Foreach/Selected
> > >
> > >
> > > Hello,
> > >
> > > I have a form with a Foreach component. I want Tapestry to
> > > call setSelected[i] on my page (i is the current index) when
> > > the form is submitted (the form contains a dynamic number of
> > > checkboxes). Thus I declared a property:
> > >
> > > <property-specification name="selected" type="boolean[]"
> > > persistent="yes"/>
> > >
> > > for the page. But the problem is the initialization, because
> > > the size of "selected" depends on another property which is
> > > calculated dynamically when requested.
> > >
> > > So I have two questions:
> > >
> > > 1. How would I initialize the "selected" property?
> >
> > Why persistent?
> >
> > Anyway, implement PageRenderListener and implement pageBeginRender()
> and
> > initialize there.
> >
> > if (getSelected() == null)
> > setSelected(new boolean[100]);
> >
> > >
> > > 2. What would be the OGNL expression for the Foreach
> > > component's "selected" attribute?
> > > selected="ognl:selected[getIndex()] if index is the property
> > > used for Foreach's attribute "index"?
> >
> > ognl:selected[index]
> >
> > or even:
> >
> > ognl:selected[components.myforeach.index]
> >
> > For myforeach@Foreach
> >
> > Foreach includes a read-only index property you can read this way.
> >
> >
> > >
> > > I do not want to add a property "selected" to my domain
> > > objects that are iterated over using Foreach (as shown in the
> > > documentation).
> > >
> > > Thanks for your help,
> > > Michael
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>