• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with getRowData() method

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic