[ 
https://issues.apache.org/jira/browse/WICKET-6045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028697#comment-15028697
 ] 

Tero Tarkkala commented on WICKET-6045:
---------------------------------------

Yes, forgot to mention we have set a viewsize. And since that is set after 
construction, the null list works when constructing. Yes, I could check if my 
list is null and replace it with an empty list (this is actually what I do now) 
or set the viewsize to zero, but is there a reason for this strange if-clause 
in the getViewSize()? If it would return zero when the modelObject is null, 
this would work without the extra checks for null lists. Also, having a null 
list and then setting a viewsize wouldn't accomplish anything useful.

> ListView gets wrong viewsize when changing from arbitrary list with size > 0 
> to null list
> -----------------------------------------------------------------------------------------
>
>                 Key: WICKET-6045
>                 URL: https://issues.apache.org/jira/browse/WICKET-6045
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 7.1.0
>            Reporter: Tero Tarkkala
>            Assignee: Sven Meier
>            Priority: Minor
>
> ListView tries to render the null list because of the beginning of method 
> ListView.getViewSize():
> public int getViewSize()
>       {
>               int size = viewSize;
>               final Object modelObject = getDefaultModelObject();
>               if (modelObject == null)
>               {
>                       return size == Integer.MAX_VALUE ? 0 : size;
>               }
> ....
> Let say I had 10 items in the list before a refresh to this listview. When 
> refreshing, my getter returned null because it didn't find anything 
> -> modelObject is null and size != Integer.MAX_VALUE 
> -> previous viewSize is returned. 
> -> populateItem throws npe if it tries for example getDefaultModelObject() 
> like this:
> java.lang.NullPointerException
>      at 
> org.apache.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:61)
>      at org.apache.wicket.Component.getDefaultModelObject(Component.java:1626)
>      at 
> syncrontech.common.gate.list.GateEditableListPanel$2.populateItem(GateEditableListPanel.java:264)
>      at 
> org.apache.wicket.markup.html.list.ListView.onPopulate(ListView.java:523)
> The behaviour is also inconsistent: Constructing the listview with null list 
> is ok, because that same point in code would return the 0.
> This should probably always return 0 if the modelObject is null? Or am I 
> missing something?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to