jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Problem with getRowData() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with getRowData() method" Watch "Problem with getRowData() method" New topic

Problem with getRowData() method

Craig Nicoll

Joined: Nov 26, 2004
Posts: 3

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 utputText value="#{cd.title}" />
<h utputText value="#{cd.artist}" />
<h utputText value="�#{cd.price}" />
<h:commandButton id="addtocart" action="#{CDDetails.addToCart}" value="#{bundle.add_to_cart_label}" />
</h ataTable>

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);}
} // 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
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem with getRowData() method
It's not a secret anymore!