webtier@glassfish.java.net

JSF page invoking wrong method

From: Salih ERĘKCĘ <salih_1989_at_live.com>
Date: Thu, 20 Nov 2014 19:49:18 +0200

In my JSF page, i am trying to remove an element from a collection.
Instead of calling the `Collection.remove(Object o)` method, i think the
page calls `Vector.remove(int i)`.
private Collection<Tags> tagsCollection; // instantiated by JPA

With the code below i get the following error:

java.lang.IllegalArgumentException: Cannot convert
com.question.entities.Tags[ tagId=12 ] of type class
com.question.entities.Tags to int

     <ui:repeat value="#{backingBean.question.tagsCollection}" var="tag" >
         <li>
             <span>#{tag.tagTitle}</span>
             <h:commandButton>
                 <f:ajax event="click"
listener="#{backingBean.question.tagsCollection.remove(tag)}"
render="@form" execute="@form"/>
             </h:commandButton>
         </li>
     </ui:repeat>