Hi again,
I simplified th getShortestPath to just generate some fake objects.
A TransportPath is displayed with legs when only one TransportPath is added
When adding several tp's the list is displayed in a table, but clicking on a
title
crashes the UI.
public class ShortestPathService extends AbstractService {
@Hidden
public List<TransportPath> getShortestPaths(TransportDemand td) {
List<TransportPath> l = new ArrayList<TransportPath>();
// if j == 1, i.e. only one element in l, then it works
// otherwise crash in shown table
for (int j = 0; j < 2; j++) {
TransportPath tp = newTransientInstance(TransportPath.class);
for (int i = 0; i < 2; i++) {
ShortLeg sl = newTransientInstance(ShortLeg.class);
sl.setFrom("from " + i + j);
sl.setTo("to " + i + j);
persist(sl);
tp.addLeg(sl);
}
persist(tp);
l.add(tp);
}
return l;
//return getShortestPaths(td.getPickup(), td.getDelivery());
}
The exception:
[exec] ERROR - DefaultExceptionMapper - Unexpected error occurred
[exec] org.apache.wicket.WicketRuntimeException: Can't instantiate page
using constructor 'public
org.apache.isis.viewer.wicket.ui.pages.entity.EntityPage(org.apache.wicket.request.mapper.parameter.PageParameters)'
and argument 'pageType=[ENTITY], pageTitle=[from 00-to 00-to 10]'. Might be it
doesn't exist, may be it is not visible (public).
[exec] at
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:193)
....
...
...
[exec] ... 40 more
[exec] Caused by: java.lang.NullPointerException
[exec] at java.util.regex.Matcher.getTextLength(Matcher.java:1140)
[exec] at java.util.regex.Matcher.reset(Matcher.java:291)
Christian
________________________________________
From: Christian Steinebach [[email protected]]
Sent: Sunday, February 10, 2013 11:38 AM
To: [email protected]
Subject: Presenting the user with alternatives to select one...
Hi everybody!
I'm working on a similar demo as DDDsample (didn't know about it until you
started the discussion)
I have a service installed which should produces a list of alternative
transportation paths from a pickup
to a delivery destination. One of the alternatives should be selected by the
user.
The chosen TransportationPath should then be added to a TransportDemand.
class TransportPath[{
List<ShortLeg> getLegs();
...
}
//for simplicity only to and from
class ShortLeg{
public String getFrom();
public String getTo();
}
The ShortestPathService seems to work ok while generating
TransportPaths with increasing 'costs'. When 'leaving' the service all legs are
instantiated.
Nothing needs to be persisted until the user has chosen an alternative.
Now the questions:
1) While generating the paths I've used createTransientInstance() with persist
and without persist afterwords.
I've use new ...() as well to allocate both new paths and new ShortLegs.
Whenever the transport paths end up in a table, the legs are gone, the list is
empty.
I've build up the title on the fly to check that the legs are originally added
tot the transport path.
And the title is reflecting all legs correctly, but still the added legs are
gone.
When clicking on one alternative, the viewer crashes.
What am I doing wrong here? What would be the correct way of presenting
unpersisted
alternatives to a user where he can select the one.
2) Even when having a list of transport paths (althouhg only titles) where
should I annotate with
@Bulk to make it happen? I've tried several places (TransportDemand,
TransportDemands)
but to no success. Or isn't Bulk the right way to do it?
I'm getting more and more confused and am obviously missing something important
here.
I've put the source on GitHub
https://github.com/chris58/TPM.git
Any help very much appriciated
Christian
I've tried the onaboat project to get some ideas, but when clicking on an
'Undefined Schedule' in Voyage
it crashes too. :-(