You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by always_rick <sh...@hotmail.com> on 2013/06/26 08:33:53 UTC

ListView remove a row by SubmitLink always move the last one

Hi all,

I have a form of inputs (ListView). 

I firstly tried the removeLink, it was working. Because it is a normal link,
it simply don't keep the other rows inputs. Obviously, it does not meet the
requirement. I thought SubmitLink was good, but it always removed the last
row. I clearly see the index is correct, but result is incorrect.

I searched this forum and google, and found the a few answers, none of them
worked in my case.

Could some one please help?


p.s.  I set setReuseItems(true) 'coz wicket api said, "If you nest a
ListView in a Form, always set this property to true, as otherwise
validation will not work properly.", which is correct.






--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-move-the-last-one-tp4659796.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ListView remove a row by SubmitLink always move the last one

Posted by always_rick <sh...@hotmail.com>.
ListPage.html
<http://apache-wicket.1842946.n4.nabble.com/file/n4659905/ListPage.html>  
ListPage.java
<http://apache-wicket.1842946.n4.nabble.com/file/n4659905/ListPage.java>  
User.java
<http://apache-wicket.1842946.n4.nabble.com/file/n4659905/User.java>  

Hi Sven, it is odd. When I was building the quickstart, SubmitLink acts like
removeLink. It was directly copied for the code. I am going to review my
code on weekend. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-delete-the-last-one-tp4659796p4659905.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ListView remove a row by SubmitLink always move the last one

Posted by always_rick <sh...@hotmail.com>.
Hi Sven, I review my code and api. I misunderstood the
setDefaultFormProcessing( false ). Simply removing that method, then it
works.  Now I am thinking of a way to skip validation, and process form
updating.




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-delete-the-last-one-tp4659796p4659919.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ListView remove a row by SubmitLink always move the last one

Posted by Sven Meier <sv...@meiers.net>.
Sorry, I'm out of ideas. If you can create a quickstart, I'll debug the 
problem.

Sven

On 06/28/2013 12:43 PM, always_rick wrote:
> Thank you for quick response.
>
> I tried what you suggested, no luck.
>
> What I think is clicking "remove" link (SubmitLink), form memorizes input
> data, then remove row.
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-delete-the-last-one-tp4659796p4659899.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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: ListView remove a row by SubmitLink always move the last one

Posted by always_rick <sh...@hotmail.com>.
Thank you for quick response.

I tried what you suggested, no luck.

What I think is clicking "remove" link (SubmitLink), form memorizes input
data, then remove row.





--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-delete-the-last-one-tp4659796p4659899.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ListView remove a row by SubmitLink always move the last one

Posted by Sven Meier <sv...@meiers.net>.
First of all don't pull something out of a model and put it into another 
model:

    item.setDefaultModel(new CompoundPropertyModel( 
item.getModelObject() ) );

Do this instead:

    item.setDefaultModel(new CompoundPropertyModel( item.getModel() ) );

Perhaps this is the reason: the textfields are showing stale data.

Sven


On 06/28/2013 11:20 AM, always_rick wrote:
> Sven, I forgot.
>
> code:
> -----
> ListView listView = new ListView( "users", users ) {
>
> 			@Override
> 			protected void populateItem( final ListItem item ) {
> 				item.setDefaultModel(
> 						new CompoundPropertyModel( item.getModelObject() ) );
> 				item.add( new TextField<String>( "firstName" ) );
> 				item.add( new TextField<String>( "lastName" ) );
>
> 				item.add( //removeLink( "remove", item ) );
> 					      new SubmitLink( "remove", item.getModel() ) {
> 							private static final long serialVersionUID = 1L;
>
> 					@Override
> 					public void onSubmit() {
> 						// copy from ListView > removeLink
> 						addStateChange();
> 						item.modelChanging();
> 						getList().remove( item.getIndex() );
> 						modelChanged();
> 						removeAll();
> 					}
> 				}.setDefaultFormProcessing( false ) );
> 			}
> }
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-delete-the-last-one-tp4659796p4659895.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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: ListView remove a row by SubmitLink always move the last one

Posted by always_rick <sh...@hotmail.com>.
Sven, I forgot.  

code:
-----
ListView listView = new ListView( "users", users ) {

			@Override
			protected void populateItem( final ListItem item ) {
				item.setDefaultModel( 
						new CompoundPropertyModel( item.getModelObject() ) );
				item.add( new TextField<String>( "firstName" ) );
				item.add( new TextField<String>( "lastName" ) );

				item.add( //removeLink( "remove", item ) );
					      new SubmitLink( "remove", item.getModel() ) {
							private static final long serialVersionUID = 1L;

					@Override
					public void onSubmit() {
						// copy from ListView > removeLink
						addStateChange();
						item.modelChanging();
						getList().remove( item.getIndex() );
						modelChanged();
						removeAll();
					}
				}.setDefaultFormProcessing( false ) );
			}
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-delete-the-last-one-tp4659796p4659895.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ListView remove a row by SubmitLink always move the last one

Posted by Sven Meier <sv...@meiers.net>.
You'll have to show us some code.

Sven

On 06/26/2013 08:33 AM, always_rick wrote:
> Hi all,
>
> I have a form of inputs (ListView).
>
> I firstly tried the removeLink, it was working. Because it is a normal link,
> it simply don't keep the other rows inputs. Obviously, it does not meet the
> requirement. I thought SubmitLink was good, but it always removed the last
> row. I clearly see the index is correct, but result is incorrect.
>
> I searched this forum and google, and found the a few answers, none of them
> worked in my case.
>
> Could some one please help?
>
>
> p.s.  I set setReuseItems(true) 'coz wicket api said, "If you nest a
> ListView in a Form, always set this property to true, as otherwise
> validation will not work properly.", which is correct.
>
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListView-remove-a-row-by-SubmitLink-always-move-the-last-one-tp4659796.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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