Search code examples
listobjecttapestry

Drop-down from an object list with Tapestry


Actually I've got a UserCred Property on my Tapestry 5.3.7 App...

Is there any way to show a drop-down list of objects instead of enums on a beaneditform?

Thanks guys... I've been looking for any solution, but most of them seems outdated and hard to understand for my poor mind T_T


Solution

  • Tapestry needs two main things to render a Select

    1. A SelectModel to determine the values in the list
    2. A ValueEncoder to know how to render clientside keys which convert to serverside values.

    Notes:

    1. You can @Inject the SelectModelFactory to generate a SelectModel from a list of objects.
    2. There's also an EnumSelectModel to help with enums.
    3. If you don't explicitly provide a ValueEncoder, tapestry will attempt to find one using the ValueEnvoderSource (tapestry-hibernate automagically creates ValueEncoders for all of your entities)
    4. If you pass model parameter which is not an instance of SelectModel, tapestry will attempt to type-coerce the value to a SelectModel. There are a couple of built-in coercions for String, List and Map.