Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with getRowData() method

 
Craig Nicoll
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having a problem when using the getRowData() method on an instance of UIData. I get the following error message:

javax.faces.el.EvaluationException: java.lang.ClassCastException: java.util.TreeMap

I don't know why TreeMap is mentioned as I don't use it at all. Here is my code:


<h:form id="shoppingForm">
<h ataTable value="#{CDDetails.all}" var="cd" binding="#{CDDetails.table}">
<h:column>
<h utputText value="#{cd.title}" />
</h:column>
<h:column>
<h utputText value="#{cd.artist}" />
</h:column>
<h:column>
<h utputText value="�#{cd.price}" />
</h:column>
<h:column>
<h:commandButton id="addtocart" action="#{CDDetails.addToCart}" value="#{bundle.add_to_cart_label}" />
</h:column>
</h ataTable>
</h:form>


public class CDDetails {

private UIData table;

public void setTable(UIData table) {this.table = table;}
public UIData getTable() {return this.table;}

public void addToCart() {
CD cd = (CD) table.getRowData(); // THE PROBLEM IS HERE
}

public Result getAll() throws SQLException, NamingException {
try{resultSet = DatabaseBean.performQuery
("SELECT * FROM cd WHERE release_date > '2004-01-01' ORDER BY release_date DESC");
return ResultSupport.toResult(resultSet);}
finally{
createItems();
}
}
} // end class CDDetails


public class CD {

public CD(String catalogueNo, String artist, String title, Date releaseDate, String label, String genre, double price){
this.catalogueNo = catalogueNo;
this.artist = artist;
this.title = title;
this.releaseDate = releaseDate;
this.label = label;
this.genre = genre;
this.price = price;
}
}// end class CD


I would be massively grateful if anyone could point out where I'm going wrong
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!