When does presenter get added to workitem

Topics: CAB & Smart Client Software Factory
Mar 4, 2006 at 9:44 AM
originally posted by: MarcoPaul

I'm reading this in the smart client toolkit documentation:

"When a view object is added to a WorkItem, its presenter is also added to that WorkItem. When the view is disposed, the view should also dispose of its presenter. If it does not, the presenter will remain inaccessible in the container and will not be garbage collected. "

I don't understand who or when the presenter actually gets added to the workitem. I see in the code where the view gets added (before showing the dialog), but I don't see where the presenter does.

Someone pls sheed some light?

Thanks
Mar 4, 2006 at 9:54 AM
originally posted by: matiaswoloski

Hi,

ObjectBuilder does the magic via the CreateNew attribute.

CreateNew
public AvailableAppraisalsViewPresenter Presenter
{
set
{
_presenter = value;
_presenter.View = this;
_presenter.ShowAvailableAppraisals();
}
}

When the View is added to the WorkItem, ObjectBuilder will look into the View for properties with CreateNew attributes and will create a new object of the property type and assign it to the private field.

Matias
http://staff.southworks.net/blogs/matiaswoloski
Mar 4, 2006 at 11:33 AM
originally posted by: MarcoPaul

Ok, to make sure I understand this correctly, when the ObjectBuilder finds the CreateNew attribute in the view, it will create an instance of the type, assign it to the private variable, and also add it (presenter in this case) to the workitem.
Mar 8, 2006 at 3:30 PM
originally posted by: DeivaShankar

Yes. The ObjectBuilder creates the instance of the type. It then calls the set method of the property, which in turn will assign the instance to the private vairable.