myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard W. Smith, Jr." <smithh032...@gmail.com>
Subject Re: Migrating to CDI: Could not find any registered converter-class by converterId
Date Tue, 20 Nov 2012 19:22:06 GMT
Finally, I went with the following, but for some reason the p:ajax
event="transfer" is not updating my database, and I don't get an ajax
status or message stating that database has been updated. I may need to
report this to PrimeFaces when CDI is used.

*xhtml*
<p:pickList id="pickList" *converter="roleControllerConverter"*


*bean*
    @FacesConverter("roleControllerConverter")
    public static class RoleControllerConverter implements Converter {



On Tue, Nov 20, 2012 at 2:05 PM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:

> Well, blow me down. PrimeFaces picklist component requires me to hardcode
> the converter name, and this is breaking my CDI app.
>
> <p:pickList id="pickList" *converter="roleControllerConverter"*
>             value="#{pf_roleController.rolesPickList}"
>             var="role" itemLabel="#{role.roleName}" itemValue="#{role}">
>     <f:facet name="sourceCaption">Available</f:facet>
>     <f:facet name="targetCaption">Assigned</f:facet>
>     <p:ajax event="transfer" listener="#{pf_roleController.onTransfer}"
>             update=":userDetailForm:_ajax_status
> :userDetailForm:formMessages roleTabPanel"/>
> </p:pickList>
>
> So..., as per the following,
>
> How can I inject in @FacesConverter?<http://stackoverflow.com/questions/13156671/how-can-i-inject-in-facesconverter>
>
> and I changed xhtml to as follows:
>
> <p:pickList id="pickList" *converter="#{roleControllerConverter}"*
>             value="#{pf_roleController.rolesPickList}"
>             var="role" itemLabel="#{role.roleName}" itemValue="#{role}">
>     <f:facet name="sourceCaption">Available</f:facet>
>     <f:facet name="targetCaption">Assigned</f:facet>
>     <p:ajax event="transfer" listener="#{pf_roleController.onTransfer}"
>             update=":userDetailForm:_ajax_status
> :userDetailForm:formMessages roleTabPanel"/>
> </p:pickList>
>
>
> and I added converter to CDI @SessionScoped pf_RoleController, and I
> tested what Mark recommended earlier (bolded below), and now I am not
> getting this exception anymore, but PrimeFaces p:pickList is not updating
> database as it in via JSF Managed Bean.
>
>     @Named
>     @RequestScoped
>     public static class RoleControllerConverter implements Converter {
>
>         public Object getAsObject(FacesContext facesContext, UIComponent
> component, String value) {
>             if (value == null || value.length() == 0) {
>                 return null;
>             }
>             pf_RoleController controller = *
> BeanManagerProvider.getInstance().*
> *
>  getContextualReference(pf_RoleController.class);*
>             if (controller == null) {
>                 System.out.println("RoleControllerConverter.getAsObject()
> failed to get instance of pf_RoleController");
>                 return null;
>             }
>             return controller.ejbFacade.find(value);
>         }
>
>         public String getAsString(FacesContext facesContext, UIComponent
> component, Object object) {
>             if (object == null) {
>                 return null;
>             }
>             if (object instanceof Role) {
>                 Role o = (Role) object;
>                 return o.getRoleName();
>             } else {
>                 throw new IllegalArgumentException("object " + object + "
> is of type " + object.getClass().getName() + "; expected type: " +
> Role.class.getName());
>             }
>         }
>     }
>
>
>
> On Tue, Nov 20, 2012 at 10:57 AM, Howard W. Smith, Jr. <
> smithh032772@gmail.com> wrote:
>
>> Hmmmm, one of the many issues that I need to resolve is this exception
>> that I'm only experiencing only on one xhtml page in my JSF web app, so far
>> (as I haven't regression tested all pages yet).
>>
>>
>>    1. pf_RoleController is CDI managed bean via @Named and @SessionScoped
>>       1. this has no @FacesConverter
>>       2. @Named("pf_roleController")
>>    2. RoleController is JSF @RequestScoped managed bean
>>       1. contains @FacesConverter(forClass = Role.class)
>>       2. @ManagedBean(name = "roleController")
>>    3. pf_UsersController is CDI managed bean via @Named and
>>    @SessionScoped
>>       1. injects and references pf_RoleController (see code below)
>>
>>     @Inject
>>     private pf_RoleController pf_roleController;
>>
>> Below is the exception that I experience when I click View or Edit
>> button, which will open 2 separate xhtml pages, that evidently is
>> attempting to use the RoleControllerConverter.
>>
>> SEVERE: Servlet.service() for servlet [Faces Servlet] in context with
>> path [/mcmsweb] threw exception [Could not find any registered
>> converter-class by converterId : roleControllerConverter] with root cause
>> javax.faces.FacesException: Could not find any registered converter-class
>> by converterId : roleControllerConverter
>> at
>> org.apache.myfaces.application.ApplicationImpl.createConverter(ApplicationImpl.java:1511)
>>  at
>> javax.faces.application.ApplicationWrapper.createConverter(ApplicationWrapper.java:164)
>> at
>> org.apache.myfaces.view.facelets.tag.jsf.ValueHolderRule$LiteralConverterMetadata.applyMetadata(ValueHolderRule.java:50)
>>  at
>> org.apache.myfaces.view.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:45)
>> at
>> javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:66)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:93)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:237)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:158)
>> at
>> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
>>  at
>> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
>> at
>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:394)
>>  at
>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:448)
>> at
>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:426)
>>  at
>> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:244)
>>  at
>> org.apache.myfaces.view.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:217)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:156)
>> at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:58)
>>  at
>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:294)
>>  at
>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
>>  at
>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:49)
>> at
>> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
>>  at
>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:179)
>> at
>> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:452)
>>  at
>> org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreView(DefaultFaceletsStateManagementStrategy.java:273)
>>  at
>> org.apache.myfaces.application.StateManagerImpl.restoreView(StateManagerImpl.java:130)
>> at
>> org.apache.myfaces.shared.view.ViewDeclarationLanguageBase.restoreView(ViewDeclarationLanguageBase.java:106)
>>  at
>> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.restoreView(FaceletViewDeclarationLanguage.java:2118)
>>  at
>> org.apache.myfaces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:300)
>> at
>> javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:83)
>>  at
>> org.omnifaces.viewhandler.RestorableViewHandler.restoreView(RestorableViewHandler.java:66)
>>  at
>> javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:83)
>> at
>> org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:127)
>>  at
>> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
>> at
>> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
>>  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>>  at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>  at
>> org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>>  at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>  at
>> org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:148)
>> at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
>>  at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>>  at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>  at pf.LoginFilter.doFilter(LoginFilter.java:175)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>>  at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>  at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
>>  at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
>> at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
>>  at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
>> at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
>>  at
>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>  at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
>> at
>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
>>  at
>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
>>  at
>> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
>> at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>>  at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>> at java.lang.Thread.run(Thread.java:722)
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message