Re: validation in form component panels in RefreshingView

2015-01-22 Thread lucast
Thank you, Martin,

I have used ReuseIfModelsEqualStrategy and the validation message side of it
work but now I have a different problem.

When I navigate away from the form panel, update the list of objects and
navigate back to the FormComponentPanel that holds the RefreshingView, only
one item from the list gets displayed.

I use a ListModel to pass the list of objects to the FormComponentPanel.

When used for the first time, the RefreshingView calls getItemModels() and
populateItem(), but after updating the ListModel, RefreshingView only calls
getItemModels() and *not* populateItem(). 

Would you happen to know why that is?

If I use DefaultItemReuseStrategy.getInstance() then  getItemModels() and
populateItem() get called every time. But that just takes me back to square
1.

I'm not sure if this is relevant. ReuseIfModelsEqualStrategy documentation
states that  the model and not the model object needs to implement the
Object.equals(Object) and Object.hashCode() methods.

I'm terribly sorry but I'm not sure completely understand that statement.
Would that be something to do with the RefreshingView not displaying all
items in the list model.

On trying to interpret that statement, on RefreshingView.getItemModels(), I
return an anonymous class that extends ModelIteratorAdapter. And on
ModelIteratorAdapter.model, I return an custom Model with extends ModelMy
Application Object. It is there that I implement hashcode and equals. But
the problem still persists.

I hope I'm not making things more confusing by writing extensively, but I
just wanted to put it out there, in case there was something simple and
small that I am missing.

Thanks in advance,
Lucas




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/validation-in-form-component-panels-in-RefreshingView-tp4669068p4669081.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: validation in form component panels in RefreshingView

2015-01-22 Thread Martin Grigorov
Hi,

On Thu, Jan 22, 2015 at 3:16 PM, lucast lucastol...@hotmail.com wrote:

 Thank you, Martin,

 I have used ReuseIfModelsEqualStrategy and the validation message side of
 it
 work but now I have a different problem.

 When I navigate away from the form panel, update the list of objects and
 navigate back to the FormComponentPanel that holds the RefreshingView, only
 one item from the list gets displayed.

 I use a ListModel to pass the list of objects to the FormComponentPanel.

 When used for the first time, the RefreshingView calls getItemModels() and
 populateItem(), but after updating the ListModel, RefreshingView only calls
 getItemModels() and *not* populateItem().

 Would you happen to know why that is?

 If I use DefaultItemReuseStrategy.getInstance() then  getItemModels() and
 populateItem() get called every time. But that just takes me back to square
 1.

 I'm not sure if this is relevant. ReuseIfModelsEqualStrategy documentation
 states that  the model and not the model object needs to implement the
 Object.equals(Object) and Object.hashCode() methods.

 I'm terribly sorry but I'm not sure completely understand that statement.
 Would that be something to do with the RefreshingView not displaying all
 items in the list model.


This says that your model object has to have proper impls of #equals() and
#hashCode() methods. Just like when you put instances of this class in
HashMap.

I guess this will solve your problem.



 On trying to interpret that statement, on RefreshingView.getItemModels(), I
 return an anonymous class that extends ModelIteratorAdapter. And on
 ModelIteratorAdapter.model, I return an custom Model with extends ModelMy
 Application Object. It is there that I implement hashcode and equals. But
 the problem still persists.

 I hope I'm not making things more confusing by writing extensively, but I
 just wanted to put it out there, in case there was something simple and
 small that I am missing.

 Thanks in advance,
 Lucas




 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/validation-in-form-component-panels-in-RefreshingView-tp4669068p4669081.html
 Sent from the Users forum mailing list archive at Nabble.com.

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




Re: validation in form component panels in RefreshingView

2015-01-22 Thread lucast
Hi Martin,
Thank you for taking the time to reply.

I have implemented hashcode and equals on the object, and the Model class
used inside the RefreshingView and the ListModel class that is passed to the
RefreshingView.


In order to be able to display the right number of entries, I clear the list
inside the ListModel and populate it again with  N numbers of initialized
objects. The variables in those objects are all null. 


This works on the first run but not on the second.

In stepping through the code with debugger, hashcode and equal are called
only for the the actual object and the model object, not for the ListModel.

Since all objects are empty (no variables have been populated) the models
and the actual objects all return the same hash code.

But this surely is of no relevance since I am using a List, not a set. 

I've been looking at this for a while, and perhaps I have lost the sense of
perspective, but I cannot see what I am doing wrong.

Kind regards,
Lucas


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/validation-in-form-component-panels-in-RefreshingView-tp4669068p4669088.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: validation in form component panels in RefreshingView

2015-01-22 Thread lucast
Hi Martin,

I'm sorry to bother you with a second post. 

I have reproduced the behaviour described above in a simple project ( 
refreshingview.zip
http://apache-wicket.1842946.n4.nabble.com/file/n4669090/refreshingview.zip 
). Also, I put the mercurial project on bitbucket( hg clone
https://luc...@bitbucket.org/lucast/refreshingview).


The behaviour is as follow. 

Step 1, choose a number (3, for example) from the drop down list. A list of
3 entries of text fields will be displayed.

Step 2, choose a different number (2, for example) from the drop down list.
Only one entry of text field will be displayed. Even though the list model
has 2 entries, not one.

When an entry from the drop down list, located in HomePage is selected,
PersonListFormComponentPanel is updated.

On running the debugger, I noticed that inside
ReuseIfModelsEqualStrategy.getItems(), (line 86), on the bit that compares 
if (oldItem == null), on the first run, oldItem *is* null.
On the second run, *oldItem* *is not*.

That is why PersonRefreshingView.populateItem() is not called the second
time a number is selected from the drop down list.

How can I set *oldItem* to null so that it follows the very same behaviour
as when executed the first time?

If you happen to look inside
PersonListFormComponentPanel.PersonRefreshingView, you will notice that I
have implemented PersonModel, with equals and hashcode functions.


Anyway, this is something I honestly cannot get my head around. I have tried
for days now and I find it most puzzling.

Any tips, or hints in the right direction will be much appreciated.

Thanks, once more,
Lucas

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/validation-in-form-component-panels-in-RefreshingView-tp4669068p4669090.html
Sent from the Users forum mailing list archive at Nabble.com.

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



validation in form component panels in RefreshingView

2015-01-21 Thread lucast
Dear forum,

I'm implementing a tabbed panel. 
On first panel, user selects number of items. On second tab, user enters
details for each item.

I've implemented a RefreshingView so that the number of items on list
reflects the number of items selected by user.

To bundle all of the fields together I use a form component panel and for
each entry on the RefreshingView, I add a form component panel.

The text fields have FieldDecorators, as explained on the Apache Wicket
Cookbook, chapter 3.

The problem is that when I submit the form, the error messages for each
field are not shown on the text field FieldDecorators.

If I use RepeatingView, error messages are displayed as intended. But my
list is dynamic.

How can I get the proper validation message displayed inside the form
component panel, used in a RefreshingView?

Thanks in advance,
Lucas


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/validation-in-form-component-panels-in-RefreshingView-tp4669068.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: validation in form component panels in RefreshingView

2015-01-21 Thread Martin Grigorov
org.apache.wicket.markup.repeater.RefreshingView#setItemReuseStrategy(org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy#getInstance())

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Jan 21, 2015 at 6:59 PM, lucast lucastol...@hotmail.com wrote:

 Dear forum,

 I'm implementing a tabbed panel.
 On first panel, user selects number of items. On second tab, user enters
 details for each item.

 I've implemented a RefreshingView so that the number of items on list
 reflects the number of items selected by user.

 To bundle all of the fields together I use a form component panel and for
 each entry on the RefreshingView, I add a form component panel.

 The text fields have FieldDecorators, as explained on the Apache Wicket
 Cookbook, chapter 3.

 The problem is that when I submit the form, the error messages for each
 field are not shown on the text field FieldDecorators.

 If I use RepeatingView, error messages are displayed as intended. But my
 list is dynamic.

 How can I get the proper validation message displayed inside the form
 component panel, used in a RefreshingView?

 Thanks in advance,
 Lucas


 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/validation-in-form-component-panels-in-RefreshingView-tp4669068.html
 Sent from the Users forum mailing list archive at Nabble.com.

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