Your below is correct (at least from my understanding). My only point
is a developer shouldn't need to do this. EIther a) A tag should exist
that already supports this (similar to using html:options in Struts or
b) It should be easy to create you own selectItems while iterating
over the collection on the front end, similar to what you would do
with JSTL
On 9/8/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
> I'm pretty sure this is rhetorical question, but in case it isn't:
>
> public SelectItem[] getSecIndividualItems()
> {
> if (null == secIndividualList)
> {
> secIndividualList = adminDbDataStore.getSecIndividualList();
> }
>
> SelectItem secIndividualItems[] = new
> SelectItem[secIndividualList.size()];
> for (int index = 0; index < secIndividualList.size(); ++index)
> {
> SecIndividual secIndividual = (SecIndividual)
> secIndividualList.get(index);
> secIndividualItems[index] = new SelectItem(secIndividual,
> secIndividual.getName());
> }
>
> return secIndividualItems;
> }
>
> A better way to do it would be to create an EL function
>
> public void getSelectItemsForLabelValueList(List list)
> // where list contains object that implement a LabelValue interface
>
> and register the function.
>
>
> On 9/8/05, Rick Reumann <[EMAIL PROTECTED]> wrote:
> > On 9/8/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote:
> > > It's actually pretty easy,
> >
> > What's the easy part? Creating a tag to do it? I agree it's probably
> > easy for a tag to do this, I was just surprised that it's not already
> > included in MyFaces - it actually should be part of JSF in the
> > selectItems tag imo.
> >
> > > and you don't want to have your back-end
> > > objects tightly coupled to your front-end objects. Your back-end
> > > objects typically should not have any concept of "selections."
> >
> > How are they coupled? I'm just wanting to use a Collection of objects
> > for a drop down? Even struts in its earliest stages had a tag to
> > support this. How is my backend coupled with my front end when I want
> > to make select options? JSF should make things more simple not more
> > difficult. If a method exists to bring me back a Collection of
> > "Regional Vice Presidents" and I want to use that for my select
> > options the famework should be able to handle this. It seems like with
> > JSF (and MyFaces) there is nothing "out of the box" that deals with
> > this.
> >
> > So how would you handle this scenario...
> >
> > A perfectly good method exists that returns you a Collection of
> > "Persons." Each person has a Name and an ID and possibly a few other
> > fields you don't care about it. How do you go about using this
> > Collection to create your select options? (value is id, and label is
> > name)
> >
>
--
Rick