Hi all,

I have this code in a Panel:

TextField name = new TextField("name", new PropertyModel(person, "name.value
"));
add(WidgetDecorator.decorate(name).from(person.getName());

I have domain objects (person) with rich type definities. getName() returns
a Text object that contains all constraints imposed on the field (required,
min, max, etc).

WidgetDecorator is a class I build that enriches a particular Wicket
component, based on the type information from the domain object. All
decorate methods on the WidgetDecorator are static and return a component
specific decorator, so in the sample above a new TextFieldDecorator will be
instantiated and returned. It looks like this:

public class TextFieldDecorator {

    private TextField widget;

    public TextFieldDecorator(TextField textField) {
        this.widget = textField;
    }

    public TextField from(Text textType) {
        widget.setRequired(textType.isRequired());
        widget.add(StringValidator.lengthBetween(textType.getMinLength(),
textType.getMaxLength()));
        widget.setLabel(new Model(textType.getFieldName()));
        return widget;
    }
}

Now the problem: Wicket complains that my TextFieldDecorator is not
serializable. But why? IMO it is not added to the component hierarchy. The
argument to the panel.add(...) method is the result of evaluating:
WidgetDecorator.decorate(name).from(person.getName(), which returns the
TextField widget.

Should I redo my Java programmers exam?

Thanx,

-- 
Martijn Lindhout
JointEffort IT Services
http://www.jointeffort.nl
[EMAIL PROTECTED]
+31 (0)6 18 47 25 29

Reply via email to