From 6cf2fb1d57739cb028624c033af8a50326123b4b Mon Sep 17 00:00:00 2001 From: jensp Date: Tue, 10 Jun 2014 15:43:20 +0000 Subject: [PATCH] Added a PrintListener to the SingleSelect for the default category system of the new ContentSection in the ContentSectionCreateForm. Before this change new Term Domains were not shown until CCM was restarted. git-svn-id: https://svn.libreccm.org/ccm/trunk@2685 8810af33-2d31-482b-a856-94f89814c4df --- .../ContentSectionCreateForm.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java index 936cbf210..12e805d56 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java @@ -27,22 +27,25 @@ import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.NotEmptyValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.categorization.Category; -import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; +import com.arsdigita.util.UncheckedWrapperException; import java.math.BigDecimal; +import java.util.TooManyListenersException; /** * Form for creating a new ContentSection. Used by the {@link ContentSectionAppManager}. - * + * * @author Jens Pelzetter * @version $Id$ */ @@ -65,17 +68,32 @@ public class ContentSectionCreateForm extends Form { add(new Label(GlobalizationUtil.globalize("cms.ui.section.new_section_root_category"))); final SingleSelect rootCategorySelect = new SingleSelect(NEW_SECTION_ROOT_CAT); - final DataCollection categories = SessionManager.getSession().retrieve( - Category.BASE_DATA_OBJECT_TYPE); rootCategorySelect.addOption(new Option("")); - Category current; - while (categories.next()) { - current = (Category) DomainObjectFactory.newInstance(categories.getDataObject()); - if (current.isRoot()) { - rootCategorySelect.addOption(new Option(current.getID().toString(), + + try { + rootCategorySelect.addPrintListener(new PrintListener() { + + @Override + public void prepare(final PrintEvent event) { + final SingleSelect target = (SingleSelect) event.getTarget(); + + final DataCollection categories = SessionManager.getSession().retrieve( + Category.BASE_DATA_OBJECT_TYPE); + Category current; + while (categories.next()) { + current = (Category) DomainObjectFactory.newInstance(categories. + getDataObject()); + if (current.isRoot()) { + target.addOption(new Option(current.getID().toString(), current.getDisplayName())); - } + } + } + } + }); + } catch (TooManyListenersException ex) { + throw new UncheckedWrapperException("Something has gone terribly wrong.", ex); } + rootCategorySelect.addValidationListener(new NotNullValidationListener()); rootCategorySelect.addValidationListener(new NotEmptyValidationListener()); add(rootCategorySelect);