There's nothing specifically in the framework, nor anything planned, that
I know of. There is a "ListPropertySelectionModel" in Tassel
(http://www.tapestrycomponents.org/Tassel/app?service=external/ViewComponent&sp=SListPropertySelectionModel)
which does the same thing in almost exactly the same manner (sans the 1.5
requirements).
Robert
> Maybe my java-files didn't get throug in my first mail :)
> I will just paste them here.
> My intent with my mail was to tell people that I have made this
> NamedPropertySelectionModel that I think alot of people would be glad
> to use. I would also want to know if there is something similar in the
> framwork (or planned to be implemented) that I should use instead.
>
> here are the files from my first mail:
>
> package net.keso.ted.peng;
>
> /************ INamedProperty.java ***********/
>
> public interface INamedProperty {
> public String getPropertyName();
> }
>
> /************ NamedPropertySelectionModel.java ***********/
>
> package net.keso.ted.peng;
>
> import java.util.ArrayList;
> import java.util.Arrays;
> import java.util.Collection;
> import java.util.List;
>
> import org.apache.tapestry.form.IPropertySelectionModel;
>
> public class NamedPropertySelectionModel implements
> IPropertySelectionModel {
> private List<INamedProperty> _list;
>
> /**
> * Build an empty named property selection model.
> */
> public NamedPropertySelectionModel() {
> this(Arrays.asList(new INamedProperty[0]));
> }
>
> /**
> * Build a named property selection model.
> * @param list The list
> */
> public NamedPropertySelectionModel(List<INamedProperty> list) {
> _list = list;
> }
>
> /**
> * Build a named property selection model.
> * @param c Collection
> */
> public NamedPropertySelectionModel(Collection<? extends
> INamedProperty> c) {
> _list = new ArrayList<INamedProperty>(c);
> }
>
> /**
> * Get the number of options.
> * @return option count
> */
> public int getOptionCount() { return _list.size(); }
>
> /**
> * Get the option at index.
> * @param index Index
> * @return object Object at index
> */
> public Object getOption(int index) {
> return _list.get(index);
> }
>
> /**
> * Get the label at index.
> * @param index Index
> * @return label Label at index
> */
> public String getLabel(int index) {
> INamedProperty prop = _list.get(index);
> return prop.getPropertyName();
> }
>
> /**
> * Get the value at index.
> * @param index Index
> * @return value Value at index
> */
> public String getValue(int index) {
> return String.valueOf(index);
> }
>
> /**
> * Translate value to object.
> * @param value Value
> * @return object Object from value
> */
> public Object translateValue(String value) {
> return getOption(Integer.parseInt(value));
> }
> }
>
> /***********************/
>
> On 4/27/06, James Carman <[EMAIL PROTECTED]> wrote:
>> So, you want a generic way to generate the value for the objects in the
>> collection (and the display text I presume)?
>>
>> -----Original Message-----
>> From: Ted Steen [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, April 27, 2006 1:26 PM
>> To: Tapestry users
>> Subject: Re: PropertySelectionModel
>>
>> I provided code for the NamedPropertySelectionModel and the
>> INamedProperty interface in my previous message as an attachment.
>>
>> An example would be a page where the model for a @PropertySelection is
>> a new NamedPropertySelectionModel("a collection of objects of type <?
>> extends INamedProperty>");
>>
>> I needed a way to be able to select a property and then get it mapped
>> to an object in my application.
>> Now with NamedPropertySelectionModel I just implement the
>> INamedProperty interface on the classes I want to be able to list as
>> properties on my page.
>> And then instansiate NamedPropertySelectionModel with a Collection of
>> these objects.
>>
>> The naming convention could be a bit messed up as English is not my
>> native language...
>>
>>
>> On 4/27/06, Mark Stang <[EMAIL PROTECTED]> wrote:
>> > Can you provide code and an example?
>> >
>> > regards,
>> >
>> > Mark
>> >
>> >
>> > -----Original Message-----
>> > From: Ted Steen [mailto:[EMAIL PROTECTED]
>> > Sent: Thu 4/27/2006 2:14 AM
>> > To: Tapestry users
>> > Subject: PropertySelectionModel
>> >
>> > I created a "NamedPropertySelectionModel". Is this something that has
>> > already been done that I could find in T4?
>> > It just feels like something alot of people would need.
>> >
>> > Cheers!
>> > /ted
>> >
>> >
>> >
>> >
>>
>>
>> --
>> /ted
>>
>> ---------------------------------------------------------------------
>> 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]
>>
>>
>
>
> --
> /ted
>
> ---------------------------------------------------------------------
> 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]