final IModel<Itinerary> candidateRouteModel,
int index
)
{
super( id, candidateRouteModel );
Itinerary itinerary = candidateRouteModel.getObject();
IModel<String> header = Model.of( "Route candidate " + index + " - duration: " + itinerary.days() + " days." );
add( new Label( "routeHeader", header ) );
final FeedbackPanel routeFeedback = new FeedbackPanel( "routeFeedback" );
add( routeFeedback.setOutputMarkupId( true ).setEscapeModelStrings( true ) );
IModel<List<Leg>> legListModel = new LoadableDetachableModel<List<Leg>>()
{
@Override
protected List<Leg> load()
{
return candidateRouteModel.getObject().legs().get();
}
};
add( new ListView<Leg>( "legs", legListModel )
{
@Override
protected void populateItem( ListItem<Leg> item )
{
Leg leg = item.getModelObject();
item.add( new Label( "voyage", leg.voyage().get().toString() ),
new Label( "loadLocation", leg.loadLocation().get().getCode() ),
new Label( "loadTime", new Model<Date>( leg.loadTime().get() ) ),
new Label( "unloadLocation", leg.unloadLocation().get().getCode() ),
new Label( "unloadTime", new Model<Date>( leg.unloadTime().get() ) )
);
}
} );
StatelessForm form = new StatelessForm<Void>( "form" );
form.add( new AjaxFallbackButton( "assign", form )
{
@Override
protected void onSubmit( AjaxRequestTarget target, Form<?> form )
{
try
{
Itinerary itinerary = candidateRouteModel.getObject();
new AssignCargoToRoute( trackingIdString, itinerary ).assign();
setResponsePage( CargoDetailsPage.class, new PageParameters().set( 0, trackingIdString ) );
}
catch( Exception e )
{