Show error message on empty name.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 27 Jul 2012 14:25:39 +0000 (16:25 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 27 Jul 2012 14:25:39 +0000 (16:25 +0200)
src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddArtistPage.java

index 24d5e7b..4ba7f05 100644 (file)
@@ -59,7 +59,11 @@ public class AddArtistPage extends AdminBasePage {
        protected void processTemplate(TemplateContext templateContext, ServletRequest request) throws RedirectException {
                super.processTemplate(templateContext, request);
                if (request.getMethod() == Method.POST) {
-                       String name = request.getServletRequest().getParameter("name");
+                       String name = request.getServletRequest().getParameter("name").trim();
+                       if (name.length() == 0) {
+                               templateContext.set("error", "no-name-given");
+                               return;
+                       }
                        try {
                                Artist artist = getCore().getDataManager().createArtist(name);
                                throw new RedirectException("admin.edit-artist?id=" + artist.getId());