From 53d7315932f1d1be9e5bdb3bc1c468645f1adf79 Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 15 Mar 2001 19:33:37 +0000 Subject: [PATCH] Added getParameter(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@98 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/webmacro/FormUtil.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/webmacro/FormUtil.java b/projects/samskivert/src/java/com/samskivert/webmacro/FormUtil.java index 421eec6c..3ae380a2 100644 --- a/projects/samskivert/src/java/com/samskivert/webmacro/FormUtil.java +++ b/projects/samskivert/src/java/com/samskivert/webmacro/FormUtil.java @@ -1,5 +1,5 @@ // -// $Id: FormUtil.java,v 1.4 2001/03/04 08:18:28 mdb Exp $ +// $Id: FormUtil.java,v 1.5 2001/03/15 19:33:37 mdb Exp $ package com.samskivert.webmacro; @@ -65,6 +65,22 @@ public class FormUtil return parseDateParameter(context.getForm(name), invalidDataMessage); } + /** + * Fetches the supplied parameter from the request. If the parameter + * does not exist, either null or the empty string will be returned + * depending on the value of the returnNull parameter. + */ + public static String getParameter (WebContext context, String name, + boolean returnNull) + { + String value = context.getForm(name); + if (returnNull || !StringUtil.blank(value)) { + return value; + } else { + return ""; + } + } + /** * Fetches the supplied parameter from the request and converts it to * a date. The value of the parameter should be a date formatted like