@HandlesEvent("createDivision")
public Resolution createDivision() {
String message = EsimsConstants._BLANK_STRING;
Standard standardToBeLinkedWith = this.divisionService
.getStandardById(this.standardId);
Division division = new Division(this.divisionName,
standardToBeLinkedWith, this.teacherInCharge,
this.maxNoOfstudents, this.minNoOfstudents, this.createdOn);
// setting the non mandatory fields
division.setBuildingName(this.buildingName);
division.setLeaderBoy(this.leaderBoy);
division.setLeaderGirl(this.leaderGirl);
division.setNoOfBenches(this.noOfBenches);
division.setNoOfBlackBoards(this.noOfBlackBoards);
division.setNoOfChairs(this.noOfChairs);
division.setNoOfDesks(this.noOfDesks);
division.setNoOfTables(this.noOfTables);
division.setRoomNo(this.roomNo);
// Check if the division already exists in the system.
Division divInSystem = this.divisionService
.checkIfDivisionExists(division);
if (divInSystem != null) {
message = EsimsUtils.createWarnMessage(this.getContext()
.getContextPath(), "<strong>The division "
+ this.divisionName + " already exists !!</strong>");
} else {
this.divisionService.save(division);
message = EsimsUtils.createInfoMessage(this.getContext()
.getContextPath(), "Division <strong>" + this.divisionName
+ "</strong> was created succesfully for "
+ standardToBeLinkedWith.getName());
}
this.getContext().removeAttributeFromSession("listOfStandards");
FlashScope.getCurrent(this.getContext().getRequest(),true).put("message", message);
return new RedirectResolution(DisplayMessageAction.class, "forwardToMessagePage");