title: Wicket: Label with default text if model empty + CompoundPropertyModel
body: <p>I have:</p>
  
  <pre><code>public FooPage( ... ) {
     this.setDefaultModel( new CompoundPropertyModel(new GenericIdLDM( Foo.class, 1)) );
     add(new Label("title"));
  </code></pre>
  
  <p>I'd like to have $subj.
  I've found this solution from 2007 (point below) : <a href="http://www.mail-archive.com/wicket-user@lists.sourceforge.net/msg29603.html" rel="nofollow">http://www.mail-archive.com/wicket-user@lists.sourceforge.net/msg29603.html</a>
  However, it wouldn't work for CPM as it needs the constructor with model.</p>
  
  <p>How could I make it work with CPM?</p>
  
  <pre><code>public class DefaultTextModel extends AbstractReadOnlyModel&lt;String&gt; {
  
  private final IModel&lt;String&gt; 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();
  }
  
  } 
  </code></pre>