1 Reply Latest reply on Dec 15, 2009 3:55 PM by Ahmad Adly

    Parameter "size" for convert from HTML to java can not be decoded: 11px, reason: Unparseable number: "11px"

    Ahmad Adly Newbie

      Hi all,
      I was developing a seam project that has been generated using seam-gen tool.
      Every thing goes fine until I try to deploy the application to an another machine.
      My environment settings are: Windows XP SP2, jBoss Seam 2.2.0.GA, jBoss AS 5.0.0.GA
      I got this error stack trace.



      java.lang.IllegalArgumentException: Parameter "size" for convert from HTML to java can not be decoded: [11px], reason: Unparseable number: "11px"
              org.ajax4jsf.util.HtmlDimensions.decode(HtmlDimensions.java:65)
              org.richfaces.renderkit.html.images.BaseControlBackgroundImage.getHeight(BaseControlBackgroundImage.java:80)
              org.richfaces.renderkit.html.images.BaseControlBackgroundImage.getHeight(BaseControlBackgroundImage.java:87)
              org.richfaces.renderkit.html.images.BaseControlBackgroundImage.saveData(BaseControlBackgroundImage.java:105)
              org.richfaces.renderkit.html.BaseGradient.getDataToStore(BaseGradient.java:289)
              org.ajax4jsf.resource.InternetResourceBase.getUri(InternetResourceBase.java:218)
              org.ajax4jsf.renderkit.compiler.ResourceElement.getString(ResourceElement.java:114)
              org.ajax4jsf.renderkit.compiler.ClassElement.getString(ClassElement.java:94)
              org.ajax4jsf.renderkit.compiler.ClassElement.encode(ClassElement.java:59)
              org.ajax4jsf.renderkit.compiler.ElementBase.encode(ElementBase.java:105)
              org.ajax4jsf.renderkit.compiler.ElementBase.encode(ElementBase.java:105)
              org.ajax4jsf.renderkit.compiler.RootElement.encode(RootElement.java:64)
              org.ajax4jsf.renderkit.compiler.ElementBase.encode(ElementBase.java:73)
              org.ajax4jsf.resource.TemplateCSSRenderer.send(TemplateCSSRenderer.java:91)
              org.ajax4jsf.resource.InternetResourceBase.send(InternetResourceBase.java:374)
              org.ajax4jsf.resource.ResourceLifecycle.sendResource(ResourceLifecycle.java:215)
              org.ajax4jsf.resource.ResourceLifecycle.send(ResourceLifecycle.java:144)
              org.ajax4jsf.resource.InternetResourceService.load(InternetResourceService.java:335)
              org.ajax4jsf.cache.LRUMapCache.load(LRUMapCache.java:116)
              org.ajax4jsf.cache.LRUMapCache.get(LRUMapCache.java:87)
              org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:195)
              org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
              org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)



      First, I thought that I specified by mistake a size attribute for JSF control with invalid size format. But after reviewing my code I found nothing like that. I tried to google for that problem without any hope.


      Regarding to some search results, some people said that problem raised regarding to Regional Settings in Windows. And others fixed this problem by formatting their OS.
      All of these are not making sense. Can anyone help me in this issue?


      Thanks,


      Ahmad

        • 1. Re: Parameter "size" for convert from HTML to java can not be decoded: 11px, reason: Unparseable number: "11px"
          Ahmad Adly Newbie

          Hi, I have changed my Regional Settings to use English (United States) standards and formats instead of Arabic (Egypt) format. And this fixed my problem. As I mentioned before it makes no sense, but this is what fixing the problem.


          In fact I didn't convened with this problems. So I have opened org.ajax4jsf.util.HtmlDimensions source and copy all decode() method content into a Java class to test it outside jBoss Seam.



          You can see the code that I wrote here:



          import java.text.DecimalFormat;
          import java.text.NumberFormat;
          import java.text.ParseException;
          import java.util.regex.Pattern;
          
          public class TestPattern {
          
               private static final Pattern PATTERN_NUMERIC = Pattern
                         .compile("^[+-]?\\d+(\\.\\d+)?$");
               private static final Pattern PATTERN_PX = Pattern
                         .compile("^[+-]?\\d+(\\.\\d+)?px$");
               private static final Pattern PATTERN_PCT = Pattern
                         .compile("^[+-]?\\d+(\\.\\d+)?%$");
          
               private static final NumberFormat numericFormat = new DecimalFormat();
               private static final DecimalFormat pxFormat;
               private static final NumberFormat pctFormat = NumberFormat
                         .getPercentInstance();
          
               /**
                * @param args
                */
               public static void main(String[] args) {
          
                    System.out.println(System.getProperty("user.language"));
          
                    String size = "11px";
          
                    double d = 0.0D;
                    try {
                         if (size != null) {
                              if (TestPattern.PATTERN_NUMERIC.matcher(size).matches()) {
                                   d = TestPattern.numericFormat.parse(size).doubleValue();
                              } else if (TestPattern.PATTERN_PX.matcher(size).matches()) {
                                   d = TestPattern.pxFormat.parse(size).doubleValue();
                              } else if (TestPattern.PATTERN_PCT.matcher(size).matches()) {
                                   d = TestPattern.pctFormat.parse(size).doubleValue();
                              }
                         }
                    } catch (ParseException e) {
                         e.printStackTrace();
                    }
          
                    System.out.println("d = " + d);
               }
          
               static {
                    pxFormat = new DecimalFormat();
                    TestPattern.pxFormat.setPositiveSuffix("px");
                    TestPattern.pxFormat.setNegativeSuffix("px");
               }
          
          }



          When I run this program using VM argument with -Duser.language=en, it run well. While if I run it again by specifying Arabic as a user language it gives me this exception




          java.text.ParseException: Unparseable number: "11px"
               at java.text.NumberFormat.parse(Unknown Source)
               at test.patterns.TestPattern.main(TestPattern.java:37)




          So I convened that is a bug in Java NumberFormat or something like this