2 Replies Latest reply on Dec 5, 2008 7:48 AM by matt.drees

    EL resolution... I'm confused about this

    kragoth

      Ok, can someone explain to me why I'm having problems with this EL.


      I've made a custom component and one of its attributes is an EL expression which should evalutate to a method that takes a string as a parameter, and I've got this working, but what is confusing is that I have to do the EL expression like this:


      resolveEntryMethod="#{AMaintenanceController.findBWithId}"



      If I do it like this


      resolveEntryMethod="#{AMaintenanceController.findBWithId()}"



      This gives me an error


      Caused by javax.servlet.ServletException with message: 
      "class scratch.tje.navTest.AMaintenanceController_$$_javassist_13.findBWithId has 1 params"




      Here is my code that evaluates the expression (Done in my converter):


      String methodExpressionString = 
          ((UITextLookup)component).getResolveEntryMethodExpression();
              
          Class<?> clazz = (Class<?>)component.getAttributes().get("classType");
      
          javax.el.MethodExpression methodExpression = 
              WebUtils.methodHelper(
                  methodExpressionString, 
                  clazz, 
                  new Class<?>[]{String.class});
              
          ELContext elc = context.getELContext();
          Object result = methodExpression.invoke(elc, new Object[]{value});
      



      And the code behind my WebUtils.methodHelper is:


          FacesContext fc = FacesContext.getCurrentInstance();
          ExpressionFactory expFactory = 
              fc.getApplication().getExpressionFactory();
          MethodExpression methodExpression = 
              expFactory.createMethodExpression(
              fc.getELContext(), 
              expression, 
              returnType, 
              params);
      



      And finally the method that is getting called:


      @Name(AMaintenanceController.SEAM_ID)
      @Scope(ScopeType.CONVERSATION)
      public class AMaintenanceController extends AbstractModuleController {
      
          ...
      
          public B findBWithId(String id) {
              return querySvc.read(B.class, Long.valueOf(id));
          }
      
          ...
      }
      




      So I guess ideally I would like my team to be able to type the expression with or without the brackets (). So if someone could tell me what is going on and why having the brackets makes it break that would be great!


      Cheers,
      Tim