Non Serializable Exception and Illegal State Exception in ExtendedDatatable
iegle Dec 13, 2012 3:44 AMGood morning!
I've been working with Richfaces for a just little time yet, and encountered that problem I couldnt solve. Im loading data from a mysql db, words with some number attributes. Im trying to list them in an extended data table and on click show some detailed information about them. I keep getting NonSerializableException and IllegalStateException. If I use a simple model with only 2 strings and put it in the extendeddatatable-> no problem. but as soon as i take a little more complex model 1 string, 5 ints i get these errors. Can anyone tell me where they get thrown or how to resolve them. thanks in advance
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beans;
import dao.WordDao;
import model.testWord;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.event.AjaxBehaviorEvent;
import model.Word;
import org.richfaces.component.UIExtendedDataTable;
/**
*
* @author Philip
*/
@ManagedBean(name = "ResultTableBean")
@ViewScoped
public class ResultTableBean {
/**
* Creates a new instance of testBean
*/
public ResultTableBean() {
try {
WordDao wdao = WordDao.getInstance();
words = (ArrayList <Word>) wdao.getAllWords();
// words.add(new testWord(someWords.get(0).toString(),"hi"));
// words.add(new testWord(someWords.get(1).toString(),"hi"));
// words.add(new testWord(someWords.get(2).toString(),"hi"));
// words.add(new testWord("Hi my name is B", "anytext"));
// words.add(new testWord("Hi my name is A", "anytext"));
// words.add(new testWord("Hi my name is B", "anytext"));
// words.add(new testWord("Hi my name is A", "anytext"));
// words.add(new testWord("Hi my name is B", "anytext"));
// words.add(new testWord("Hi my name is A", "anytext"));
// words.add(new testWord("Hi my name is B", "anytext"));
// words.add(new testWord("Hi my name is A", "anytext"));
// words.add(new testWord("Hi my name is B", "anytext"));
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
private boolean displaySelection = false;
private List<Word> words = new <Word>ArrayList();
private ArrayList<Word> selectedwords = new <Word>ArrayList();
private String choosenString;
private Collection<Object> selection;
public void someListener() {
System.out.println("hello world");
}
public String getChoosenString() {
return choosenString;
}
public void setChoosenString(String choosenString) {
System.out.println("chosen string set to " + choosenString);
this.choosenString = choosenString;
}
public void selectionListener(AjaxBehaviorEvent event) {
System.out.println("listener called");
UIExtendedDataTable dataTable = (UIExtendedDataTable) event.getComponent();
Object originalKey = dataTable.getRowKey();
selectedwords.clear();
for (Object selectionKey : selection) {
dataTable.setRowKey(selectionKey);
if (dataTable.isRowAvailable()) {
System.out.println("+");
selectedwords.add((Word) dataTable.getRowData());
//dataTable.
} else {
System.out.println("not available");
}
}
//dataTable.s
dataTable.setRowKey(originalKey);
}
public ArrayList<Word> getSelectedwords() {
return selectedwords;
}
public void setSelectedwords(ArrayList<Word> selectedwords) {
this.selectedwords = selectedwords;
}
public List<Word> getWords() {
return words;
}
public void setWords(ArrayList<Word> words) {
this.words = words;
}
public Collection<Object> getSelection() {
return selection;
}
public void setSelection(Collection<Object> selection) {
this.selection = selection;
}
public boolean isDisplaySelection() {
return displaySelection;
}
public void setDisplaySelection(boolean displaySelection) {
this.displaySelection = displaySelection;
}
}
-
resulttable.xhtml.zip 1.4 KB
-
WordDao.java.zip 778 bytes
-
testWord.java.zip 380 bytes
-
Word.java.zip 573 bytes
-
ResultTableBean.java.zip 1.1 KB