Injecting custom-type parameters with CDI and JSF

Splash Forums Rewrite Users Injecting custom-type parameters with CDI and JSF


This topic contains 2 replies, has 2 voices, and was last updated by  KennethWilcox 1 year, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #27762



    What would be the correct way to inject custom-typed parameters (for which a JSF converter exists) into a JSF bean that has a CDI scope (@RequestScoped) ?

    I’ve tried something like this:

    public class BankAccountNumber { ... } // My custom type
    @FacesConverter(forClass = BankAccountNumber.class)
    public class BankAccountNumberConverter implements Converter { ... }
    @Model // @Named + @javax.enterprise.context.RequestScoped (CDI scope, not JSF)
    @Join(path = "/account/{bankAccountNumber}", to = "/account.xhtml")
    public class AccountBean {
        private BankAccountNumber bankAccountNumber;

    I get the following exception:

    Error during [InboundRewrite [GET url=http://localhost:8080/myapp/account/1234-5678-90, flow=UN_HANDLED, dispatchResource=null]] while executing rule [.addRule(Join.path(“/account/{bankAccountNumber}”).to(“/account.xhtml”))]
    Caused by: java.lang.IllegalArgumentException: Cannot convert 1234-5678-90 of type class java.lang.String to class com.mycompany.BankAccountNumber

    The problem seems to be in CdiExpressionLanguageProvider.setValue(

    ve.setValue(context, factory.coerceToType(value, ve.getType(context)));

    Instead of asking the ExpressionFactory to coerce the value to the given type, shouldn’t it leverage Rewrite’s built-in conversion facility (org.ocpsoft.rewrite.param.Converter<T>, org.ocpsoft.rewrite.spi.ConverterProvider, org.ocpsoft.rewrite.faces.artifact.FacesConverterProvider) ?


    • This topic was modified 4 years, 2 months ago by  kalgon. Reason: typo


    Nevermind, I just had to use @Convert and @Deferred on my property.



    I have the same errors on one of the pages on my site If you have found a solution to this problem, I would be very grateful for a hint.

    • This reply was modified 1 year, 1 month ago by  KennethWilcox.
Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.