Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not overwrite the updateModel method of a FormComponent #91

Closed
wants to merge 1 commit into from

Conversation

coder-hugo
Copy link

  • if you use wicket the right way there is no need the overwrite the updateModel method for a custom form component
  • this strange code inside the updateModel method caused an error in combination with the wicket-bootstrap library
    -> the FormGroup component implements the interface IFormModelUpdateListener (which is also wrong) and cause that the updateModel method of each FormComponent gets called twice
    -> calling this updateModel method twice within one request cycle results in an empty collection for the model object

- if you use wicket the right way there is no need the overwrite the updateModel method for a custom form component
- this strange code inside the updateModel method caused an error in combination with the wicket-bootstrap library
  -> the FormGroup component implements the interface IFormModelUpdateListener (which is also wrong) and cause that the updateModel method of each FormComponent gets called twice
  -> calling this updateModel method twice within one request cycle results in an empty collection for the model object
@ivaynberg ivaynberg closed this in b8c9a68 Jul 16, 2014
@ivaynberg
Copy link
Owner

if you use wicket the right way there is no need the overwrite the updateModel method for a custom form component

this is incorrect. form components that work with collections typically override updateModel to handle the collection appropriately. if this method is removed entirely a brand new collection will always gets pushed to the component, with this method in place an existing collection if present will be modified - which is most often the desired behavior.

this strange code inside the updateModel method caused an error in combination with the wicket-bootstrap library

perhaps the bug is in the bootstrap module.

however, i did notice that the existing code does not notify the component that its model is changing, which may also cause a problem.

this is now fixed.

@coder-hugo
Copy link
Author

Thanks,

till now I always thought that it's the expected behavior that also for collections you get a new instance for the model object after a form submit. But this is indeed the better solution ;-)
And with this code:

    @Override
    public void updateModel() {
        FormComponent.updateCollectionModel(this);
    }

it works also in combination with the other bug that calls the updateModel method twice for each form compoent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants