From 2764acd06a8bf5d3e889ea2d3d4f700b90ae65b2 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 11 Nov 2008 23:57:24 +0000 Subject: [PATCH] added form field validation git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13167 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/slaves/CommandLauncher.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/slaves/CommandLauncher.java b/core/src/main/java/hudson/slaves/CommandLauncher.java index c3e908557c..7d9b32ec66 100644 --- a/core/src/main/java/hudson/slaves/CommandLauncher.java +++ b/core/src/main/java/hudson/slaves/CommandLauncher.java @@ -46,11 +46,7 @@ public class CommandLauncher extends ComputerLauncher { return DESCRIPTOR; } - public static final Descriptor DESCRIPTOR = new Descriptor(CommandLauncher.class) { - public String getDisplayName() { - return Messages.CommandLauncher_displayName(); - } - }; + public static final Descriptor DESCRIPTOR = new DescriptorImpl(); /** * Gets the formatted current time stamp. @@ -121,4 +117,25 @@ public class CommandLauncher extends ComputerLauncher { static { LIST.add(DESCRIPTOR); } + + public static class DescriptorImpl extends Descriptor { + public DescriptorImpl() { + super(CommandLauncher.class); + } + + public String getDisplayName() { + return Messages.CommandLauncher_displayName(); + } + + public void doCheckCommand(StaplerRequest req, StaplerResponse rsp, @QueryParameter final String value) throws IOException, ServletException { + new FormFieldValidator(req,rsp,false) { + protected void check() throws IOException, ServletException { + if(Util.fixEmptyAndTrim(value)==null) + error("Command is empty"); + else + ok(); + } + }.process(); + } + } }