Hi,
I've been having trouble getting my app to run for any reasonable period of
time without crashing. I've laid out a basic page that contains a
ListChoice component, after loading this page 13 times (when I have more
components it's far less) it just hangs indefinitely.
I'm sure the problem is something to do with either storing heavy objects in
memory or a serialization issue (from all that I have read) but I
can't work out why.
I'm using Wicket version 1.2.6 in development mode with Java 5.
Here is my code:
public class Operations extends WebPage {
private String selection;
@SpringBean
private ICategoryDao categoryDao;
public void setCategoryDao(ICategoryDao categoryDao) {
this.categoryDao = categoryDao;
}
...
MyCategory catModel = new MyCategory();
ListChoice categories = new ListChoice(
"categories",
new PropertyModel(catModel, "category"),
new LoadableDetachableModel() {
@Override
protected Object load() {
return categoryDao.getAllCategories();
}
},
new ChoiceRenderer("category", "categoryId"),
5);
add(categories);
...
}
public class MyCategory {
private Category category;
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
}
public class CategoryDao implements ICategoryDao {
@SpringBean
private DataSource dataSource;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
private Connection getConnection() {
return DataSourceUtils.getConnection(dataSource);
}
public List getAllCategories() {
List results = new ArrayList();
try {
PreparedStatement st = getConnection()
.prepareStatement("SELECT Category_ID, Category
FROM Category");
try {
ResultSet rs = st.executeQuery();
while (rs.next()) {
results.add(
new
Category(rs.getInt("Category_ID"), rs.getString("Category"))
);
}
return results;
} finally {
st.close();
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
public class Category implements Serializable {
private int categoryId;
private String category;
public Category(int categoryId, String category) {
this.categoryId = categoryId;
this.category = category;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getCategoryId() {
return categoryId;
}
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
}
Please could you provide some code snippets or comments if you know why this
might be crashing.
Thanks very much for your time, much appreciated.
Regards,
Will
--
View this message in context:
http://www.nabble.com/ListChoice-Crashing-on-13th-Load-tp17672729p17672729.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]