As you can see at http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartRequestWrapper.java?only_with_tag=cocoon_2_0_3_branch this bug is fixed since version 1.2 of the file (05.04.2002).

Regards,

Joerg

Volker Schneider wrote:
Dear colleagues,

within Cocoon 2.0.2 I've found another bug which causes a class cast
exception. Maybe it is fixed in Cocoon 2.0.3 but I'm not able to find the
class in the cocoon code repository. If not, please fix it.

If you use a form with

<form method="post" enctype="multipart/form-data" ...>

and you will use an array of checkboxes (<input type="checkbox"...) with
equal names, but different values, you only can select one checkbox. If you
select more than one checkbox and try to get the parameters via
getParameterValues() you will get a class cast excpetion.

This was a bug in the getParameterValues() method in class
"MultipartRequestWrapper.java":

    public String[] getParameterValues(String name) {

        if (values != null)
        {
          Object value = get(name);

          if (value != null)
          {
            if (value instanceof Vector)
            {
              //---- Bug fix (class cast exception)
              //old code:
              //return (String[]) ((Vector) value).toArray();

              //---- begin bug fix
              Vector theVector = (Vector)value;
              String[] theArray = new String[theVector.size()];
              for (int i=0; i<theArray.length; i++)
              {
              	theArray[i] = (String)theVector.elementAt(i);
              }

              return theArray;
              //---- end bug fix
            }
            else
            {
              return new String[]{value.toString()};
            }
          }

          return null;
        }
        else
        {
          return request.getParameterValues(name);
        }
      }

Best regards
- Volker -

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to