Search code examples
javaselecttapestry

Using custom classes in Tapestry's BeanEditor


I have a class consisting of mostly Strings and a few Doubles which I have a BeanEditor for.

However, I wish to add another field to this class, and the type of that field is my custom class, let's call it Bar.

public class Foo {
    private String myString;
    private Double myDouble;
    private Bar bar;

    // getters and setters
    ...
}

The allowed values for that field are pulled from a database and should appear as a select control.

However, when I try to do this in my page, it's like the myBar doesn't exist in my Foo class.

<beaneditor>
    <p:bar>
        <div class="t-beaneditor-row">
            <label>Bar</label>
            <t:select t:id="barSelecter" t:model="barModel" t:value="foo.bar" t:encoder="barEncoder"/>
        </div>
    </p:bar>
</beaneditor>

How do I accomplish the desired effect?


Solution

  • You'll have to add the bar property to the model.

    Eg <beaneditor add="bar"... >