You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sebastian <no...@gmx.net> on 2010/08/14 16:05:15 UTC

Using up/down/remove links of ListView items clears text fields

Hi,

I am trying to use a list view component on a page where rows with text 
fields can be added, removed or moved around. I am using the removeLink, 
moveUpLink and moveDownLink methods of the listview to create the 
respective links for each list item.
The problem is that even when I enable the reuseListItems option, on 
using any of these links the text fields "forget" the recently entered 
data (raw input) and revert to the values of the backing model.

This issue does not occur when I am adding rows the list view.

Below is an example. I can add rows using the "Add Row" button. When I 
enter text into the text fields, when I use the links next to a row, the 
content of any text field is cleared.

Any suggestions?

Regards,

Seb

/******************** PAGE ********************************/
import java.util.*;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.markup.html.list.*;
import org.apache.wicket.model.*;

public class ListViewPage extends WebPage {
   public static class Row {
     public String key;
     public String value;
   }

   private final List<Row> rows = new ArrayList<Row>();

   public ListViewPage(final PageParameters parameters) {

     add(new Form<List<Row>>("rowsForm").

       add(new Button("addRowButton") {
         public void onSubmit() { rows.add(new Row()); }
       }.setDefaultFormProcessing(false)).

       add(new ListView<Row>("rowsList", new 
PropertyModel<List<Row>>(this, "rows")) {
         protected void populateItem(final ListItem<Row> item) {
           final Row row = item.getModelObject();

           item.add(new Label("index", new 
AbstractReadOnlyModel<Integer>() {
            public Integer getObject() { return item.getIndex() + 1; }
           }));

           item.add(new RequiredTextField<String>("key", new 
PropertyModel<String>(row, "key")));

           item.add(new TextField<String>("value", new 
PropertyModel<String>(row, "value")));

           item.add(removeLink("removeRowLink", item));
           item.add(moveUpLink("moveUpLink", item));
           item.add(moveDownLink("moveDownLink", item));
         }
       }.setReuseItems(true)));
   }
}

/******************** HTML ********************************/
<html>
<head><title>ListView Test</title></head>
<body>
   <form wicket:id="rowsForm">
   <button wicket:id="addRowButton">Add Row</button>
   <table><tr wicket:id="rowsList">
      <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
      <td>Key: <input type="text" wicket:id="key" /></td>
      <td>Value: <input type="text" wicket:id="value" /></td>
      <td>
         <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
         <a href="#" wicket:id="moveDownLink">[&darr;]</a>
         <a href="#" wicket:id="removeRowLink">[X]</a>
      </td>
   </tr></table>
   <input type="submit" value="Submit" />
</form>
</body>
</html>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Using up/down/remove links of ListView items clears text fields

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
> how would I use this in my case?

Attach it as onclick event to your link? If you don't have a form in
the hierarchy above it will not work. A form is needed to submit any
kind of data nicely.

And, it does not work without JS.
Really, we are in 2010, I am sure it is time to start ignoring
browsers without JS!

**
Martin

2010/8/14 Sebastian <no...@gmx.net>:
> Hi Martin,
>
> how would I use this in my case? I am relatively new to Wicket. Also does it
> have a graceful fallback for browsers having JS disabled?
>
> Seb
>
> On 14.08.2010 18:39, Martin Makundi wrote:
>>
>> Hi!
>>
>> Again, I have a custom solution for you :)
>>
>> It's called AjaxFormSubmittingChangeListenerBehavior
>>
>>
>> http://apache-wicket.1842946.n4.nabble.com/New-behavior-AjaxFormSubmittingChangeListenerBehavior-td1909633.html#a1909633
>>
>> 2010/8/14 Sebastian<no...@gmx.net>:
>>>
>>> Hi Martin,
>>>
>>> thanks for pointing me to the reuse component concept. It solved my
>>> problem
>>> partially but not completely. The problem is, that the links provided by
>>> the
>>> listview result in HTTP GET request which means that any values recently
>>> entered will not be transferred back and get lost. I am now using my own
>>> link implementations based on the SubmitLink class. I am attaching all
>>> files
>>> of my working example as reference.
>>>
>>> Generally I think it makes great sense to have this behaviour as part of
>>> the
>>> ListView. At least I expected it to work this way in the first place.
>>>
>>> Regards,
>>>
>>> Seb
>>>
>>> On 14.08.2010 16:40, Martin Makundi wrote:
>>>>
>>>> Hi!
>>>>
>>>> You can solve this in a robust manner using reusemanager:
>>>>
>>>> http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html
>>>>
>>>> 2010/8/14 Sebastian<no...@gmx.net>:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to use a list view component on a page where rows with text
>>>>> fields can be added, removed or moved around. I am using the
>>>>> removeLink,
>>>>> moveUpLink and moveDownLink methods of the listview to create the
>>>>> respective
>>>>> links for each list item.
>>>>> The problem is that even when I enable the reuseListItems option, on
>>>>> using
>>>>> any of these links the text fields "forget" the recently entered data
>>>>> (raw
>>>>> input) and revert to the values of the backing model.
>>>>>
>>>>> This issue does not occur when I am adding rows the list view.
>>>>>
>>>>> Below is an example. I can add rows using the "Add Row" button. When I
>>>>> enter
>>>>> text into the text fields, when I use the links next to a row, the
>>>>> content
>>>>> of any text field is cleared.
>>>>>
>>>>> Any suggestions?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Seb
>>>>>
>>>>> /******************** PAGE ********************************/
>>>>> import java.util.*;
>>>>> import org.apache.wicket.PageParameters;
>>>>> import org.apache.wicket.markup.html.WebPage;
>>>>> import org.apache.wicket.markup.html.basic.Label;
>>>>> import org.apache.wicket.markup.html.form.*;
>>>>> import org.apache.wicket.markup.html.list.*;
>>>>> import org.apache.wicket.model.*;
>>>>>
>>>>> public class ListViewPage extends WebPage {
>>>>>  public static class Row {
>>>>>    public String key;
>>>>>    public String value;
>>>>>  }
>>>>>
>>>>>  private final List<Row>    rows = new ArrayList<Row>();
>>>>>
>>>>>  public ListViewPage(final PageParameters parameters) {
>>>>>
>>>>>    add(new Form<List<Row>>("rowsForm").
>>>>>
>>>>>      add(new Button("addRowButton") {
>>>>>        public void onSubmit() { rows.add(new Row()); }
>>>>>      }.setDefaultFormProcessing(false)).
>>>>>
>>>>>      add(new ListView<Row>("rowsList", new
>>>>> PropertyModel<List<Row>>(this,
>>>>> "rows")) {
>>>>>        protected void populateItem(final ListItem<Row>    item) {
>>>>>          final Row row = item.getModelObject();
>>>>>
>>>>>          item.add(new Label("index", new
>>>>> AbstractReadOnlyModel<Integer>()
>>>>> {
>>>>>           public Integer getObject() { return item.getIndex() + 1; }
>>>>>          }));
>>>>>
>>>>>          item.add(new RequiredTextField<String>("key", new
>>>>> PropertyModel<String>(row, "key")));
>>>>>
>>>>>          item.add(new TextField<String>("value", new
>>>>> PropertyModel<String>(row, "value")));
>>>>>
>>>>>          item.add(removeLink("removeRowLink", item));
>>>>>          item.add(moveUpLink("moveUpLink", item));
>>>>>          item.add(moveDownLink("moveDownLink", item));
>>>>>        }
>>>>>      }.setReuseItems(true)));
>>>>>  }
>>>>> }
>>>>>
>>>>> /******************** HTML ********************************/
>>>>> <html>
>>>>> <head><title>ListView Test</title></head>
>>>>> <body>
>>>>>  <form wicket:id="rowsForm">
>>>>>  <button wicket:id="addRowButton">Add Row</button>
>>>>>  <table><tr wicket:id="rowsList">
>>>>>     <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>>>>>     <td>Key:<input type="text" wicket:id="key" /></td>
>>>>>     <td>Value:<input type="text" wicket:id="value" /></td>
>>>>>     <td>
>>>>>        <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>>>>>        <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>>>>>        <a href="#" wicket:id="removeRowLink">[X]</a>
>>>>>     </td>
>>>>>  </tr></table>
>>>>>  <input type="submit" value="Submit" />
>>>>> </form>
>>>>> </body>
>>>>> </html>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Using up/down/remove links of ListView items clears text fields

Posted by Sebastian <no...@gmx.net>.
Hi Martin,

how would I use this in my case? I am relatively new to Wicket. Also 
does it have a graceful fallback for browsers having JS disabled?

Seb

On 14.08.2010 18:39, Martin Makundi wrote:
> Hi!
>
> Again, I have a custom solution for you :)
>
> It's called AjaxFormSubmittingChangeListenerBehavior
>
> http://apache-wicket.1842946.n4.nabble.com/New-behavior-AjaxFormSubmittingChangeListenerBehavior-td1909633.html#a1909633
>
> 2010/8/14 Sebastian<no...@gmx.net>:
>> Hi Martin,
>>
>> thanks for pointing me to the reuse component concept. It solved my problem
>> partially but not completely. The problem is, that the links provided by the
>> listview result in HTTP GET request which means that any values recently
>> entered will not be transferred back and get lost. I am now using my own
>> link implementations based on the SubmitLink class. I am attaching all files
>> of my working example as reference.
>>
>> Generally I think it makes great sense to have this behaviour as part of the
>> ListView. At least I expected it to work this way in the first place.
>>
>> Regards,
>>
>> Seb
>>
>> On 14.08.2010 16:40, Martin Makundi wrote:
>>>
>>> Hi!
>>>
>>> You can solve this in a robust manner using reusemanager:
>>>
>>> http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html
>>>
>>> 2010/8/14 Sebastian<no...@gmx.net>:
>>>>
>>>> Hi,
>>>>
>>>> I am trying to use a list view component on a page where rows with text
>>>> fields can be added, removed or moved around. I am using the removeLink,
>>>> moveUpLink and moveDownLink methods of the listview to create the
>>>> respective
>>>> links for each list item.
>>>> The problem is that even when I enable the reuseListItems option, on
>>>> using
>>>> any of these links the text fields "forget" the recently entered data
>>>> (raw
>>>> input) and revert to the values of the backing model.
>>>>
>>>> This issue does not occur when I am adding rows the list view.
>>>>
>>>> Below is an example. I can add rows using the "Add Row" button. When I
>>>> enter
>>>> text into the text fields, when I use the links next to a row, the
>>>> content
>>>> of any text field is cleared.
>>>>
>>>> Any suggestions?
>>>>
>>>> Regards,
>>>>
>>>> Seb
>>>>
>>>> /******************** PAGE ********************************/
>>>> import java.util.*;
>>>> import org.apache.wicket.PageParameters;
>>>> import org.apache.wicket.markup.html.WebPage;
>>>> import org.apache.wicket.markup.html.basic.Label;
>>>> import org.apache.wicket.markup.html.form.*;
>>>> import org.apache.wicket.markup.html.list.*;
>>>> import org.apache.wicket.model.*;
>>>>
>>>> public class ListViewPage extends WebPage {
>>>>   public static class Row {
>>>>     public String key;
>>>>     public String value;
>>>>   }
>>>>
>>>>   private final List<Row>    rows = new ArrayList<Row>();
>>>>
>>>>   public ListViewPage(final PageParameters parameters) {
>>>>
>>>>     add(new Form<List<Row>>("rowsForm").
>>>>
>>>>       add(new Button("addRowButton") {
>>>>         public void onSubmit() { rows.add(new Row()); }
>>>>       }.setDefaultFormProcessing(false)).
>>>>
>>>>       add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
>>>> "rows")) {
>>>>         protected void populateItem(final ListItem<Row>    item) {
>>>>           final Row row = item.getModelObject();
>>>>
>>>>           item.add(new Label("index", new AbstractReadOnlyModel<Integer>()
>>>> {
>>>>            public Integer getObject() { return item.getIndex() + 1; }
>>>>           }));
>>>>
>>>>           item.add(new RequiredTextField<String>("key", new
>>>> PropertyModel<String>(row, "key")));
>>>>
>>>>           item.add(new TextField<String>("value", new
>>>> PropertyModel<String>(row, "value")));
>>>>
>>>>           item.add(removeLink("removeRowLink", item));
>>>>           item.add(moveUpLink("moveUpLink", item));
>>>>           item.add(moveDownLink("moveDownLink", item));
>>>>         }
>>>>       }.setReuseItems(true)));
>>>>   }
>>>> }
>>>>
>>>> /******************** HTML ********************************/
>>>> <html>
>>>> <head><title>ListView Test</title></head>
>>>> <body>
>>>>   <form wicket:id="rowsForm">
>>>>   <button wicket:id="addRowButton">Add Row</button>
>>>>   <table><tr wicket:id="rowsList">
>>>>      <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>>>>      <td>Key:<input type="text" wicket:id="key" /></td>
>>>>      <td>Value:<input type="text" wicket:id="value" /></td>
>>>>      <td>
>>>>         <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>>>>         <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>>>>         <a href="#" wicket:id="removeRowLink">[X]</a>
>>>>      </td>
>>>>   </tr></table>
>>>>   <input type="submit" value="Submit" />
>>>> </form>
>>>> </body>
>>>> </html>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Using up/down/remove links of ListView items clears text fields

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

Again, I have a custom solution for you :)

It's called AjaxFormSubmittingChangeListenerBehavior

http://apache-wicket.1842946.n4.nabble.com/New-behavior-AjaxFormSubmittingChangeListenerBehavior-td1909633.html#a1909633

2010/8/14 Sebastian <no...@gmx.net>:
> Hi Martin,
>
> thanks for pointing me to the reuse component concept. It solved my problem
> partially but not completely. The problem is, that the links provided by the
> listview result in HTTP GET request which means that any values recently
> entered will not be transferred back and get lost. I am now using my own
> link implementations based on the SubmitLink class. I am attaching all files
> of my working example as reference.
>
> Generally I think it makes great sense to have this behaviour as part of the
> ListView. At least I expected it to work this way in the first place.
>
> Regards,
>
> Seb
>
> On 14.08.2010 16:40, Martin Makundi wrote:
>>
>> Hi!
>>
>> You can solve this in a robust manner using reusemanager:
>>
>> http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html
>>
>> 2010/8/14 Sebastian<no...@gmx.net>:
>>>
>>> Hi,
>>>
>>> I am trying to use a list view component on a page where rows with text
>>> fields can be added, removed or moved around. I am using the removeLink,
>>> moveUpLink and moveDownLink methods of the listview to create the
>>> respective
>>> links for each list item.
>>> The problem is that even when I enable the reuseListItems option, on
>>> using
>>> any of these links the text fields "forget" the recently entered data
>>> (raw
>>> input) and revert to the values of the backing model.
>>>
>>> This issue does not occur when I am adding rows the list view.
>>>
>>> Below is an example. I can add rows using the "Add Row" button. When I
>>> enter
>>> text into the text fields, when I use the links next to a row, the
>>> content
>>> of any text field is cleared.
>>>
>>> Any suggestions?
>>>
>>> Regards,
>>>
>>> Seb
>>>
>>> /******************** PAGE ********************************/
>>> import java.util.*;
>>> import org.apache.wicket.PageParameters;
>>> import org.apache.wicket.markup.html.WebPage;
>>> import org.apache.wicket.markup.html.basic.Label;
>>> import org.apache.wicket.markup.html.form.*;
>>> import org.apache.wicket.markup.html.list.*;
>>> import org.apache.wicket.model.*;
>>>
>>> public class ListViewPage extends WebPage {
>>>  public static class Row {
>>>    public String key;
>>>    public String value;
>>>  }
>>>
>>>  private final List<Row>  rows = new ArrayList<Row>();
>>>
>>>  public ListViewPage(final PageParameters parameters) {
>>>
>>>    add(new Form<List<Row>>("rowsForm").
>>>
>>>      add(new Button("addRowButton") {
>>>        public void onSubmit() { rows.add(new Row()); }
>>>      }.setDefaultFormProcessing(false)).
>>>
>>>      add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
>>> "rows")) {
>>>        protected void populateItem(final ListItem<Row>  item) {
>>>          final Row row = item.getModelObject();
>>>
>>>          item.add(new Label("index", new AbstractReadOnlyModel<Integer>()
>>> {
>>>           public Integer getObject() { return item.getIndex() + 1; }
>>>          }));
>>>
>>>          item.add(new RequiredTextField<String>("key", new
>>> PropertyModel<String>(row, "key")));
>>>
>>>          item.add(new TextField<String>("value", new
>>> PropertyModel<String>(row, "value")));
>>>
>>>          item.add(removeLink("removeRowLink", item));
>>>          item.add(moveUpLink("moveUpLink", item));
>>>          item.add(moveDownLink("moveDownLink", item));
>>>        }
>>>      }.setReuseItems(true)));
>>>  }
>>> }
>>>
>>> /******************** HTML ********************************/
>>> <html>
>>> <head><title>ListView Test</title></head>
>>> <body>
>>>  <form wicket:id="rowsForm">
>>>  <button wicket:id="addRowButton">Add Row</button>
>>>  <table><tr wicket:id="rowsList">
>>>     <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>>>     <td>Key:<input type="text" wicket:id="key" /></td>
>>>     <td>Value:<input type="text" wicket:id="value" /></td>
>>>     <td>
>>>        <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>>>        <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>>>        <a href="#" wicket:id="removeRowLink">[X]</a>
>>>     </td>
>>>  </tr></table>
>>>  <input type="submit" value="Submit" />
>>> </form>
>>> </body>
>>> </html>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Using up/down/remove links of ListView items clears text fields

Posted by Sebastian <no...@gmx.net>.
Couldn't detect the listview if it is part of a form and decide for 
SubmitLink or Link?

On 14.08.2010 18:51, James Carman wrote:
> But then all listviews that need up/down links have to be in a form.
>
> On Aug 14, 2010 12:37 PM, "Sebastian"<no...@gmx.net>  wrote:
>> Hi Martin,
>>
>> thanks for pointing me to the reuse component concept. It solved my
>> problem partially but not completely. The problem is, that the links
>> provided by the listview result in HTTP GET request which means that any
>> values recently entered will not be transferred back and get lost. I am
>> now using my own link implementations based on the SubmitLink class. I
>> am attaching all files of my working example as reference.
>>
>> Generally I think it makes great sense to have this behaviour as part of
>> the ListView. At least I expected it to work this way in the first place.
>>
>> Regards,
>>
>> Seb
>>
>> On 14.08.2010 16:40, Martin Makundi wrote:
>>> Hi!
>>>
>>> You can solve this in a robust manner using reusemanager:
>>>
>>> http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html
>>>
>>> 2010/8/14 Sebastian<no...@gmx.net>:
>>>> Hi,
>>>>
>>>> I am trying to use a list view component on a page where rows with text
>>>> fields can be added, removed or moved around. I am using the removeLink,
>>>> moveUpLink and moveDownLink methods of the listview to create the
> respective
>>>> links for each list item.
>>>> The problem is that even when I enable the reuseListItems option, on
> using
>>>> any of these links the text fields "forget" the recently entered data
> (raw
>>>> input) and revert to the values of the backing model.
>>>>
>>>> This issue does not occur when I am adding rows the list view.
>>>>
>>>> Below is an example. I can add rows using the "Add Row" button. When I
> enter
>>>> text into the text fields, when I use the links next to a row, the
> content
>>>> of any text field is cleared.
>>>>
>>>> Any suggestions?
>>>>
>>>> Regards,
>>>>
>>>> Seb
>>>>
>>>> /******************** PAGE ********************************/
>>>> import java.util.*;
>>>> import org.apache.wicket.PageParameters;
>>>> import org.apache.wicket.markup.html.WebPage;
>>>> import org.apache.wicket.markup.html.basic.Label;
>>>> import org.apache.wicket.markup.html.form.*;
>>>> import org.apache.wicket.markup.html.list.*;
>>>> import org.apache.wicket.model.*;
>>>>
>>>> public class ListViewPage extends WebPage {
>>>> public static class Row {
>>>> public String key;
>>>> public String value;
>>>> }
>>>>
>>>> private final List<Row>  rows = new ArrayList<Row>();
>>>>
>>>> public ListViewPage(final PageParameters parameters) {
>>>>
>>>> add(new Form<List<Row>>("rowsForm").
>>>>
>>>> add(new Button("addRowButton") {
>>>> public void onSubmit() { rows.add(new Row()); }
>>>> }.setDefaultFormProcessing(false)).
>>>>
>>>> add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
>>>> "rows")) {
>>>> protected void populateItem(final ListItem<Row>  item) {
>>>> final Row row = item.getModelObject();
>>>>
>>>> item.add(new Label("index", new AbstractReadOnlyModel<Integer>() {
>>>> public Integer getObject() { return item.getIndex() + 1; }
>>>> }));
>>>>
>>>> item.add(new RequiredTextField<String>("key", new
>>>> PropertyModel<String>(row, "key")));
>>>>
>>>> item.add(new TextField<String>("value", new
>>>> PropertyModel<String>(row, "value")));
>>>>
>>>> item.add(removeLink("removeRowLink", item));
>>>> item.add(moveUpLink("moveUpLink", item));
>>>> item.add(moveDownLink("moveDownLink", item));
>>>> }
>>>> }.setReuseItems(true)));
>>>> }
>>>> }
>>>>
>>>> /******************** HTML ********************************/
>>>> <html>
>>>> <head><title>ListView Test</title></head>
>>>> <body>
>>>> <form wicket:id="rowsForm">
>>>> <button wicket:id="addRowButton">Add Row</button>
>>>> <table><tr wicket:id="rowsList">
>>>> <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>>>> <td>Key:<input type="text" wicket:id="key" /></td>
>>>> <td>Value:<input type="text" wicket:id="value" /></td>
>>>> <td>
>>>> <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>>>> <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>>>> <a href="#" wicket:id="removeRowLink">[X]</a>
>>>> </td>
>>>> </tr></table>
>>>> <input type="submit" value="Submit" />
>>>> </form>
>>>> </body>
>>>> </html>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Using up/down/remove links of ListView items clears text fields

Posted by James Carman <ja...@carmanconsulting.com>.
But then all listviews that need up/down links have to be in a form.

On Aug 14, 2010 12:37 PM, "Sebastian" <no...@gmx.net> wrote:
> Hi Martin,
>
> thanks for pointing me to the reuse component concept. It solved my
> problem partially but not completely. The problem is, that the links
> provided by the listview result in HTTP GET request which means that any
> values recently entered will not be transferred back and get lost. I am
> now using my own link implementations based on the SubmitLink class. I
> am attaching all files of my working example as reference.
>
> Generally I think it makes great sense to have this behaviour as part of
> the ListView. At least I expected it to work this way in the first place.
>
> Regards,
>
> Seb
>
> On 14.08.2010 16:40, Martin Makundi wrote:
>> Hi!
>>
>> You can solve this in a robust manner using reusemanager:
>>
>> http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html
>>
>> 2010/8/14 Sebastian<no...@gmx.net>:
>>> Hi,
>>>
>>> I am trying to use a list view component on a page where rows with text
>>> fields can be added, removed or moved around. I am using the removeLink,
>>> moveUpLink and moveDownLink methods of the listview to create the
respective
>>> links for each list item.
>>> The problem is that even when I enable the reuseListItems option, on
using
>>> any of these links the text fields "forget" the recently entered data
(raw
>>> input) and revert to the values of the backing model.
>>>
>>> This issue does not occur when I am adding rows the list view.
>>>
>>> Below is an example. I can add rows using the "Add Row" button. When I
enter
>>> text into the text fields, when I use the links next to a row, the
content
>>> of any text field is cleared.
>>>
>>> Any suggestions?
>>>
>>> Regards,
>>>
>>> Seb
>>>
>>> /******************** PAGE ********************************/
>>> import java.util.*;
>>> import org.apache.wicket.PageParameters;
>>> import org.apache.wicket.markup.html.WebPage;
>>> import org.apache.wicket.markup.html.basic.Label;
>>> import org.apache.wicket.markup.html.form.*;
>>> import org.apache.wicket.markup.html.list.*;
>>> import org.apache.wicket.model.*;
>>>
>>> public class ListViewPage extends WebPage {
>>> public static class Row {
>>> public String key;
>>> public String value;
>>> }
>>>
>>> private final List<Row> rows = new ArrayList<Row>();
>>>
>>> public ListViewPage(final PageParameters parameters) {
>>>
>>> add(new Form<List<Row>>("rowsForm").
>>>
>>> add(new Button("addRowButton") {
>>> public void onSubmit() { rows.add(new Row()); }
>>> }.setDefaultFormProcessing(false)).
>>>
>>> add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
>>> "rows")) {
>>> protected void populateItem(final ListItem<Row> item) {
>>> final Row row = item.getModelObject();
>>>
>>> item.add(new Label("index", new AbstractReadOnlyModel<Integer>() {
>>> public Integer getObject() { return item.getIndex() + 1; }
>>> }));
>>>
>>> item.add(new RequiredTextField<String>("key", new
>>> PropertyModel<String>(row, "key")));
>>>
>>> item.add(new TextField<String>("value", new
>>> PropertyModel<String>(row, "value")));
>>>
>>> item.add(removeLink("removeRowLink", item));
>>> item.add(moveUpLink("moveUpLink", item));
>>> item.add(moveDownLink("moveDownLink", item));
>>> }
>>> }.setReuseItems(true)));
>>> }
>>> }
>>>
>>> /******************** HTML ********************************/
>>> <html>
>>> <head><title>ListView Test</title></head>
>>> <body>
>>> <form wicket:id="rowsForm">
>>> <button wicket:id="addRowButton">Add Row</button>
>>> <table><tr wicket:id="rowsList">
>>> <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>>> <td>Key:<input type="text" wicket:id="key" /></td>
>>> <td>Value:<input type="text" wicket:id="value" /></td>
>>> <td>
>>> <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>>> <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>>> <a href="#" wicket:id="removeRowLink">[X]</a>
>>> </td>
>>> </tr></table>
>>> <input type="submit" value="Submit" />
>>> </form>
>>> </body>
>>> </html>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Using up/down/remove links of ListView items clears text fields

Posted by Sebastian <no...@gmx.net>.
Hi Martin,

thanks for pointing me to the reuse component concept. It solved my 
problem partially but not completely. The problem is, that the links 
provided by the listview result in HTTP GET request which means that any 
values recently entered will not be transferred back and get lost. I am 
now using my own link implementations based on the SubmitLink class. I 
am attaching all files of my working example as reference.

Generally I think it makes great sense to have this behaviour as part of 
the ListView. At least I expected it to work this way in the first place.

Regards,

Seb

On 14.08.2010 16:40, Martin Makundi wrote:
> Hi!
>
> You can solve this in a robust manner using reusemanager:
>
> http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html
>
> 2010/8/14 Sebastian<no...@gmx.net>:
>> Hi,
>>
>> I am trying to use a list view component on a page where rows with text
>> fields can be added, removed or moved around. I am using the removeLink,
>> moveUpLink and moveDownLink methods of the listview to create the respective
>> links for each list item.
>> The problem is that even when I enable the reuseListItems option, on using
>> any of these links the text fields "forget" the recently entered data (raw
>> input) and revert to the values of the backing model.
>>
>> This issue does not occur when I am adding rows the list view.
>>
>> Below is an example. I can add rows using the "Add Row" button. When I enter
>> text into the text fields, when I use the links next to a row, the content
>> of any text field is cleared.
>>
>> Any suggestions?
>>
>> Regards,
>>
>> Seb
>>
>> /******************** PAGE ********************************/
>> import java.util.*;
>> import org.apache.wicket.PageParameters;
>> import org.apache.wicket.markup.html.WebPage;
>> import org.apache.wicket.markup.html.basic.Label;
>> import org.apache.wicket.markup.html.form.*;
>> import org.apache.wicket.markup.html.list.*;
>> import org.apache.wicket.model.*;
>>
>> public class ListViewPage extends WebPage {
>>   public static class Row {
>>     public String key;
>>     public String value;
>>   }
>>
>>   private final List<Row>  rows = new ArrayList<Row>();
>>
>>   public ListViewPage(final PageParameters parameters) {
>>
>>     add(new Form<List<Row>>("rowsForm").
>>
>>       add(new Button("addRowButton") {
>>         public void onSubmit() { rows.add(new Row()); }
>>       }.setDefaultFormProcessing(false)).
>>
>>       add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
>> "rows")) {
>>         protected void populateItem(final ListItem<Row>  item) {
>>           final Row row = item.getModelObject();
>>
>>           item.add(new Label("index", new AbstractReadOnlyModel<Integer>() {
>>            public Integer getObject() { return item.getIndex() + 1; }
>>           }));
>>
>>           item.add(new RequiredTextField<String>("key", new
>> PropertyModel<String>(row, "key")));
>>
>>           item.add(new TextField<String>("value", new
>> PropertyModel<String>(row, "value")));
>>
>>           item.add(removeLink("removeRowLink", item));
>>           item.add(moveUpLink("moveUpLink", item));
>>           item.add(moveDownLink("moveDownLink", item));
>>         }
>>       }.setReuseItems(true)));
>>   }
>> }
>>
>> /******************** HTML ********************************/
>> <html>
>> <head><title>ListView Test</title></head>
>> <body>
>>   <form wicket:id="rowsForm">
>>   <button wicket:id="addRowButton">Add Row</button>
>>   <table><tr wicket:id="rowsList">
>>      <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>>      <td>Key:<input type="text" wicket:id="key" /></td>
>>      <td>Value:<input type="text" wicket:id="value" /></td>
>>      <td>
>>         <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>>         <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>>         <a href="#" wicket:id="removeRowLink">[X]</a>
>>      </td>
>>   </tr></table>
>>   <input type="submit" value="Submit" />
>> </form>
>> </body>
>> </html>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


Re: Using up/down/remove links of ListView items clears text fields

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

You can solve this in a robust manner using reusemanager:

http://osdir.com/ml/users-wicket.apache.org/2010-08/msg00161.html

2010/8/14 Sebastian <no...@gmx.net>:
> Hi,
>
> I am trying to use a list view component on a page where rows with text
> fields can be added, removed or moved around. I am using the removeLink,
> moveUpLink and moveDownLink methods of the listview to create the respective
> links for each list item.
> The problem is that even when I enable the reuseListItems option, on using
> any of these links the text fields "forget" the recently entered data (raw
> input) and revert to the values of the backing model.
>
> This issue does not occur when I am adding rows the list view.
>
> Below is an example. I can add rows using the "Add Row" button. When I enter
> text into the text fields, when I use the links next to a row, the content
> of any text field is cleared.
>
> Any suggestions?
>
> Regards,
>
> Seb
>
> /******************** PAGE ********************************/
> import java.util.*;
> import org.apache.wicket.PageParameters;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.markup.html.form.*;
> import org.apache.wicket.markup.html.list.*;
> import org.apache.wicket.model.*;
>
> public class ListViewPage extends WebPage {
>  public static class Row {
>    public String key;
>    public String value;
>  }
>
>  private final List<Row> rows = new ArrayList<Row>();
>
>  public ListViewPage(final PageParameters parameters) {
>
>    add(new Form<List<Row>>("rowsForm").
>
>      add(new Button("addRowButton") {
>        public void onSubmit() { rows.add(new Row()); }
>      }.setDefaultFormProcessing(false)).
>
>      add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
> "rows")) {
>        protected void populateItem(final ListItem<Row> item) {
>          final Row row = item.getModelObject();
>
>          item.add(new Label("index", new AbstractReadOnlyModel<Integer>() {
>           public Integer getObject() { return item.getIndex() + 1; }
>          }));
>
>          item.add(new RequiredTextField<String>("key", new
> PropertyModel<String>(row, "key")));
>
>          item.add(new TextField<String>("value", new
> PropertyModel<String>(row, "value")));
>
>          item.add(removeLink("removeRowLink", item));
>          item.add(moveUpLink("moveUpLink", item));
>          item.add(moveDownLink("moveDownLink", item));
>        }
>      }.setReuseItems(true)));
>  }
> }
>
> /******************** HTML ********************************/
> <html>
> <head><title>ListView Test</title></head>
> <body>
>  <form wicket:id="rowsForm">
>  <button wicket:id="addRowButton">Add Row</button>
>  <table><tr wicket:id="rowsList">
>     <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>     <td>Key: <input type="text" wicket:id="key" /></td>
>     <td>Value: <input type="text" wicket:id="value" /></td>
>     <td>
>        <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>        <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>        <a href="#" wicket:id="removeRowLink">[X]</a>
>     </td>
>  </tr></table>
>  <input type="submit" value="Submit" />
> </form>
> </body>
> </html>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Using up/down/remove links of ListView items clears text fields

Posted by Igor Vaynberg <ig...@gmail.com>.
those links remove all current items and repopulate the listview
becuse the index of items has to be recalculated. you can try using a
non-listview repeater and implementing the links yourself.

-igor

On Sat, Aug 14, 2010 at 7:05 AM, Sebastian <no...@gmx.net> wrote:
> Hi,
>
> I am trying to use a list view component on a page where rows with text
> fields can be added, removed or moved around. I am using the removeLink,
> moveUpLink and moveDownLink methods of the listview to create the respective
> links for each list item.
> The problem is that even when I enable the reuseListItems option, on using
> any of these links the text fields "forget" the recently entered data (raw
> input) and revert to the values of the backing model.
>
> This issue does not occur when I am adding rows the list view.
>
> Below is an example. I can add rows using the "Add Row" button. When I enter
> text into the text fields, when I use the links next to a row, the content
> of any text field is cleared.
>
> Any suggestions?
>
> Regards,
>
> Seb
>
> /******************** PAGE ********************************/
> import java.util.*;
> import org.apache.wicket.PageParameters;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.markup.html.form.*;
> import org.apache.wicket.markup.html.list.*;
> import org.apache.wicket.model.*;
>
> public class ListViewPage extends WebPage {
>  public static class Row {
>    public String key;
>    public String value;
>  }
>
>  private final List<Row> rows = new ArrayList<Row>();
>
>  public ListViewPage(final PageParameters parameters) {
>
>    add(new Form<List<Row>>("rowsForm").
>
>      add(new Button("addRowButton") {
>        public void onSubmit() { rows.add(new Row()); }
>      }.setDefaultFormProcessing(false)).
>
>      add(new ListView<Row>("rowsList", new PropertyModel<List<Row>>(this,
> "rows")) {
>        protected void populateItem(final ListItem<Row> item) {
>          final Row row = item.getModelObject();
>
>          item.add(new Label("index", new AbstractReadOnlyModel<Integer>() {
>           public Integer getObject() { return item.getIndex() + 1; }
>          }));
>
>          item.add(new RequiredTextField<String>("key", new
> PropertyModel<String>(row, "key")));
>
>          item.add(new TextField<String>("value", new
> PropertyModel<String>(row, "value")));
>
>          item.add(removeLink("removeRowLink", item));
>          item.add(moveUpLink("moveUpLink", item));
>          item.add(moveDownLink("moveDownLink", item));
>        }
>      }.setReuseItems(true)));
>  }
> }
>
> /******************** HTML ********************************/
> <html>
> <head><title>ListView Test</title></head>
> <body>
>  <form wicket:id="rowsForm">
>  <button wicket:id="addRowButton">Add Row</button>
>  <table><tr wicket:id="rowsList">
>     <td>&nbsp;&nbsp;&nbsp;#<span wicket:id="index">1</span></td>
>     <td>Key: <input type="text" wicket:id="key" /></td>
>     <td>Value: <input type="text" wicket:id="value" /></td>
>     <td>
>        <a href="#" wicket:id="moveUpLink">[&uarr;]</a>
>        <a href="#" wicket:id="moveDownLink">[&darr;]</a>
>        <a href="#" wicket:id="removeRowLink">[X]</a>
>     </td>
>  </tr></table>
>  <input type="submit" value="Submit" />
> </form>
> </body>
> </html>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org