It's in HEAD of wicket-examples now. As it will take a couple of hours
before this shows up in annon cvs, I attached the patch (apply on the
root of the wicket-examples project).

Eelco

On 9/13/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> No, but I'll make one now.
> 
> Eelco
> 
> 
> On 9/13/05, Jim McBeath <[EMAIL PROTECTED]> wrote:
> > Yes, and I am calling setOptimizeItemRemoval(true) on my ListView objects.
> >
> > Is there an example somewhere of a form that uses and updates a ListView?
> >
> > --
> > Jim
> >
> > On Tue, Sep 13, 2005 at 07:49:18PM +0200, Eelco Hillenius wrote:
> > > From: Eelco Hillenius <[EMAIL PROTECTED]>
> > > To: [email protected]
> > > Subject: Re: [Wicket-user] ListItemModel doesn't update the item in the 
> > > List
> > > Date: Tue, 13 Sep 2005 19:49:18 +0200
> > >
> > > Before you look any further, did you read/do:
> > > http://wicket.sourceforge.net/wiki/index.php/Listviews_in_a_form ?
> > >
> > > Eelco
> > >
> > >
> > > On 9/13/05, Jim McBeath <[EMAIL PROTECTED]> wrote:
> > > > I am working on an app with a form containing a table where some of the
> > > > cells are editable.  The model for the app is a bean with a property
> > > > for the data whose value is a List of Lists.  At the bottom, I create a
> > > > CheckBox or TextField using the ListItem passed to me in populateItem.
> > > > Since my models are all chained back to the original model, I expected
> > > > that when I submitted the form, the data in my app model would be 
> > > > updated.
> > > > However, this does not happen.  From looking at the code for 
> > > > ListItemModel,
> > > > it looks like the new value gets stored in the ListItemModel itself
> > > > rather than getting stored in the List from which that model was 
> > > > created.
> > > >
> > > > ListItemModel.setObject() line 95 sets a local "object" variable rather
> > > > than setting the data into the underlying list in the same way as it
> > > > accesses it in ListItemModel.onAttach() line 70.
> > > >
> > > > Am I reading this correctly?  Shouldn't it be updating the List itself?
> > > > I can do this myself in an onModelChanged() method, but it seems like I
> > > > shouldn't have to.
> > > >
> > > > This is in rc1.
> > > >
> > > > --
> > > > Jim McBeath
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > SF.Net email is Sponsored by the Better Software Conference & EXPO
> > > > September 19-22, 2005 * San Francisco, CA * Development Lifecycle 
> > > > Practices
> > > > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & 
> > > > QA
> > > > Security * Process Improvement & Measurement * 
> > > > http://www.sqe.com/bsce5sf
> > > > _______________________________________________
> > > > Wicket-user mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > >
> > >
> > >
> > > -------------------------------------------------------
> > > SF.Net email is Sponsored by the Better Software Conference & EXPO
> > > September 19-22, 2005 * San Francisco, CA * Development Lifecycle 
> > > Practices
> > > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> > > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> > > _______________________________________________
> > > Wicket-user mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >
> > -------------------------------------------------------
> > SF.Net email is Sponsored by the Better Software Conference & EXPO
> > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> > _______________________________________________
> > Wicket-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
Index: src/java/wicket/examples/forminput/FormInput.html
===================================================================
RCS file: 
/cvsroot/wicket/wicket-examples/src/java/wicket/examples/forminput/FormInput.html,v
retrieving revision 1.20
diff -u -r1.20 FormInput.html
--- src/java/wicket/examples/forminput/FormInput.html   3 Sep 2005 14:00:08 
-0000       1.20
+++ src/java/wicket/examples/forminput/FormInput.html   13 Sep 2005 18:30:13 
-0000
@@ -51,7 +51,11 @@
                                <option>foo</option>
                                <option>bar</option>
                          </select>
-
+                         <ul>
+                          <li wicket:id="lines">
+                           <input type="text" wicket:id="lineEdit" /> 
+                          </li>
+                         </ul>
                  </td>
                  </tr>
                  <tr>
Index: src/java/wicket/examples/forminput/FormInput.java
===================================================================
RCS file: 
/cvsroot/wicket/wicket-examples/src/java/wicket/examples/forminput/FormInput.java,v
retrieving revision 1.58
diff -u -r1.58 FormInput.java
--- src/java/wicket/examples/forminput/FormInput.java   30 Aug 2005 19:21:07 
-0000      1.58
+++ src/java/wicket/examples/forminput/FormInput.java   13 Sep 2005 18:30:13 
-0000
@@ -38,6 +38,8 @@
 import wicket.markup.html.form.validation.IntegerValidator;
 import wicket.markup.html.image.Image;
 import wicket.markup.html.link.Link;
+import wicket.markup.html.list.ListItem;
+import wicket.markup.html.list.ListView;
 import wicket.markup.html.panel.FeedbackPanel;
 import wicket.model.CompoundPropertyModel;
 import wicket.model.PropertyModel;
@@ -144,6 +146,9 @@
                                }
                        });
 
+                       // and this is to show we can nest ListViews in Forms 
too
+                       add(new LinesListView("lines"));
+
                        add(new ImageButton("saveButton"));
 
                        add(new Link("resetButtonLink")
@@ -229,4 +234,26 @@
                        return display;
                }
        }
+
+       /** list view to be nested in the form. */
+       private static final class LinesListView extends ListView
+       {
+
+               /**
+                * Construct.
+                * 
+                * @param id
+                */
+               public LinesListView(String id)
+               {
+                       super(id);
+               }
+
+               protected void populateItem(ListItem item)
+               {
+                       // add a text field that works on each list item model 
(returns objects of
+                       // type FormInputModel.Line) using property text.
+                       item.add(new TextField("lineEdit", new 
PropertyModel(item.getModel(), "text")));
+               }
+       }
 }
\ No newline at end of file
Index: src/java/wicket/examples/forminput/FormInputModel.java
===================================================================
RCS file: 
/cvsroot/wicket/wicket-examples/src/java/wicket/examples/forminput/FormInputModel.java,v
retrieving revision 1.4
diff -u -r1.4 FormInputModel.java
--- src/java/wicket/examples/forminput/FormInputModel.java      23 Apr 2005 
20:13:38 -0000      1.4
+++ src/java/wicket/examples/forminput/FormInputModel.java      13 Sep 2005 
18:30:14 -0000
@@ -20,9 +20,11 @@
 import java.io.Serializable;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -31,6 +33,54 @@
  */
 public final class FormInputModel implements Serializable
 {
+       /**
+        * Represents a line of text. Hack to get around the fact that strings 
are
+        * immutable.
+        */
+       public final class Line
+       {
+               private String text;
+
+               /**
+                * Construct.
+                * 
+                * @param text
+                */
+               public Line(String text)
+               {
+                       this.text = text;
+               }
+
+               /**
+                * Gets text.
+                * 
+                * @return text
+                */
+               public String getText()
+               {
+                       return text;
+               }
+
+               /**
+                * Sets text.
+                * 
+                * @param text
+                *            text
+                */
+               public void setText(String text)
+               {
+                       this.text = text;
+               }
+
+               /**
+                * @see java.lang.Object#toString()
+                */
+               public String toString()
+               {
+                       return text;
+               }
+       }
+
        private String stringProperty = "test";
        private Integer integerProperty = new Integer(100);
        private Double doubleProperty = new Double(20.5);
@@ -40,6 +90,7 @@
        private URL urlProperty;
        private String numberRadioChoice;
        private Set siteSelection = new HashSet();
+       private List lines = new ArrayList();
 
        /**
         * Construct.
@@ -54,6 +105,9 @@
                {
                        e.printStackTrace();
                }
+               lines.add(new Line("line one"));
+               lines.add(new Line("line two"));
+               lines.add(new Line("line three"));
        }
 
        /**
@@ -234,6 +288,24 @@
        }
 
        /**
+        * Gets lines.
+        * @return lines
+        */
+       public List getLines()
+       {
+               return lines;
+       }
+
+       /**
+        * Sets lines.
+        * @param lines lines
+        */
+       public void setLines(List lines)
+       {
+               this.lines = lines;
+       }
+
+       /**
         * @see java.lang.Object#toString()
         */
        public String toString()
@@ -254,6 +326,13 @@
                        if(i.hasNext()) b.append(",");
                }
                b.append("}");
+               b.append(",lines {");
+               for(Iterator i = lines.iterator(); i.hasNext();)
+               {
+                       b.append(i.next());
+                       if(i.hasNext()) b.append(",");
+               }
+               b.append("}");
                b.append("]");
                return b.toString();
        }
Index: src/java/wicket/examples/forminput/FormInput_de.html
===================================================================
RCS file: 
/cvsroot/wicket/wicket-examples/src/java/wicket/examples/forminput/FormInput_de.html,v
retrieving revision 1.7
diff -u -r1.7 FormInput_de.html
--- src/java/wicket/examples/forminput/FormInput_de.html        27 Aug 2005 
20:09:22 -0000      1.7
+++ src/java/wicket/examples/forminput/FormInput_de.html        13 Sep 2005 
18:30:14 -0000
@@ -52,7 +52,11 @@
                                <option>foo</option>
                                <option>bar</option>
                          </select>
-
+                         <ul>
+                          <li wicket:id="lines">
+                           <input type="text" wicket:id="lineEdit" /> 
+                          </li>
+                         </ul>
                  </td>
                  </tr>
                  <tr>
Index: src/java/wicket/examples/forminput/FormInput_nl.html
===================================================================
RCS file: 
/cvsroot/wicket/wicket-examples/src/java/wicket/examples/forminput/FormInput_nl.html,v
retrieving revision 1.9
diff -u -r1.9 FormInput_nl.html
--- src/java/wicket/examples/forminput/FormInput_nl.html        27 Aug 2005 
20:09:22 -0000      1.9
+++ src/java/wicket/examples/forminput/FormInput_nl.html        13 Sep 2005 
18:30:14 -0000
@@ -49,6 +49,11 @@
                                <option>foo</option>
                                <option>bar</option>
                          </select>
+                         <ul>
+                          <li wicket:id="lines">
+                           <input type="text" wicket:id="lineEdit" /> 
+                          </li>
+                         </ul>
                  </td>
                  </tr>
                  <tr>
Index: src/java/wicket/examples/forminput/FormInput_zh_CN.html
===================================================================
RCS file: 
/cvsroot/wicket/wicket-examples/src/java/wicket/examples/forminput/FormInput_zh_CN.html,v
retrieving revision 1.7
diff -u -r1.7 FormInput_zh_CN.html
--- src/java/wicket/examples/forminput/FormInput_zh_CN.html     27 Aug 2005 
20:09:22 -0000      1.7
+++ src/java/wicket/examples/forminput/FormInput_zh_CN.html     13 Sep 2005 
18:30:14 -0000
@@ -51,6 +51,11 @@
                                <option>foo</option>
                                <option>bar</option>
                          </select>
+                         <ul>
+                          <li wicket:id="lines">
+                           <input type="text" wicket:id="lineEdit" /> 
+                          </li>
+                         </ul>
                  </td>
                  </tr>
                  <tr>

Reply via email to