Hi everyone !
I have two questions.

First, I have a PropertyModel ..

Something similar to this :

add ( new Label("firstResidentName", new PropertyModel<House>(myHouse,
"residents[0].name") ) );

Where House.getResidents() returns a Collection<Person>
and Person.getName() returns the Person's name (a String).

Now say I use this PropertyModel on a House with no residents. I'll get
a IndexOutOfBoundsException.
Is there a way to define a default value for the Label in case the
PropertyModel cannot reach the property ?

In my current situation, I cannot verify directly (before defining the
PropertyModel) if "myHouse" has any residents so the solution would have to
be related to the Label or the Model.

Second,

Using the same example, should my PropertyModel be " PropertyModel<House> "
or " PropertyModel<String> " ? Person.getName() returns a String.

Thanks in advance !

Sincerely,
Guillaume

Reply via email to