diff --git a/ccm-core/src/com/arsdigita/web/WebResources.properties b/ccm-core/src/com/arsdigita/web/WebResources.properties new file mode 100644 index 000000000..27c9e14ed --- /dev/null +++ b/ccm-core/src/com/arsdigita/web/WebResources.properties @@ -0,0 +1,2 @@ +web.ui.url_cannot_contain_/=The url cannot contain '/' +web.ui.app_already_exists=An application already exists with that name diff --git a/ccm-core/src/com/arsdigita/web/WebResources_de.properties b/ccm-core/src/com/arsdigita/web/WebResources_de.properties new file mode 100644 index 000000000..0d83499b5 --- /dev/null +++ b/ccm-core/src/com/arsdigita/web/WebResources_de.properties @@ -0,0 +1,3 @@ + +web.ui.url_cannot_contain_/=Die URL darf kein "/" enthalten +web.ui.app_already_exists=Es besteht bereits eine Anwendung mit diesem Namen. diff --git a/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java b/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java index b87053f76..032288c35 100755 --- a/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java +++ b/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java @@ -43,13 +43,12 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.util.UncheckedWrapperException; +import com.arsdigita.web.util.WebGlobalizationUtil; /** - * An implementation of ResourceConfigFormSection to be - * used for creating / editing Application instances. - * For simple apps, can be used as is. If an app has any - * custom properties, this can be subclassed to add - * futher form fields. + * An implementation of ResourceConfigFormSection to be used for creating / + * editing Application instances. For simple apps, can be used as is. If an app + * has any custom properties, this can be subclassed to add futher form fields. */ public class ApplicationConfigFormSection extends ResourceConfigFormSection { @@ -62,14 +61,14 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { private boolean m_createApplicationGroup = false; public ApplicationConfigFormSection(ResourceType resType, - RequestLocal parentAppRL, - boolean createApplicationGroup) { + RequestLocal parentAppRL, + boolean createApplicationGroup) { this(resType, parentAppRL); m_createApplicationGroup = createApplicationGroup; } public ApplicationConfigFormSection(ResourceType resType, - RequestLocal parentAppRL) { + RequestLocal parentAppRL) { m_applicationType = (ApplicationType) resType; m_parentResource = parentAppRL; m_applicationType.disconnect(); @@ -90,8 +89,8 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { PageState state = e.getPageState(); if (m_currentResource != null) { - Application application = - (Application) m_currentResource.get(state); + Application application + = (Application) m_currentResource.get(state); initWidgets(state, application); } else { initWidgets(state, null); @@ -106,8 +105,8 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { PageState state = e.getPageState(); if (m_currentResource != null) { - Application application = - (Application) m_currentResource.get(state); + Application application + = (Application) m_currentResource.get(state); validateWidgets(state, application); } else { validateWidgets(state, null); @@ -120,9 +119,8 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { } /** - * Adds basic form widgets for URL, title - * and description properties. Override this - * method to add further widget. + * Adds basic form widgets for URL, title and description properties. + * Override this method to add further widget. */ protected void addWidgets() { m_url = new TextField(new StringParameter("url")); @@ -150,12 +148,13 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { /** * Initialize the form fields + * * @param state * @param application the application being edited, if any * @throws com.arsdigita.bebop.FormProcessException */ protected void initWidgets(PageState state, - Application application) + Application application) throws FormProcessException { if (application != null) { @@ -174,17 +173,19 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { /** * Validates the form fields + * * @param application the application being edited */ protected void validateWidgets(PageState state, - Application application) + Application application) throws FormProcessException { String url = (String) m_url.getValue(state); // Change this part if (url.indexOf("/") != -1) { - throw new FormProcessException("The url cannot contain '/'"); + throw new FormProcessException(WebGlobalizationUtil.globalize( + "web.ui.url_cannot_contain_/")); } // amended cg - prevent null pointer exception when // saving edit of child application @@ -203,9 +204,9 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { path = url; } if (Application.isInstalled(Application.BASE_DATA_OBJECT_TYPE, - url)) { - throw new FormProcessException( - "An application already exists with that name"); + url)) { + throw new FormProcessException(WebGlobalizationUtil.globalize( + "web.ui.app_already_exists")); } } @@ -240,10 +241,11 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { /** * Processes the form submission + * * @param application the application being edited, or newly created */ protected void processWidgets(PageState state, - Application application) + Application application) throws FormProcessException { application.setTitle((String) m_title.getValue(state)); application.setDescription((String) m_desc.getValue(state)); diff --git a/ccm-core/src/com/arsdigita/web/util/WebGlobalizationUtil.java b/ccm-core/src/com/arsdigita/web/util/WebGlobalizationUtil.java new file mode 100644 index 000000000..a96bffae5 --- /dev/null +++ b/ccm-core/src/com/arsdigita/web/util/WebGlobalizationUtil.java @@ -0,0 +1,48 @@ + + + +/* + * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.web.util; + +import com.arsdigita.globalization.Globalized; +import com.arsdigita.globalization.GlobalizedMessage; + +/** + *

+ * . + * Contains methods to simplify globalizing keys + *

+ * + * @author Konermann + */ +public class WebGlobalizationUtil implements Globalized { + + private static final String BUNDLE_NAME = "com.arsdigita.web.WebResources"; + + public static GlobalizedMessage globalize(final String key) { + return new GlobalizedMessage(key, BUNDLE_NAME); + } + + public static GlobalizedMessage globalize(final String key, final Object[] args) { + return new GlobalizedMessage(key, BUNDLE_NAME, args); + } + +} +