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

Petr Lancaric edited comment on WICKET-5518 at 2/26/14 10:03 AM:
-----------------------------------------------------------------

Thank you, there is a bug:
        if (modified && logger.isDebugEnabled())

should be 

        if (modified)
                if(logger.isDebugEnabled())
....
otherwise switch off debuging will cause exception.

Another think is, that my "TODO" was not processed, code will work only if 
setter accept List (or ArrayList or parents), but there are other collection 
will fail (Set e.g.). It is not an easy task to find right instance, but I 
recommend to put there at least comment, that code is unfinished. For my 
situation (ListMultipleChoice) it would work fine.













was (Author: [email protected]):
Thank you, there is a bug:
        if (modified && logger.isDebugEnabled())

should be 

        if (modified)
                if(ogger.isDebugEnabled())
....
otherwise switch off debuging will cause exception.

Another think is, that my "TODO" was not processed, code will work only if 
setter accept List (or ArrayList or parents), but there are other collection 
will fail (Set e.g.). It is not an easy task to find right instance, but I 
recommend to put there at least comment, that code is unfinished. For my 
situation (ListMultipleChoice) it would work fine.












> FormComponent.updateCollectionModel  does not handle unmodifiableList
> ---------------------------------------------------------------------
>
>                 Key: WICKET-5518
>                 URL: https://issues.apache.org/jira/browse/WICKET-5518
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 6.12.0
>            Reporter: Petr Lancaric
>            Assignee: Sven Meier
>            Priority: Minor
>             Fix For: 7.0.0
>
>
> FormComponent.updateCollectionModel should handle situation, when getter 
> returns unmodifiable list.
> Proposed solution:
>                       formComponent.modelChanging();
>                       booelan isChanged;
>                       try {
>                               collection.clear();
>                               if (convertedInput != null)
>                               {
>                                       collection.addAll(convertedInput);
>                               }
>                               isChanged = true;
>                       catch (Exception e)
>                       {
>                               // ignore this exception as Unmodifiable list 
> does not allow change                             
>                               logger.info("An error occurred while trying to 
> modify list attached to " + formComponent, e);
>                       }
>                       try
>                       {
>                               if(isChanged)                           
>                                       
> formComponent.getModel().setObject(collection);
>                               else 
>                                       // TODO: create here collection as 
> non-abstract successor of setObject declared argument
>                                       formComponent.getModel().setObject(new 
> ArrayList(convertedInput));
>                               isChanged = true;
>                       }
>                       catch (Exception e)
>                       {
>                               // ignore this exception because it could be 
> that there
>                               // is not setter for this collection.
>                               logger.info("An error occurred while trying to 
> set the new value for the property attached to " + formComponent, e);
>                       }
>                       // at least one update method should pass successfully  
>                 
>                       if(isChanged)
>                               formComponent.modelChanged();
>                       else
>                               throw new RuntimeException("An error occurred 
> while trying to modify value for the property attached to " + formComponent); 
>        



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to