我有:
public FooPage( ... ) {
this.setDefaultModel( new CompoundPropertyModel(new GenericIdLDM( Foo.class, 1)) );
add(new Label("title"));
我想要$subj。我从 2007 年找到了这个解决方案(如下点): http: //www.mail-archive.com/wicket-user@lists.sourceforge.net/msg29603.html 但是,它不适用于 CPM,因为它需要带有模型的构造函数。
我怎样才能使它与 CPM 一起工作?
public class DefaultTextModel extends AbstractReadOnlyModel<String> {
private final IModel<String> delegate;
private final String def;
public DefaultTextModel(String def, IModel delegate) {
this.def = def;
this.delegate = delegate;
}
public String getObject() {
String s = delegate.getObject();
return (Strings.isEmpty(s)) ? def : s;
}
public void detach() {
delegate.detach();
}
}