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

Hudson commented on WICKET-3413:
--------------------------------

Integrated in Apache Wicket 1.4.x #436 (See 
[https://hudson.apache.org/hudson/job/Apache%20Wicket%201.4.x/436/])
    WICKET-3413 FLAG_INHERITABLE_MODEL and default model change

reset 'inherited model' flag if model changed and a new one is not 
IComponentInheritedModel


> FLAG_INHERITABLE_MODEL and default model change
> -----------------------------------------------
>
>                 Key: WICKET-3413
>                 URL: https://issues.apache.org/jira/browse/WICKET-3413
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.15
>         Environment: Ubuntu 10.10/md64 JDK 1.6u23 x64
>            Reporter: Alexander Morozov
>            Assignee: Martin Grigorov
>             Fix For: 1.4.16, 1.5-RC2
>
>         Attachments: fix-WICKET-3413.patch, test-WICKET-3413.patch
>
>
> The issue is about correctness of Component#setDefaultModel 
> (Component#setModelImpl) method behavior. I expect that the flag 
> FLAG_INHERITABLE_MODEL should be checked there and turned off in case if new 
> model is not a IComponentInheritedModel. 
> Let check the next code:
> public MyPanel(String id) {
>  super(id);
>   ...
>   form.setModel(new CompoundPropertyModel(this));
>   DropDownChoice ddc = new DropDownChoice("variant", Arrays.ofList(...)) {    
> // p1
>     @Override
>     protected void onInitialize() {
>        super.onInitialize();
>        setModel(new DefaultingWrapModel(getModel(), Model.of("default 
> value"));            // p2
>     }
>   };
>   ddc.setNullValid(false);
>   ddc.setRequired(true);
>   form.add(ddc);
>   ...
> }
> In the (p1) the DDC will initialize with CompoundPropertyModel and the 
> FLAG_INHERITABLE_MODEL will be turned on soon by the first invocation of 
> FormComponent#getModel().
>  In the (p2) we wrap the DDC model with the model which provide the default 
> value (DefaultingWrapModel implements IWrapModel). So we change the model, 
> but the FLAG_INHERITABLE_MODEL is still turned on. On the Component#detach() 
> event, the method Component#setModelImpl(null) will be invoked for the ddc 
> and the DefaultingWrapModel instance will be lost:
>               // reset the model to null when the current model is a 
> IWrapModel and
>               // the model that created it/wrapped in it is a 
> IComponentInheritedModel
>               // The model will be created next time.
>               if (getFlag(FLAG_INHERITABLE_MODEL))
>               {
>                       setModelImpl(null);
>                       setFlag(FLAG_INHERITABLE_MODEL, false);
>               }
> I think that such behavior is unexpected.
> http://apache-wicket.1842946.n4.nabble.com/1-4-15-FLAG-INHERITABLE-MODEL-and-default-model-change-td3252093.html

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to