blockContainer.addChild(table);
table.setClasses(getTablesClasses());
table.setStyle("width: " + (getInitialWidth() - depth) + "em; margin-left: " + depth + "em;");
for (final Context context : contexts) {
final CurricularCourse curricularCourse = (CurricularCourse) context.getChildDegreeModule();
if (!curricularCourse.isOptionalCurricularCourse()) {
final HtmlTableRow htmlTableRow = table.createRow();
HtmlTableCell cellName = htmlTableRow.createCell();
cellName.setClasses(getCurricularCourseNameClasses());
cellName.setBody(new HtmlText(getCurricularCoursePresentationName(curricularCourse)));
// Year
final HtmlTableCell yearCell = htmlTableRow.createCell();
yearCell.setClasses(getCurricularCourseYearClasses());
yearCell.setBody(new HtmlText(context.getCurricularPeriod().getFullLabel()));
// Ects
final HtmlTableCell ectsCell = htmlTableRow.createCell();
ectsCell.setClasses(getCurricularCourseEctsClasses());
final StringBuilder ects = new StringBuilder();
ects.append(curricularCourse.getEctsCredits()).append(" ")
.append(BundleUtil.getString(Bundle.STUDENT, "label.credits.abbreviation"));
ectsCell.setBody(new HtmlText(ects.toString()));
// Enrollment Link
final HtmlTableCell linkTableCell = htmlTableRow.createCell();
linkTableCell.setClasses(getCurricularCourseLinkClasses());
final HtmlActionLink actionLink = new HtmlActionLink();
actionLink.setText(BundleUtil.getString(Bundle.STUDENT, "label.enroll"));
actionLink.setName("optionalCurricularCourseEnrolLink" + curricularCourse.getExternalId() + "_"
+ context.getExternalId());
actionLink
.setOnClick("$(this).closest('form').find('input[name=\\'method\\']').attr('value', 'enrolInOptionalCurricularCourse');");
//actionLink.setOnClick("document.forms[2].method.value='enrolInOptionalCurricularCourse';");
actionLink.setController(new UpdateSelectedOptionalCurricularCourseController(curricularCourse));