Carlos,
I kind of got the code to work, but it doesn't feel right. Any help would be
much appreciated
1. public void buildView() {
2.
3. final BookListView bookListView = new
BookListView("bookListView", new ArrayList());
4.
5. Button addBookButton = new Button("addBookButton") {
6. protected void onSubmit() {
7. String selectedBookName = "The Travels Of John";
8. Book book = new Book();
9. book.setBookName(selectedBookName);
10.
11. List<Book> books = new ArrayList<Book>();
12. books.add(book);
13.
14. BookModel bookModel = new BookModel(books);
15.
16. ListItem bookItem = new
ListItem(bookListView.getModelIndex(), bookModel);
17. bookListView.populateItem(bookItem);
18. bookListView.setModel(bookModel);
19. bookListView.modelChanged();
20. }
21. };
22. }
23.
24. private class BookModel implements IModel {
25.
26. private List bookList;
27.
28. public BookModel(List bookList) {
29. this.bookList = bookList;
30. }
31.
32. public IModel getNestedModel() {
33. return null;
34. }
35.
36. public Object getObject(final Component component) {
37. return bookList;
38. }
39.
40. public void setObject(final Component component, final Object
object) {
41. }
42.
43. public void detach() {
44. }
45. }
46.
47. private class BookListView extends ListView {
48.
49. private int modelIndex;
50.
51. public BookListView(final String id, final List list) {
52. super(id, list);
53. }
54.
55. protected void populateItem(final ListItem listItem) {
56.
57. if (listItem.getModelObject() instanceof Book) {
58. Book book = (Book) listItem.getModelObject();
59.
60. Label bookName = new Label("bookName", new
PropertyModel(book, "bookName"));
61. listItem.add(bookName);
62.
63. setModelIndex(getModelIndex() + 1);
64. }
65. }
66.
67.
68. public int getModelIndex() {
69. return modelIndex;
70. }
71.
72. public void setModelIndex(int modelIndex) {
73. this.modelIndex = modelIndex;
74. }
75. }
76.
77. private class Book implements Serializable {
78. private int id;
79. private String bookName;
80. private boolean selected;
81.
82.
83. public int getId() {
84. return id;
85. }
86.
87. public void setId(int id) {
88. this.id = id;
89. }
90.
91. public String getBookName() {
92. return bookName;
93. }
94.
95. public void setBookName(String bookName) {
96. this.bookName = bookName;
97. }
98.
99. public boolean isSelected() {
100. return selected;
101. }
102.
103. public void setSelected(boolean selected) {
104. this.selected = selected;
105. }
106. }
Carlos Pita-4 wrote:
>
>>
>>
>> I am currently trying to convert the RepeatingView into a ListView, but I
>> am
>> having problems
>> setting the model on the ListView. I call populateItem with a model, but
>> afterwards the model
>> is not being set on the view.
>
>
> That's funny. Could you post the related code?
>
> Regards,
> Carlos
>
>
--
View this message in context:
http://www.nabble.com/RepeatingView-%3A-Removing-a-table-row-tf4331444.html#a12356657
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]