Thanks Uli!
Ulrich Stärk wrote: > > Luther Baker schrieb: >> I have an entity that contains another entity - but this time, the >> contained >> entity table is quite finite - say, 10 rows. >> >> public class Category >> { >> private String name; >> } >> >> public class User >> { >> private String firstName; >> private String lastName; >> private Category category; >> } >> >> and in this case, I'd like to render firstName, lastName and a DROP DOWN >> or >> some type of picker from existing Categories. >> >> Would I need to create my own t:form ... and possibly use a t:BeanEditor >> with a custom drop down/picker -- or is this type of idiom encapsulated >> in a >> Tapestry component already? >> >> Thanks much, >> >> -Luther >> > > Indeed you'll have to create a BeanBlockContribution and contribute it to > the BeanBlockSource > service. This contribution tells tapestry where to look for the component, > that is responsible for > rendering your type. Additionally you'll have to contribute your type to > the DefaultDataTypeAnalyzer > service. That could look something along the lines of > > public static void contributeDefaultDataTypeAnalyzer( > MappedConfiguration<Class, String> configuration) > { > configuration.add(Category.class, "category"); > } > > public static void > contributeBeanBlockSource(Configuration<BeanBlockContribution> > configuration) > { > configuration.add(new BeanBlockContribution("category", > "AppPropertyEditBlocks", "category", > true)); > } > > AppPropertyEditBlocks is the name of a page that contains a component with > the id "category" that is > responsible for rendering your category. In your case this would be a > select component: > > @Environmental > private PropertyEditContext context; > > @Component(parameters = > { "value=context.propertyValue", "label=prop:context.label", > "model=prop:categoryModel", "encoder=prop:categoryEncoder", > "clientId=prop:context.propertyId", "validate=prop:validator" }) > private Select category; > > @Inject > private PropertyAccess propertyAccess; > > @SuppressWarnings({ "unused", "unchecked" }) > public FieldValidator getValidator() > { > return context.getValidator(category); > } > > public PropertyEditContext getContext() { return context; } > > public SelectModel<Category> getCategoryModel() > { > ... > } > > public ValueEncoder<Category> getCategoryEncoder() > { > ... > } > with the corresponding .tml: > > <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> > <t:block t:id="category"> > <t:label for="category" /> > <t:select t:id="category" /> > </t:block> > </div> > > I believe that there is also some information about this on the wiki, > check it out! > > HTH, > > Uli > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > -- View this message in context: http://www.nabble.com/Entities-referencing-domain-style-Entities-tp20948001p20983899.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org