3 Replies Latest reply: Oct 23, 2008 10:56 PM by Harpreet Dhanoa RSS

    Custom ELResolver in Seam

    Harpreet Dhanoa Newbie


      I have CustomELResolver that I add that after the SeamELResolver in faces-config.xml
      Now I want to call only this CustomELResolver to resolve some special expressions otherwise everything should
      be taken care by SeamELResolver.
      but it my problem is that CUstomELResolver get called for every single expression


      How can i avoid this

      I will really appreciate your help

        • 1. Re: Custom ELResolver in Seam
          Nicklas Karlsson Master

          I don't think you can have multiple resolvers like that (latest probably wins). Try extending the Seam version and call super()-methods where applicable.

          • 2. Re: Custom ELResolver in Seam
            Harpreet Dhanoa Newbie

            Thanks for Reply!
            you are right i can do that,Actually i tried that solution I was successful in overriding the SeamELResolver  like

            public class CustomELResolver extends SeamELResolver {
            public getValue(...){
                    //do the custom stuff
                 super.getValue(..) //call the super

            it works perfect and in faces-config.xml i insert the entry like


            but i do not want to check on my condition for each and every expression and then call the super. To avoid that i am more interested in the idea of CompositeELResolver
            i was under impression that seam/faces do not use the CompositeELResolver from following bug report
            My Link

            and then i tried to write my own implementation of CompositeELResolver and add the SeamELResolver first and then my CustomELResolver, that way it will go to my CustomELResolver if it is not resolved with SeamELResolver

            but on debuging the code  i find that it is always going to my CustomELResolver and also there is  FacesCompositeELResolver class that has 11 ELResolvers including SeamELResolver
            at the 2nd place and this class is present in jsf-api

             * Maintains an ordered composite list of child <code>ELResolver for JSF</code>.
            public class FacesCompositeELResolver extends CompositeELResolver {
                public void add(ELResolver elResolver) {                                                                             

            Ok now I thought oh its great I just add my CustomELResolver at the end  of this FacesCompositeELResolver and my resolver will only get called if the expression is not get resolved from other 11 Resolvers.
            Tried following two solutions
            1) just add the CustomELResolver in faces-config

            this solutions works it added CustomELResolver at third place in FacesCompositeELResolver list

            com.sun.faces.el.ManagedBeanELResolver@ed705f, javax.el.ResourceBundleELResolver@d0c62b, com.sun.faces.el.FacesResourceBundleELResolver@6fa88c, javax.el.MapELResolver@a28ff7, javax.el.ListELResolver@99a27a, javax.el.ArrayELResolver@7a3885, javax.el.BeanELResolver@14b051, com.sun.faces.el.ScopedAttributeELResolver@4395e1, null, null, null, null, null]

            but now  my problem is it is added at 3rd place and it is still going to CustomELResolver for all the Expressions, i want to add this CustomELResolver at end of the resolvers List

            2) then i tried to override the FacesCompositeELResolver class as

            public class CompositeELResolverImpl extends FacesCompositeELResolver{     
                    public CompositeELResolverImpl(ELResolverChainType chainType) {
                 public void add(ELResolver elResolver) {
                           //add all the resolvers          
                            super.add(new SeamELResolver());
                           super.add(new WamELResolver()); //at the end add CustomELResolver
                 public Object getValue(ELContext arg0, Object arg1, Object arg2) {
                      return super.getValue(arg0, arg1, arg2);

            but throws a exceptions as

            4,570 FATAL [jsf] Cant instantiate class: com.company.CompositeELResolverImpl .
            java.lang.InstantiationException:: com.company.CompositeELResolverImpl 
             at java.lang.Class.newInstance0(Class.java:340)
             at java.lang.Class.newInstance(Class.java:308)
             at com.sun.faces.util.Util.createInstance(Util.java:471)
             at com.sun.faces.util.Util.createInstance(Util.java:436)
             at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:601)
             at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:487)
             at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:381)
             at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJ

            I hope i didn't confuse you, the whole  idea is  i want to use the idea of CompositeELResolver and want to add my CustomELResolver at the end so that in all the 99% cases it works as ususal and only go to CustomELResolver to resolve that 1% special expression

            Please give me clue on this FacesCompositeELResolver class so that i can add my ELResolver at the end of his resolvers list

            Thanks in advance

            • 3. Re: Custom ELResolver in Seam
              Harpreet Dhanoa Newbie

              anybody :)