OK, thanks for this.
The reason this isn't working is that these Apple objects aren't entities
and aren't view models and aren't value types, and so Isis has no way to
get a handle on them.
I suspect that a view model is really what you are after. Try writing
Apple like this:
public class Apple implements ViewModel {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String viewModelMemento() {
return name;
}
@Override
public void viewModelInit(String memento) {
this.name = memento;
}
}
and then populate the choices using container.newViewModelInstance(...)
public void customApple(Apple apple) {
System.out.println(apple.getName());
}
public List<Apple> choices0CustomApple() {
List<Apple> list = Lists.newArrayList();
list.add(container.newViewModelInstance(Apple.class, "foo")); //
calls viewModelInit
list.add(container.newViewModelInstance(Apple.class, "bar"));
return list;
}
HTH
Dan
PS: I can see why you might have thought that the @NotPersistable
annotation made sense to use, but (as you've realized) it doesn't do what
you want. In fact, @NotPersistable is not really supported by the Wicket
viewer; it dates back to an earlier, cruder way of managing view models.
We really ought to remove it (I've just created ISIS-743 [1] as a
placeholder).
[1] https://issues.apache.org/jira/browse/ISIS-743