From c7edf62aae5a8f4aba20a0383d9d1a4b8ca6aa20 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Wed, 28 Nov 2001 20:28:36 +0000 Subject: [PATCH] fixed that Login dialog so that hitting Enter after keying in your password should trigger the "Log In" button, NOT the reminder button! Also, small enhancements to a couple of classes in conjunction with the new UI work. --- .../util/ServletMultipartHandler.java | 74 ++++++++++++++----- .../venice/servlets/format/LoginDialog.java | 7 +- .../silverwrist/venice/util/XMLLoader.java | 6 ++ 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/com/silverwrist/util/ServletMultipartHandler.java b/src/com/silverwrist/util/ServletMultipartHandler.java index 365b8cd..ce1ffe6 100644 --- a/src/com/silverwrist/util/ServletMultipartHandler.java +++ b/src/com/silverwrist/util/ServletMultipartHandler.java @@ -47,14 +47,14 @@ import org.apache.log4j.*; * @see ServletMultipartException * @see javax.servlet.ServletRequest */ -public class ServletMultipartHandler +public final class ServletMultipartHandler { /*-------------------------------------------------------------------------------- * Internal wrapper around the ServletRequest that implements DataSource *-------------------------------------------------------------------------------- */ - class ServletDataSource implements DataSource + static class ServletDataSource implements DataSource { private ServletRequest request; private InputStream istm = null; @@ -155,7 +155,7 @@ public class ServletMultipartHandler *-------------------------------------------------------------------------------- */ - class MultipartParameter + final class MultipartParameter { private MimeBodyPart part; // the actual body part data private String name; // the parameter name @@ -231,19 +231,19 @@ public class ServletMultipartHandler } // end constructor - public String getName() + public final String getName() { return name; } // end getName - public boolean isFile() + public final boolean isFile() { return (filename!=null); } // end isFile - public String getValue() + public final String getValue() { if (filename!=null) return filename; // "value" for file parts is the filename @@ -265,7 +265,7 @@ public class ServletMultipartHandler } // end getValue - public String getContentType() + public final String getContentType() { try { // pass through to the interior part @@ -281,7 +281,7 @@ public class ServletMultipartHandler } // end getContentType - public int getSize() + public final int getSize() { try { // pass through to the interior part @@ -297,7 +297,7 @@ public class ServletMultipartHandler } // end getSize - public MultipartDataValue getContent() throws ServletMultipartException + public final MultipartDataValue getContent() throws ServletMultipartException { if (filename==null) return null; // not a file parameter @@ -378,7 +378,8 @@ public class ServletMultipartHandler for (int i=0; itrue if the given ServletRequest can be handled by * the ServletMultipartHandler, false if not. */ - public static boolean canHandle(ServletRequest request) + public final static boolean canHandle(ServletRequest request) { String ctype = request.getContentType(); return (ctype.startsWith("multipart/form-data")); @@ -428,7 +429,7 @@ public class ServletMultipartHandler * @see #getParamNames() * @see java.util.Enumeration */ - public Enumeration getNames() + public final Enumeration getNames() { ArrayList tmp_v = new ArrayList(); Iterator it = param_order.iterator(); @@ -451,7 +452,7 @@ public class ServletMultipartHandler * @see #getNames() * @see java.util.Iterator */ - public Iterator getParamNames() + public final Iterator getParamNames() { ArrayList tmp_v = new ArrayList(); Iterator it = param_order.iterator(); @@ -473,7 +474,7 @@ public class ServletMultipartHandler * @return true if the specified parameter is a file parameter, false of not. * If no parameter by this name exists in the request, the method returns false. */ - public boolean isFileParam(String name) + public final boolean isFileParam(String name) { MultipartParameter parm = (MultipartParameter)(param_byname.get(name)); if (parm==null) @@ -489,13 +490,15 @@ public class ServletMultipartHandler /** * Returns the value of the parameter with the specified name. In the case of file parameters, returns - * the name of the file that was uploaded. + * the name of the file that was uploaded.

+ * If the parameter may have multiple values, you should use {@link getParamValues(java.lang.String)} to + * return all possible values for this parameter. * * @param name Name of the parameter to return. * @return Value of the parameter, which is a filename if this parameter is a file. If no parameter by * this name exists in the request, the method returns null. */ - public String getValue(String name) + public final String getValue(String name) { MultipartParameter parm = (MultipartParameter)(param_byname.get(name)); if (parm==null) @@ -509,6 +512,37 @@ public class ServletMultipartHandler } // end getValue + /** + * Returns an array of String objects containing all of the values the given request + * parameter has, or null if the parameter does not exist. In the case of file parameters, + * the value is ne name of the file that was uploaded. If the parameter has a single value, the returned + * array has a length of 1. + * + * @param name Name of the parameter to return. + * @return Array containing all of the values associated with this parameter name. If no values + * are associated with the parameter name, returns null. + */ + public final String[] getParamValues(String name) + { + if (!(param_byname.containsKey(name))) + return null; // no parameters with this name + + // Collect all the parameter values with this name. + ArrayList rc = new ArrayList(param_order.size()); + Iterator it = param_order.iterator(); + while (it.hasNext()) + { // find names that match, copy values + MultipartParameter parm = (MultipartParameter)(it.next()); + if (parm.getName().equals(name)) + rc.add(parm.getValue()); + + } // end while + + // return the results array + return (String[])(rc.toArray(new String[0])); + + } // end getParamValues + /** * Returns the MIME type of the file parameter with the specified name. Ordinary text parameters return * the MIME type text/plain. @@ -517,7 +551,7 @@ public class ServletMultipartHandler * @return Content type of the parameter. If no parameter by this name exists in the request, the method * returns null. */ - public String getContentType(String name) + public final String getContentType(String name) { MultipartParameter parm = (MultipartParameter)(param_byname.get(name)); if (parm==null) @@ -539,7 +573,7 @@ public class ServletMultipartHandler * @return Size in bytes of the parameter. If no parameter by this name exists in the request, the method * returns -1. */ - public int getContentSize(String name) + public final int getContentSize(String name) { MultipartParameter parm = (MultipartParameter)(param_byname.get(name)); if (parm==null) @@ -563,7 +597,7 @@ public class ServletMultipartHandler * @see #getFileContentStream() * @see java.sql.Blob */ - public Blob getFileContentBlob(String name) throws ServletMultipartException + public final Blob getFileContentBlob(String name) throws ServletMultipartException { MultipartParameter parm = (MultipartParameter)(param_byname.get(name)); if (parm==null) @@ -587,7 +621,7 @@ public class ServletMultipartHandler * @see #getFileContentBlob() * @see java.io.InputStream */ - public InputStream getFileContentStream(String name) throws ServletMultipartException + public final InputStream getFileContentStream(String name) throws ServletMultipartException { MultipartParameter parm = (MultipartParameter)(param_byname.get(name)); if (parm==null) diff --git a/src/com/silverwrist/venice/servlets/format/LoginDialog.java b/src/com/silverwrist/venice/servlets/format/LoginDialog.java index 3733775..a4b6627 100644 --- a/src/com/silverwrist/venice/servlets/format/LoginDialog.java +++ b/src/com/silverwrist/venice/servlets/format/LoginDialog.java @@ -33,13 +33,14 @@ public class LoginDialog extends ContentDialog super("Log In",null,"loginform","account"); setHiddenField("cmd","L"); setHiddenField("tgt",""); + setInstructions("Forgot your password? Enter your user name and click the Reminder button to receive " + + "a password reminder via E-mail."); addFormField(new CDVeniceIDFormField("user","User name",null,false,32,64)); - addFormField(new CDPasswordFormFieldCommand("pass","Password",null,false,32,128, - new CDImageButton("remind","bn_reminder.gif","Reminder", - 80,24))); + addFormField(new CDPasswordFormField("pass","Password",null,false,32,128)); addFormField(new CDCheckBoxFormField("saveme","Remember me for next time so I can log in automatically", null,"Y")); addCommandButton(new CDImageButton("login","bn_log_in.gif","Log In",80,24)); + addCommandButton(new CDImageButton("remind","bn_reminder.gif","Password Reminder",80,24)); addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24)); } // end constructor diff --git a/src/com/silverwrist/venice/util/XMLLoader.java b/src/com/silverwrist/venice/util/XMLLoader.java index a7b42f2..1395b9c 100644 --- a/src/com/silverwrist/venice/util/XMLLoader.java +++ b/src/com/silverwrist/venice/util/XMLLoader.java @@ -241,6 +241,12 @@ public class XMLLoader } // end configVerifyNodeName + public final void configVerifyNodeName(Node n, String name) throws ConfigException + { + configVerifyNodeName(n,name,(Element)(n.getParentNode())); + + } // end configVerifyNodeName + public final void configVerifyTagName(Element tag, String name) throws ConfigException { if (tag.getTagName().equals(name))