Saturday, 26 September 2009

Lifecycle problem with WSPBuilder and EditorPart

I had a problem with the ApplyChanges method in an EditorPart class that was used in a WSPBuilder WebPart class (the default web part that WSPBuilder creates). The CreateChildControls in the WebPart class was triggered before the ApplyChanges method in the EditorPart class. Therefore the web part content was not updated and the page had to be reloaded to show any update to the web part.

In the WebPart class that is created from WSPBuilder the CreateChildControls is triggered from the OnInit method. This has the consequence that the ApplyChanges method in the EditorPart class will be triggered after the CreateChildControls in the WebPart class. My solution was to remove the method call in OnInit and then the ApplyChanges method was firing correctly.

No comments: