Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod call from an EL fails if method exists with different signatures - JSF2
    text
    copied!<p>I have a backing-bean containing a few methods that share the same names but have different signatures, e.g.:</p> <pre><code>public void voteUp( Member member, ObjectA object ) { ... } public void voteUp( Member member, ObjectB object ) { ... } </code></pre> <p>In the example, <code>ObjectA</code> and <code>ObjectB</code> types don't share anything in common.</p> <p>In my Facelet, I call actions this way:</p> <pre><code>&lt;h:form&gt; &lt;h:commandButton action="#{backingBean.voteUp(membre, objectA)}" ... /&gt; &lt;/h:form&gt; ... &lt;h:form&gt; &lt;h:commandButton action="#{backingBean.voteUp(membre, objectB)}" ... /&gt; &lt;/h:form&gt; </code></pre> <p>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:</p> <blockquote> <p>serverError: class javax.faces.el.EvaluationException Cannot convert com.test.ObjectA@116c1800 of type class com.test.ObjectA to class com.test.ObjectB</p> </blockquote> <p>Since I'm giving my EL an object of type <code>ObjectA</code>, why is it calling the method with the <code>ObjectB</code> signature anyway? Am I forgetting something about Java basics here, or is it my EL interpretor that screws up?</p> <p>I use GlassFish 3.1.2.</p> <p>[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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload