log.error("Error: " + e.getMessage());
}
}
public synchronized void actionCreateSection(CommandRequest request) throws Exception {
MessagesComponentHandler messagesHandler = MessagesComponentHandler.lookup();
if (action != null && (action.equals(ACTION_SAVE) || action.equals(ACTION_PREVIEW))) {
setLangTitle(request);
if (action.equals(ACTION_PREVIEW)) return;
if (validateBeforeEdition()) {
try {
// Create a new section instance.
final Section newSection = new Section();
WorkspaceImpl workspace = (WorkspaceImpl) getWorkspace();
newSection.setTitle(titleMap);
if ((parent != null && !"".equals(parent))) {
newSection.setParent(workspace.getSection(new Long(parent)));
}
newSection.setVisible(Boolean.TRUE);
newSection.setSkinId(skin);
newSection.setEnvelopeId(envelope);
newSection.setRegionsCellSpacing(new Integer(2));
newSection.setPanelsCellSpacing(new Integer(2));
newSection.setLayoutId(layout);
// Make changes persistent
new HibernateTxFragment() {
protected void txFragment(Session session) throws Exception {
((WorkspaceImpl) getWorkspace()).addSection(newSection);
UIServices.lookup().getSectionsManager().store(newSection);
UIServices.lookup().getWorkspacesManager().store(getWorkspace());
}}.execute();
// Finish creation action
this.setDuplicateSection(Boolean.FALSE);
this.setCreateSection(Boolean.FALSE);
this.setSelectedSectionId(null);
defaultValues();
// Print an ok message and move the user into the new page
messagesHandler.addMessage("ui.alert.sectionCreation.OK");
NavigationManager.lookup().setCurrentSection(newSection);
} catch (Exception e) {
log.error("Error creating section: ", e);
messagesHandler.clearAll();
messagesHandler.addError("ui.alert.sectionCreation.KO");
}
}
} else {
this.setDuplicateSection(Boolean.FALSE);
this.setCreateSection(Boolean.FALSE);