0 Replies Latest reply on Jul 17, 2012 4:39 AM by Pavel Zelenka

    ListShuttle and converter problem

    Pavel Zelenka Newbie

      Hi,

       

      I use <rich:listShuttle> component which uses objects of Okrsek class. There is a converter associated to this class. Problem is when this converter throws ConverterException. Instead of showing error messages in <rich:messages/> component it always ends up in showing stacktrace. Other JSF and RichFaces component work fine with this converter.

      The only solution is to get rid of throwing exception and put message into FacesContext. Any idea what is wrong?

       

      Thanks

       

      Pavel

      (JSF 1.2, RichFaces 3.3.3, Tomcat 6)

       

      Stacktrace:

      javax.faces.convert.ConverterException: Okrsek '1003033' není platný!
       cz.mediaservis.eds.converters.OkrsekConverter.getAsObject(OkrsekConverter.java:41)
       org.richfaces.renderkit.ListShuttleRendererBase.doDecode(ListShuttleRendererBase.java:345)
       org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)
       javax.faces.component.UIComponentBase.decode(UIComponentBase.java:792)
       org.richfaces.component.UIOrderingBaseComponent.decode(UIOrderingBaseComponent.java:232)
       org.richfaces.component.UIListShuttle.processDecodes(UIListShuttle.java:226)
       org.ajax4jsf.component.UIDataAdaptorBase.processDecodes(UIDataAdaptorBase.java:1173)
       org.richfaces.component.UIOrderingBaseComponent.processDecodes(UIOrderingBaseComponent.java:256)
       javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1029)
       javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1029)
       javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1029)
       org.richfaces.component.UISwitchablePanel.processDecodes(UISwitchablePanel.java:163)
       org.richfaces.component.UITabPanel.processDecodes(UITabPanel.java:155)
       javax.faces.component.UIForm.processDecodes(UIForm.java:208)
       org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:400)
       org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:240)
       org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:417)
       com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
       com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
       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)
       cz.mediaservis.eds.AuthFilter.doFilter(AuthFilter.java:45)
      
      

       

      Converter:

       

      public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
              if (string.isEmpty()) {
                  return null;
              }
              LogistikaDAO dao = new LogistikaDAO();
              Integer id;
              try {
                  id = Integer.parseInt(string);
              } catch (NumberFormatException e) {
                  throw new ConverterException(MessageFactory.getMessage(fc, NUMBER_ID, string, MessageFactory.getLabel(fc, uic)), e);
              }
              Okrsky okrsek = dao.findOkrsek(id);
              if (okrsek != null) {
                  return okrsek;
              } else {
      //            fc.addMessage(null, MessageFactory.getMessage(fc, STRING_ID, string, MessageFactory.getLabel(fc, uic)));
      //            return null;
                  throw new ConverterException(MessageFactory.getMessage(fc, STRING_ID, string, MessageFactory.getLabel(fc, uic)));
              }
          }