Hi 

I have seen that DefaultHref always adds parameters to the request also when 
these parameters are already present; this means that the querystring can 
become too long (above all in Portal Sy). I modified the java code of 
toString method. I post the modified method here. I used it in my project 
and it seems to work. 

 

   public String toString()
   {
       StringBuffer buffer = new StringBuffer(30); 

       buffer.append(this.url); 

       if (this.parameters.size() > 0)
       {
           buffer.append('?');
           Set parameterSet = this.parameters.entrySet(); 

           Iterator iterator = parameterSet.iterator();
           List alreadyAddedKey = Collections.synchronizedList(new 
ArrayList());
           while (iterator.hasNext())
           {
               Map.Entry entry = (Map.Entry) iterator.next(); 

               Object key = entry.getKey();
               Object value = entry.getValue(); 

               if (value == null)
               {
                //According to me this is wrong; if value of parameter is 
null i should put it null
                   //buffer.append(key).append('='); // no value
                //nothing to do
               }
               else if (value.getClass().isArray())
               {
                   Object[] values = (Object[]) value;
                   for (int i = 0; i < values.length; i++)
                   {
                       if (i > 0 && !"".equals(values[i]) && 
!alreadyAddedKey.contains(key))
                       {
                           buffer.append(TagConstants.AMPERSAND);
                       }
                       if( !"".equals(values[i]) && 
!alreadyAddedKey.contains(key)){

                        buffer.append(key).append('=').append(values[i]);
                        alreadyAddedKey.add(key);
                       }
                   }
               }
               else
               {
                if( !"".equals(value) && !alreadyAddedKey.contains(key) ){

                        buffer.append(key).append('=').append(value);
                        alreadyAddedKey.add(key);
                }
               }
               if (iterator.hasNext()&& 
!buffer.toString().endsWith(TagConstants.AMPERSAND))
               {
                   buffer.append(TagConstants.AMPERSAND);
               }
           }
       } 

       if (this.anchor != null)
       {
           buffer.append('#');
           buffer.append(this.anchor);
       }

       return buffer.toString();
   } 

I hope this can be usefull 

Regards,
Angelo.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to