1

I have a backing-bean containing a few methods that share the same names but have different signatures, e.g.:

public void voteUp( Member member, ObjectA object ) { ... }
public void voteUp( Member member, ObjectB object ) { ... }

In the example, ObjectA and ObjectB types don't share anything in common.

In my Facelet, I call actions this way:

<h:form>
    <h:commandButton action="#{backingBean.voteUp(membre, objectA)}" ... />
</h:form>
...
<h:form>
    <h:commandButton action="#{backingBean.voteUp(membre, objectB)}" ... />
</h:form>

But it seems that sometimes (not randomly, but probably depending on which signature is first defined in my backing-bean), the method called by one of these EL is the wrong one, and I get one of those exceptions:

serverError: class javax.faces.el.EvaluationException Cannot convert com.test.ObjectA@116c1800 of type class com.test.ObjectA to class com.test.ObjectB

Since I'm giving my EL an object of type ObjectA, why is it calling the method with the ObjectB signature anyway? Am I forgetting something about Java basics here, or is it my EL interpretor that screws up?

I use GlassFish 3.1.2.

[Edit] just to make clear that everything else is ok in my code, when I rename one of the two methods in this example, everything works just fine.

Med
  • 628
  • 9
  • 29
  • 3
    EL [won't have any of that fancy overloadin'](http://stackoverflow.com/a/10326655/1530938) – kolossus Apr 19 '13 at 07:03
  • Damn, I couldn't find this question! Thanks for the tip, although I was kind of hoping for a better way... Well at least I know now, I will rename my methods. You could make your comm an answer to my question. – Med Apr 19 '13 at 07:07

0 Answers0