You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Todd Orr <to...@gmail.com> on 2005/11/30 04:00:25 UTC

Select Component

Why does the Select component appear to be so complicated? I have an
ArrayList of objects. Each object has id and label properties (among
others). In order for me to display and use these objects I have to
implement IProperySelector. Once one is chosen, I have to loop through the
array until I find the object that was selected. It seems to me that I
should only have to specify the identifier property and the label property.
Tapestry should automatically be able to select the correct object from my
List according to the identifier property. This is how .Net operates. I
believe .Net uses reflection to determine which object to pull out of my
list. In Tapestry, I either have to implement IPropertySelector for each
type of List, or implement an interface on the list items. There seems to be
too much overhead for such a simple and widely performed task as resolving a
selection in a drop-down form element.

Am I doing this incorrectly?

Re: Select Component

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's not listed in the components until we release alpha-7 but tacos has a
BeanPropertySelection model that I think does everything you want in a very
easy way. http://tacos.sourceforge.net. No need to contribute because it's
already there, from cvs head at least ;)

jesse
On 11/29/05, Todd Orr <to...@gmail.com> wrote:
>
> Thanks for your quick reply. You have a point. There is a great deal of
> flexibility in the Tapestry approach. It does seem to sacrifice some
> simplicity, though. I believe in the utility of Tapestry because it makes
> my
> development tasks easier, in general. So, I believe it would help to have
> a
> framework component as described. I do think that the binding to a value
> is
> insufficient for a generalized list approach. I would most appreciate an
> API
> that allowed me to bind one property to the option's display and one to
> its
> value attributes. I think I could knock this one out. Does anyone have any
> more input on this?
>
> On 11/29/05, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >
> >         You're not doing it incorrectly, but you're basing your critique
> > on
> > a false assumption, to whit that the property select component will
> always
> > be backed by an instance of java.util.List containing valid beans. By
> > implementing IPropertySelection, you add a layer of abstraction which
> > means
> > that the property selection no longer knows or cares what your backing
> > data
> > store looks like.
> >
> >         Want to back it with a HashMap? No problem, just implement
> > IPropertySelection.
> >
> >         What about a JDBC result set? No problem.
> >
> >         Now it might well behoove Howard or one of his minions to
> produce
> > a
> > "SimplePropertySelection" which takes as its input a list of beans, but
> > any
> > such simplification would have to be in addition to, rather than a
> > replacement for, the existing interface bases selection model.
> >
> >         For what it's work, I just wrote one wrapper class that wraps a
> > list
> > and use that for all my property selections, so in practice it took
> maybe
> > 5
> > minutes more than it would have otherwise.
> >
> >         --- Pat
> >
> > > -----Original Message-----
> > > From: Todd Orr [mailto:torr0101@gmail.com]
> > > Sent: Tuesday, November 29, 2005 7:00 PM
> > > To: Tapestry users
> > > Subject: Select Component
> > >
> > > Why does the Select component appear to be so complicated? I have an
> > > ArrayList of objects. Each object has id and label properties (among
> > > others). In order for me to display and use these objects I have to
> > > implement IProperySelector. Once one is chosen, I have to loop through
> > the
> > > array until I find the object that was selected. It seems to me that I
> > > should only have to specify the identifier property and the label
> > > property.
> > > Tapestry should automatically be able to select the correct object
> from
> > my
> > > List according to the identifier property. This is how .Net operates.
> I
> > > believe .Net uses reflection to determine which object to pull out of
> my
> > > list. In Tapestry, I either have to implement IPropertySelector for
> each
> > > type of List, or implement an interface on the list items. There seems
> > to
> > > be
> > > too much overhead for such a simple and widely performed task as
> > resolving
> > > a
> > > selection in a drop-down form element.
> > >
> > > Am I doing this incorrectly?
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>

Re: Select Component

Posted by Robert Zeigler <ro...@scazdl.org>.
Have you tried
http://www.tapestrycomponents.org/Tassel/app?service=direct/1/Search/viewComponent&sp=SrobertzListPropertySelectionModel
? It does require implementing the "NamedListItem" interface, but that's
only got a single method "getItemName". Also, if you search the list
archives, somebody posted an implementation of a model that uses ognl to
allow you to do something along the lines of:
new Model(<list of beans>,"some ognl expression for the label")
Which is nice, since you can do something like:
new Model(myList,"'item #' + itemNumber");
And so on. If you don't like any of the existing implementations of
generic wrappers, it certainly doesn't take long to write your own. :)
You could then add it to tassel so other people can benefit, as well. ;)

Robert

On Tue, 2005-11-29 at 20:05 -0800, Todd Orr wrote:
> Thanks for your quick reply. You have a point. There is a great deal of
> flexibility in the Tapestry approach. It does seem to sacrifice some
> simplicity, though. I believe in the utility of Tapestry because it makes my
> development tasks easier, in general. So, I believe it would help to have a
> framework component as described. I do think that the binding to a value is
> insufficient for a generalized list approach. I would most appreciate an API
> that allowed me to bind one property to the option's display and one to its
> value attributes. I think I could knock this one out. Does anyone have any
> more input on this?
> 
> On 11/29/05, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >
> >         You're not doing it incorrectly, but you're basing your critique
> > on
> > a false assumption, to whit that the property select component will always
> > be backed by an instance of java.util.List containing valid beans. By
> > implementing IPropertySelection, you add a layer of abstraction which
> > means
> > that the property selection no longer knows or cares what your backing
> > data
> > store looks like.
> >
> >         Want to back it with a HashMap? No problem, just implement
> > IPropertySelection.
> >
> >         What about a JDBC result set? No problem.
> >
> >         Now it might well behoove Howard or one of his minions to produce
> > a
> > "SimplePropertySelection" which takes as its input a list of beans, but
> > any
> > such simplification would have to be in addition to, rather than a
> > replacement for, the existing interface bases selection model.
> >
> >         For what it's work, I just wrote one wrapper class that wraps a
> > list
> > and use that for all my property selections, so in practice it took maybe
> > 5
> > minutes more than it would have otherwise.
> >
> >         --- Pat
> >
> > > -----Original Message-----
> > > From: Todd Orr [mailto:torr0101@gmail.com]
> > > Sent: Tuesday, November 29, 2005 7:00 PM
> > > To: Tapestry users
> > > Subject: Select Component
> > >
> > > Why does the Select component appear to be so complicated? I have an
> > > ArrayList of objects. Each object has id and label properties (among
> > > others). In order for me to display and use these objects I have to
> > > implement IProperySelector. Once one is chosen, I have to loop through
> > the
> > > array until I find the object that was selected. It seems to me that I
> > > should only have to specify the identifier property and the label
> > > property.
> > > Tapestry should automatically be able to select the correct object from
> > my
> > > List according to the identifier property. This is how .Net operates. I
> > > believe .Net uses reflection to determine which object to pull out of my
> > > list. In Tapestry, I either have to implement IPropertySelector for each
> > > type of List, or implement an interface on the list items. There seems
> > to
> > > be
> > > too much overhead for such a simple and widely performed task as
> > resolving
> > > a
> > > selection in a drop-down form element.
> > >
> > > Am I doing this incorrectly?
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: Select Component

Posted by Todd Orr <to...@gmail.com>.
Cool! Thanks a lot everybody. No need to reinvent the wheel.

On 11/30/05, Leonardo Quijano Vincenzi <le...@dtqsoftware.com> wrote:
>
> I already did this here:
>
> http://issues.apache.org/jira/browse/TAPESTRY-628
>
> It's pending approval though. Of course, some improvements can be done
> (reflection can be very expensive for some needs).
>
> --
> Ing. Leonardo Quijano Vincenzi
> DTQ Software
>
>
> Todd Orr wrote:
> > Thanks for your quick reply. You have a point. There is a great deal of
> > flexibility in the Tapestry approach. It does seem to sacrifice some
> > simplicity, though. I believe in the utility of Tapestry because it
> makes my
> > development tasks easier, in general. So, I believe it would help to
> have a
> > framework component as described. I do think that the binding to a value
> is
> > insufficient for a generalized list approach. I would most appreciate an
> API
> > that allowed me to bind one property to the option's display and one to
> its
> > value attributes. I think I could knock this one out. Does anyone have
> any
> > more input on this?
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: Select Component

Posted by Leonardo Quijano Vincenzi <le...@dtqsoftware.com>.
I already did this here:

http://issues.apache.org/jira/browse/TAPESTRY-628

It's pending approval though. Of course, some improvements can be done 
(reflection can be very expensive for some needs).

-- 
Ing. Leonardo Quijano Vincenzi
DTQ Software


Todd Orr wrote:
> Thanks for your quick reply. You have a point. There is a great deal of
> flexibility in the Tapestry approach. It does seem to sacrifice some
> simplicity, though. I believe in the utility of Tapestry because it makes my
> development tasks easier, in general. So, I believe it would help to have a
> framework component as described. I do think that the binding to a value is
> insufficient for a generalized list approach. I would most appreciate an API
> that allowed me to bind one property to the option's display and one to its
> value attributes. I think I could knock this one out. Does anyone have any
> more input on this?
>   



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


Re: Select Component

Posted by Todd Orr <to...@gmail.com>.
Thanks for your quick reply. You have a point. There is a great deal of
flexibility in the Tapestry approach. It does seem to sacrifice some
simplicity, though. I believe in the utility of Tapestry because it makes my
development tasks easier, in general. So, I believe it would help to have a
framework component as described. I do think that the binding to a value is
insufficient for a generalized list approach. I would most appreciate an API
that allowed me to bind one property to the option's display and one to its
value attributes. I think I could knock this one out. Does anyone have any
more input on this?

On 11/29/05, Patrick Casey <pa...@adelphia.net> wrote:
>
>
>         You're not doing it incorrectly, but you're basing your critique
> on
> a false assumption, to whit that the property select component will always
> be backed by an instance of java.util.List containing valid beans. By
> implementing IPropertySelection, you add a layer of abstraction which
> means
> that the property selection no longer knows or cares what your backing
> data
> store looks like.
>
>         Want to back it with a HashMap? No problem, just implement
> IPropertySelection.
>
>         What about a JDBC result set? No problem.
>
>         Now it might well behoove Howard or one of his minions to produce
> a
> "SimplePropertySelection" which takes as its input a list of beans, but
> any
> such simplification would have to be in addition to, rather than a
> replacement for, the existing interface bases selection model.
>
>         For what it's work, I just wrote one wrapper class that wraps a
> list
> and use that for all my property selections, so in practice it took maybe
> 5
> minutes more than it would have otherwise.
>
>         --- Pat
>
> > -----Original Message-----
> > From: Todd Orr [mailto:torr0101@gmail.com]
> > Sent: Tuesday, November 29, 2005 7:00 PM
> > To: Tapestry users
> > Subject: Select Component
> >
> > Why does the Select component appear to be so complicated? I have an
> > ArrayList of objects. Each object has id and label properties (among
> > others). In order for me to display and use these objects I have to
> > implement IProperySelector. Once one is chosen, I have to loop through
> the
> > array until I find the object that was selected. It seems to me that I
> > should only have to specify the identifier property and the label
> > property.
> > Tapestry should automatically be able to select the correct object from
> my
> > List according to the identifier property. This is how .Net operates. I
> > believe .Net uses reflection to determine which object to pull out of my
> > list. In Tapestry, I either have to implement IPropertySelector for each
> > type of List, or implement an interface on the list items. There seems
> to
> > be
> > too much overhead for such a simple and widely performed task as
> resolving
> > a
> > selection in a drop-down form element.
> >
> > Am I doing this incorrectly?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

RE: Select Component

Posted by Patrick Casey <pa...@adelphia.net>.
	You're not doing it incorrectly, but you're basing your critique on
a false assumption, to whit that the property select component will always
be backed by an instance of java.util.List containing valid beans. By
implementing IPropertySelection, you add a layer of abstraction which means
that the property selection no longer knows or cares what your backing data
store looks like.

	Want to back it with a HashMap? No problem, just implement
IPropertySelection.

	What about a JDBC result set? No problem.

	Now it might well behoove Howard or one of his minions to produce a
"SimplePropertySelection" which takes as its input a list of beans, but any
such simplification would have to be in addition to, rather than a
replacement for, the existing interface bases selection model.

	For what it's work, I just wrote one wrapper class that wraps a list
and use that for all my property selections, so in practice it took maybe 5
minutes more than it would have otherwise.

	--- Pat

> -----Original Message-----
> From: Todd Orr [mailto:torr0101@gmail.com]
> Sent: Tuesday, November 29, 2005 7:00 PM
> To: Tapestry users
> Subject: Select Component
> 
> Why does the Select component appear to be so complicated? I have an
> ArrayList of objects. Each object has id and label properties (among
> others). In order for me to display and use these objects I have to
> implement IProperySelector. Once one is chosen, I have to loop through the
> array until I find the object that was selected. It seems to me that I
> should only have to specify the identifier property and the label
> property.
> Tapestry should automatically be able to select the correct object from my
> List according to the identifier property. This is how .Net operates. I
> believe .Net uses reflection to determine which object to pull out of my
> list. In Tapestry, I either have to implement IPropertySelector for each
> type of List, or implement an interface on the list items. There seems to
> be
> too much overhead for such a simple and widely performed task as resolving
> a
> selection in a drop-down form element.
> 
> Am I doing this incorrectly?



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