From 516c764daa3ed8a3d4cdb7e8a3d621a8cc3b8678 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 27 Jul 2012 16:25:39 +0200 Subject: [PATCH] Show error message on empty name. --- .../net/pterodactylus/demoscenemusic/page/admin/AddArtistPage.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()); -- 2.7.4