[opencms-dev] Re: Possible bug using I_CmsRequest getParameterValues() with multipart/form-data form and multi valued checkbox

jean-guillaume.battaglia at inexware.fr jean-guillaume.battaglia at inexware.fr
Mon Mar 29 19:08:00 CEST 2004


Hi everybody.

I solved this bug (it was less difficult than I thought).

So I wonder why what I added was not implemented before.

Was it forgotten ?
Or is there a good reason ?

Anyway, please find attached the CmsRequestHttpServlet class modified to handle multiple valued HTTP parameters with multipart/form-data forms.
(All the modifications are surrounded by a commentary with "JG" in it)


Any commentary is welcomed.


                                                  Jean-Guillaume.

 
-----Jean-Guillaume Battaglia/Developpement/Inexware wrote: -----

To: opencms-dev at opencms.org
From: Jean-Guillaume Battaglia/Developpement/Inexware
Date: 03/26/2004 04:08PM
cc: alex at opencms.org
Subject: Possible bug using I_CmsRequest getParameterValues() with multipart/form-data form and multi valued checkbox

Hi everybody.

It's the third time I try to send this message. 
Hope you won't receive it thrice.

With the following form in a JSP :
<form name="rechercheProcedure"
method="post"
action="creationModificationDocument.jsp"
enctype="multipart/form-data">
<input type="checkbox" name="channelIds" id="checkboxChannel1" value="1"/>
<input type="checkbox" name="channelIds" id="checkboxChannel2" value="2"/>
<input type="checkbox" name="channelIds" id="checkboxChannel3" value="3"/>
<input type="checkbox" name="channelIds" id="checkboxChannel4" value="4"/>
<input type="file" name="fileToUpload" >
</form>


I use the following code to log the cmsRequest :
public static Logger logger = Logger.getLogger(MyClass.class);

public void logCmsHttpRequestParameters(CmsObject cmsObject) {
StringBuffer cmsHttpRequestParameters = new StringBuffer();
// [..] Different test to avoid NullPointerException
cmsHttpRequestParameters.append("\r\n Paramètres de la requête HTTP d'OpenCMS :");
Enumeration params = cmsRequest.getParameterNames();
if (params == null) {
cmsHttpRequestParameters.append("\r\n cmsRequest.getParameterNames() :" + params);
} else {
while(params.hasMoreElements()) {
String paramName = (String)params.nextElement();
if (paramName == null) {
cmsHttpRequestParameters.append("\r\nparamName = " + paramName);
} else {
String parameterValues[] = cmsRequest.getParameterValues(paramName);
if (parameterValues == null || parameterValues.length == 0) {
String parameterValue = cmsRequest.getParameter(paramName);
cmsHttpRequestParameters.append("\r\n(" + paramName + ", only one value : " + parameterValue + ")");
} else {
cmsHttpRequestParameters.append("\r\n(" + paramName + ", " + parameterValues.length + " value(s) : ");
for (int i = 0; i < parameterValues.length; i++) {
cmsHttpRequestParameters.append(parameterValues[i]);
if (i == parameterValues.length - 1) {
cmsHttpRequestParameters.append(")");
} else {
cmsHttpRequestParameters.append(", ");
}
}
}
cmsHttpRequestParameters.append("\r\n");
logger.debug(cmsHttpRequestParameters.toString());
}
}


For the parameter channelIds, even when I check several values, I only get one in my log message, for example :
(channelIds, only one value : 2)

Have I done something wrong or is this a bug ?

TIA for any help.


Jean-Guillaume.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CmsRequestHttpServlet.class
Type: application/octet-stream
Size: 10679 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040329/9fb5ff19/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CmsRequestHttpServlet.java
Type: application/octet-stream
Size: 28927 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040329/9fb5ff19/attachment-0001.obj>


More information about the opencms-dev mailing list