Here is your overview (assuming that you want to render your list of schools using a select component):

SelectModel

This is a model of the data you want to render. This could be backed by a list or some other collection type (there is a type coercer from list to selectmodel build into tapestry which automatically converts the one into the other). In your case you will want to populate this model with the available schools.

ValueEncoder

As Thiago already pointed out, this is needed to convert from object to presentation and back.

GenericSelectModel

Search for it in the wiki. It's user-contributed and implements both the SelectModel and the ValueEncoder interfaces. In its constructor, you pass it the type you want to create a model/encoder for, the list of available items (schools in your case), the name of the id property and the name of the property used to display to the user (if null, toString() will be used).

AppPropertyEditBlocks

The name of a page where you define a block used for rendering your custom type (school). This name is arbitrary and can be whatever you like it to be. Here you wire up the select component with your model and encoder. In the page template you define some block whith an explicit id (e.g. schoolBlock).

AppModule

In your AppModule you have to make contributions to the DefaultDataTypeAnalyzer and the BeanBlockSource services.

public static void contributeDefaultDataTypeAnalyzer(
            MappedConfiguration<Class, String> configuration)
{
    configuration.add(School.class, "school");
}

This will assign the name school to your school type for use within tapestry.

With

public static void contributeBeanBlockSource(Configuration<BeanBlockContribution> configuration)
{
configuration.add(new BeanBlockContribution("school", "AppPropertyEditBlocks", "schoolBlock",
                true));
}

you tell Tapestry to render a property of type school with the block "schoolBlock" inside the AppPropertyEditBlocks page.

HTH,

Uli

Luther Baker schrieb:
Given two hibernate objects and a many-to-one relationship

school
{
  name
}

student
{
  firstname

  @ManyToOne
  school
}


I want to pass something like this into a BeanEditForm and have the it
invoke school.toString() or possibly, school.getName().

I know I can add a t:Parameter to t:BeanEditForm but it seems that I should
be able to somehow register the School type with Tapestry and have it simply
invoke school.toString() when required to render itself.

I've looked at
http://wiki.apache.org/tapestry/Tapestry5HowToCreateAPropertyEditBlock but
found it a bit confusing. At some high level, is there a brief synopsis of
the different players required to do this?

PropertyEditor
ValueEncoder
DataTypeAnalyzer
PropertyEditContext
@Environmental
the Model ... etc.

Now, on the other hand, is the BeanEditForm really considered just a starter
component and is generally not used for production code? In which case, is
it just fine to come up with custom solutions to determine types and how to
render them? Or is there a strong reason to go through all of this ... when
I want to render a nested Hibernate Entity with a toString().

Thanks,

-Luther



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to