Siemanko, mam taki problem, chce wygenerowac losowo klilkanaście rekordów z tablic i przesłać je do index.xhtml do tabelki. Ale uwala mnie na ArrayList. Zerknijcie w kod:
import java.io.Serializable;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@SessionScoped
@ManagedBean
public class Books implements Serializable {
public static final long serialVersionUID = 1L;
public int newRows;
public List<book> bookshop = new ArrayList<book>();
public String getRandomAuthor(){
String[] authors = new String[10];
for (int i=0; i<10; i++)
authors[i] = "Autor" + i+1;
return authors[(int)(Math.random() * 10)];
}
public String getRandomTitle(){
String[] titles = new String[10];
for (int i=0; i<10; i++)
titles[i] = "Tytuł" + i+1;
return titles[(int)(Math.random() * 10)];
}
public int getRandomIssn(){
return (int)(Math.random() * 1000 + 1100);
}
public double getRandomPrice(){
return (double)(Math.random() * 5.99 + 50);
}
public void randomArray(){
for (int r=0; r<50; r++)
list.add(getRandomAuthor(), getRandomTitle(), getRandomIssn(), getRandomPrice());
}
public List<book> getBookshop(){
return bookshop;
}
public void setNewRows(int newRows){
this.newRows = newRows;
}
public int getNewRows(){
return newRows;
}
}
Błąd jaki otrzymuje to Type book not present