make dialog close after submitting annotation and fix freemarker syntax