1 Reply Latest reply on Feb 28, 2008 12:27 PM by Nicklas Karlsson

    Help needed Converters with Seam

    Vemula sriramsudheer Newbie

      The following is the converter code I am not using getasObject any where. My main need is getasString



      package com.landmarkSoftware.dv03.client.customConverter;
      
      
      import java.lang.annotation.Annotation;
      
      
      import javax.ejb.Remote;
      
      import javax.ejb.Remove;
      
      import javax.faces.component.UIComponent;
      
      import javax.faces.context.FacesContext;
      
      
      import org.jboss.seam.annotations.AutoCreate;
      
      import org.jboss.seam.annotations.Destroy;
      
      import org.jboss.seam.annotations.Name;
      
      import org.jboss.seam.annotations.faces.Converter;
      
      import org.jboss.seam.annotations.intercept.BypassInterceptors;
      
      
      import com.landmarkSoftware.dv03.deploy.entity.global.Function;
      
      
      @Name("functionConverter")
      
      @Converter
      
      @BypassInterceptors
      
      @AutoCreate
      
      public class FunctionConverter implements javax.faces.convert.Converter{
      
           
      
           Function function = new Function();     
      
           
      
           public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
      
                
      
                return function;
      
           }
      
      
           public String getAsString(FacesContext arg0, UIComponent arg1, Object obj) {
      
                
      
                
      
                if(obj!=null && obj instanceof Function) {
      
                     
      
                     Function function = (Function)obj;
      
                     return function.getFunctionName()+"sriram";
      
                }else {
      
                     return null;
      
                }
      
                
      
           }
      
      
           
      
      }
      
      



      The Following is the .xhtml file In the below code authenticatedFunctionList is a list of Function beans



      <rich:toolBar
      
          xmlns="http://www.w3.org/1999/xhtml"
      
          xmlns:ui="http://java.sun.com/jsf/facelets"
      
          xmlns:h="http://java.sun.com/jsf/html"
      
          xmlns:f="http://java.sun.com/jsf/core"
      
          xmlns:s="http://jboss.com/products/seam/taglib"
      
          xmlns:rich="http://richfaces.org/rich" width="200px" rendered="#{identity.loggedIn}">
      
          
      
          <ui:repeat value="#{authenticatedFunctionList}" var="eachFunction">
      
               
      
               <s:link value="#{eachFunction}" propagation="none">
      
               <f:converter converterId="#{functionConverter}" />         
      
               </s:link>
      
          </ui:repeat>
      
      </rich:toolBar>



      The following is the exception i am getting :



      javax.faces.FacesException: Expression Error: Named Object: client.customConverter.FunctionConverter@40f2f1 not found.
      
           at com.sun.faces.application.ApplicationImpl.createConverter(ApplicationImpl.java:726)
      
           at org.jboss.seam.jsf.SeamApplication.createConverter(SeamApplication.java:112)
      
           at org.jboss.seam.jsf.SeamApplication.createConverter(SeamApplication.java:112)
      
           at com.sun.facelets.tag.jsf.core.ConvertDelegateHandler.createConverter(ConvertDelegateHandler.java:57)
      
           at com.sun.facelets.tag.jsf.ConvertHandler.apply(ConvertHandler.java:108)
      
           at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
      
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
      
           at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
      
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
      
           at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
      
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
      
           at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
      
           at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
      
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
      
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
      
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
      
           at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:144)
      
           at com.sun.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:60)
      
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      
           at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
      
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
      
           at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
      
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
      
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
      
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
      
           at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:144)
      
           at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
      
           at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
      
           at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
      
           at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
      
           at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:524)
      
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
      
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
      
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
      
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      
           at java.lang.Thread.run(Thread.java:595)