2 Replies Latest reply on Dec 13, 2006 12:15 AM by Chris Hane

    Encoded Request Parameter

    Chris Hane Novice


      I have noticed that in some older browsers that request parameters are being encoded by the browser such that:

      http://somedomain.com/action.seam?param1=v1&param2=v2

      is encoding the & symbol to:


      http://somedomain.com/action.seam?param1=v1&param2=v2

      which means that "param2" looks like "amp;param2".

      Is there a way to get the parameter to be decoded correctly. I'm using JBoss 4.0.4 and Seam 1.0.

      Thanks,
      Chris....

        • 1. Re: Encoded Request Parameter
          Gavin King Master

          Um, how are you adding the parameters? What happens if you try Seam 1.1?

          • 2. Re: Encoded Request Parameter
            Chris Hane Novice

            This is the link I am using:

            http://somedomain.com/action.seam?param1=v1&param2=v2

            For some reason it seams that the browser encodes the link to use "&" instead of just "&".

            I figured this is probably a JSF/Tomcat issue; but it seems like for the short term I can solve it in Seam. I modified Component like this:

            
             private Object convertMultiValueRequestParameter(Map<String, String[]> requestParameters, String name, Class<?> type)
             {
             String[] array = requestParameters.get(name);
            
             if(array == null || array.length==0){
             array = requestParameters.get("amp;"+name);
             }
            
             if (array==null || array.length==0)
             {
             return null;
             }
             else
             {
             if ( type.isArray() )
             {
             int length = Array.getLength(array);
             Class<?> elementType = type.getComponentType();
             Object newInstance = Array.newInstance(elementType, length);
             for ( int i=0; i<length; i++ )
             {
             Object element = convertRequestParameter( (String) Array.get(array, i), elementType );
             Array.set( newInstance, i, element );
             }
             return newInstance;
             }
             else
             {
             return convertRequestParameter( array[0], type );
             }
             }
             }


            So when a RequestParameter is searched for, if it is not found the "amp;"+name version is looked for next. I don't like this solution; but for the short term it's gonna have to suffice. Other suggestions are always welcomed.

            As for Seam 1.1, I am looking forward to using it as soon as I can; but I can't move to the new version right this instant. We are planning on moving to 1.1 in the next couple of months (maybe over xmas) when I have a chance to do some testing. I also need to look into making some of my local modifications to the 1.1 version (specifically - http://jira.jboss.org/jira/browse/JBSEAM-326). None of them are difficult, just need some time.

            Thanks,
            Chris....