From: David ‘Bombe’ Roden Date: Fri, 27 Jul 2012 14:25:39 +0000 (+0200) Subject: Show error message on empty name. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=516c764daa3ed8a3d4cdb7e8a3d621a8cc3b8678;p=demoscenemusic.git Show error message on empty name. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddArtistPage.java b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddArtistPage.java index 24d5e7b..4ba7f05 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddArtistPage.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddArtistPage.java @@ -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());