Fehler #2400 FormprocessException, modul ccm-core/../web

git-svn-id: https://svn.libreccm.org/ccm/trunk@3220 8810af33-2d31-482b-a856-94f89814c4df
master
konermann 2015-02-18 11:48:23 +00:00
parent e19bf2b8eb
commit 0f1b1cb8b7
4 changed files with 77 additions and 22 deletions

View File

@ -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

View File

@ -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.

View File

@ -43,13 +43,12 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.util.WebGlobalizationUtil;
/** /**
* An implementation of ResourceConfigFormSection to be * An implementation of ResourceConfigFormSection to be used for creating /
* used for creating / editing Application instances. * editing Application instances. For simple apps, can be used as is. If an app
* For simple apps, can be used as is. If an app has any * has any custom properties, this can be subclassed to add futher form fields.
* custom properties, this can be subclassed to add
* futher form fields.
*/ */
public class ApplicationConfigFormSection extends ResourceConfigFormSection { public class ApplicationConfigFormSection extends ResourceConfigFormSection {
@ -62,14 +61,14 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
private boolean m_createApplicationGroup = false; private boolean m_createApplicationGroup = false;
public ApplicationConfigFormSection(ResourceType resType, public ApplicationConfigFormSection(ResourceType resType,
RequestLocal parentAppRL, RequestLocal parentAppRL,
boolean createApplicationGroup) { boolean createApplicationGroup) {
this(resType, parentAppRL); this(resType, parentAppRL);
m_createApplicationGroup = createApplicationGroup; m_createApplicationGroup = createApplicationGroup;
} }
public ApplicationConfigFormSection(ResourceType resType, public ApplicationConfigFormSection(ResourceType resType,
RequestLocal parentAppRL) { RequestLocal parentAppRL) {
m_applicationType = (ApplicationType) resType; m_applicationType = (ApplicationType) resType;
m_parentResource = parentAppRL; m_parentResource = parentAppRL;
m_applicationType.disconnect(); m_applicationType.disconnect();
@ -90,8 +89,8 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
PageState state = e.getPageState(); PageState state = e.getPageState();
if (m_currentResource != null) { if (m_currentResource != null) {
Application application = Application application
(Application) m_currentResource.get(state); = (Application) m_currentResource.get(state);
initWidgets(state, application); initWidgets(state, application);
} else { } else {
initWidgets(state, null); initWidgets(state, null);
@ -106,8 +105,8 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
PageState state = e.getPageState(); PageState state = e.getPageState();
if (m_currentResource != null) { if (m_currentResource != null) {
Application application = Application application
(Application) m_currentResource.get(state); = (Application) m_currentResource.get(state);
validateWidgets(state, application); validateWidgets(state, application);
} else { } else {
validateWidgets(state, null); validateWidgets(state, null);
@ -120,9 +119,8 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
} }
/** /**
* Adds basic form widgets for URL, title * Adds basic form widgets for URL, title and description properties.
* and description properties. Override this * Override this method to add further widget.
* method to add further widget.
*/ */
protected void addWidgets() { protected void addWidgets() {
m_url = new TextField(new StringParameter("url")); m_url = new TextField(new StringParameter("url"));
@ -150,12 +148,13 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
/** /**
* Initialize the form fields * Initialize the form fields
*
* @param state * @param state
* @param application the application being edited, if any * @param application the application being edited, if any
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
protected void initWidgets(PageState state, protected void initWidgets(PageState state,
Application application) Application application)
throws FormProcessException { throws FormProcessException {
if (application != null) { if (application != null) {
@ -174,17 +173,19 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
/** /**
* Validates the form fields * Validates the form fields
*
* @param application the application being edited * @param application the application being edited
*/ */
protected void validateWidgets(PageState state, protected void validateWidgets(PageState state,
Application application) Application application)
throws FormProcessException { throws FormProcessException {
String url = (String) m_url.getValue(state); String url = (String) m_url.getValue(state);
// Change this part // Change this part
if (url.indexOf("/") != -1) { 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 // amended cg - prevent null pointer exception when
// saving edit of child application // saving edit of child application
@ -203,9 +204,9 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
path = url; path = url;
} }
if (Application.isInstalled(Application.BASE_DATA_OBJECT_TYPE, if (Application.isInstalled(Application.BASE_DATA_OBJECT_TYPE,
url)) { url)) {
throw new FormProcessException( throw new FormProcessException(WebGlobalizationUtil.globalize(
"An application already exists with that name"); "web.ui.app_already_exists"));
} }
} }
@ -240,10 +241,11 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
/** /**
* Processes the form submission * Processes the form submission
*
* @param application the application being edited, or newly created * @param application the application being edited, or newly created
*/ */
protected void processWidgets(PageState state, protected void processWidgets(PageState state,
Application application) Application application)
throws FormProcessException { throws FormProcessException {
application.setTitle((String) m_title.getValue(state)); application.setTitle((String) m_title.getValue(state));
application.setDescription((String) m_desc.getValue(state)); application.setDescription((String) m_desc.getValue(state));

View File

@ -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;
/**
* <p>
* .
* Contains methods to simplify globalizing keys
* </p>
*
* @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);
}
}