Accessing using WorkItem from a SmartPart

Topics: CAB & Smart Client Software Factory
Oct 3, 2005 at 2:56 PM
originally posted by: pfilipchyk

Is there a simple way to get a handle on the WorkItem that uses a SmartPart, so that that SmartPart can properly create other SmartParts contained within it?:

containedSmartPart = usingWorkItem.Create<ContainedSmartPart1>();

instead of

containedSmartPart = new ContainedSmartPart1();

which works fine if that complex SmartPart is created only once by the using WorkItem, but throws an exception on all cnsequent attempts with approximately the following message:

"Component named "ContainedSmartPart1" already exists in the container."

Oct 4, 2005 at 4:06 AM
originally posted by: DLorenz

Why would you run the same smart part in the same workitem more than once? Ideally, you would run multiple workitems from the workitem above on a deck workspace in order to get the same workitem more than once.
Oct 4, 2005 at 5:01 AM
originally posted by: pfilip

Let's say I have a business entity/business object (customer).

I create a single CAB controller for that business object.

I design a number of, at first, simple views/smart-parts that provide views of parts of data contained
within that business object (contact info, demographics, occupation, etc.).

Then, I decide I need a complex/composite view that would contain several of the simple views (summary view), and so I create another smart-part/view by dragging and dropping simple views onto the composite view/smart-part.

Then, in some WorkItem, I'd like to display a couple of simple views/smart-parts in one place and a composite view/smart-part in other place (imagine a wizard scenario where I collect information in discrete steps using simple views, and display all collected information at the end in a composite view).

Now, the problem is that I don't want to construct the composite view/smart-part every time at run-time in the WorkItem, but rather use a pre-constructed view/smart-part that was constructed at design-time using a bunch of simpler smart-parts/views (all have their own controller injection since each one may be used as a standalone view/smart-part).
Oct 4, 2005 at 5:10 AM
originally posted by: DLorenz

I think the only way you are going to achieve someting like this is to have multiple WorkItem Levels. Then for each level, you will make a SmartPart that just contains different Workspaces (Like a Deck or a Zone). Then you should be able to have your composite control at the parent WorkItem and the simpler ones in the child workitem(s).
Oct 4, 2005 at 5:14 AM
originally posted by: DLorenz

Another option would be to make another "simple" smartpart that simply contains the fields you want to display for your summary at the end. That way, you wouldn't have the same SmartPart twice.
Oct 5, 2005 at 1:10 PM
originally posted by: pfilip

Yes, both are some of the possible solutions.

However, the first one --- having miniature WorkItems --- raises a question of what a WorkItem really is. In my understanding, a WorkItem represents a complete, meaningful use-case or unit of work/interaction with the system. So, having such functionally useless WorkItems breaks the semantics of the whole framework and makes it difficult to convey to others.

The second one --- making another 'simple' smart-part/view from scratch --- defeats the whole concept of smart-parts reuse: it's error prone, it's not flexible in case the underlying business entity changes (cannot just change simple smart-parts and have those changes propagated to composite ones).

I have some dependancy-injection-like solution to the issue, but hope that new CAB releases will allow for easier implementation of such scenarios.