Hei everybody!
I'm trying to learn isis and DDD, using the wicket viewer.
I have a class TransportDemand which has as a property a pickup destination and
a delivery destination.
The Destination is again defined as a class.
The TransportDemands 'factory and repository' has an action
newTransportDemand();
In order to give the user a choice for the pickup/delivery destinations I
created a method
choicesPickup() in the class TransportDemand
But, in the UI there are no choices presented when selecting 'New Transport
Demand'. Only 'null' is written.
When removing choicesPickup() and declaring the class Destination as @Bounded,
the list of destinations is shown.
What have I done wrong? Some code fragments below.
Thank your for any help
Christian
---- TransportDemand.java
public class TransportDemand extends AbstractDomainObject implements
Comparable<TransportDemand> {
private Destination pickup;
public Destination getPickup() {
return pickup;
}
public List<Destination> choicesPickup(){
return destinations.allDestinations();
}
.....
private Destinations destinations;
public void setDestinations(final Destinations destinations) {
this.destinations = destinations;
}
}
---- TransportDemands.java
public class TransportDemands extends AbstractFactoryAndRepository{
...
public TransportDemand newTransportDemand(
@Named("Pickup") Destination pickup,
@Named("Delivery") Destination delivery
)
{
final TransportDemand transportDemand =
newTransientInstance(TransportDemand.class);
transportDemand.setPickup(pickup);
transportDemand.setDelivery(delivery);
transportDemand.setOwnedBy(currentUserName());
persist(transportDemand);
return transportDemand;
}
public List<TransportDemand> allTransportDemands(){
final String currentUser = currentUserName();
final List<TransportDemand> items = allMatches(TransportDemand.class,
TransportDemand.thoseOwnedBy(currentUser));
Collections.sort(items);
return items;
}
---- Destinations.java
public class Destinations extends AbstractFactoryAndRepository{
....
public List<Destination> allDestinations() {
final List<Destination> items = allInstances(Destination.class);
Collections.sort(items);
return items;
}
}