2 Replies Latest reply on May 24, 2011 11:13 AM by henry katz

    extending number converter causes odd exception

    henry katz Newbie

      Hi,


      Following the documentation and presumably working example (http://seamframework.org/Community/CustomConverterThatExtendsNumberConverter). I implemented the following converter:




      package com.xxxx.isg.wizard;
      
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.NumberConverter;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.faces.Converter;
      import org.jboss.seam.annotations.intercept.BypassInterceptors;
      
      /**
       * attempt to intercept inputtext input with client-side javascript unsuccessful
       * doing this from converter.
       */
      
      @Name("myNumberConverter")
      @BypassInterceptors
      @Converter
      public class MyNumberConverter extends NumberConverter {
          @Override
          public Object getAsObject(FacesContext context, UIComponent component,
                  String value) {
               setType("percent");
               setMinFractionDigits(2);
               StringBuffer newValue = new StringBuffer(value).append("%");
               return super.getAsObject(context, component, newValue.toString()); 
          }
      }





      and invoke it from a simple text widget:






      <h:inputText  value="#{alloc.vals[0].td.wt}"  onblur="formatPercentage(this,0)" style="width:50px; text-align: right;">
          <a4j:support event="onchange" ajaxSingle="true" reRender="assetAllocPanel"/>
          <f:converter converterId="myNumberConverter"/>
           <!-- f:convertNumber type="percent" minFractionDigits="2" / -->                              
      </h:inputText>



      Under Seam 2.2.1, JSF 1.2, deploying to JBoss 5.1EAP results in the following exception:





      java.lang.NullPointerException
           org.jboss.seam.core.Events.raiseEvent(Events.java:63)
           org.jboss.seam.contexts.Contexts.destroy(Contexts.java:237)
           org.jboss.seam.contexts.Contexts.flushAndDestroyContexts(Contexts.java:379)
           org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:164)
           org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:89)
           org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70)
           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
           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.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      Anyone seen this before and offer a fix?


      TIA,
      Henry