add( new ListView<HandlingEventDTO>( "handlingEvents", handlingEventsModel )
{
@Override
protected void populateItem( ListItem<HandlingEventDTO> item )
{
HandlingEventDTO event = item.getModelObject();
Boolean isLast = item.getIndex() == getList().size() - 1;
Boolean isMisdirected = cargoModel.getObject().delivery().get().isMisdirected().get();
// Status icon
IModel iconName = Model.of( isLast && isMisdirected ? "cross.png" : "tick.png" );
item.add( new WebMarkupContainer( "onTrackIcon" ).add( new AttributeAppender( "src", iconName, "" ) ) );
// Date
item.add( new Label( "completion", new Model<Date>( event.completionTime().get() ) ) );
// Event description (data substitution in strings from HandlingHistoryPanel.properties)
ValueMap map = new ValueMap();
map.put( "type", event.handlingEventType().get().name() );
map.put( "location", event.location().get().getString() );
if( event.voyage().get() != null )
{
map.put( "voyage", event.voyage().get().voyageNumber().get().number().get() );
}
IModel text = new StringResourceModel( "handlingEvent.${type}", this, new Model<ValueMap>( map ) );
item.add( new Label( "event", text )
.add( new ErrorColor( isLast && isMisdirected ) )
.setEscapeModelStrings( false ) );