Print Page | Close Window

Adding to Root menu

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=740
Printed Date: 28-Mar-2024 at 5:32am


Topic: Adding to Root menu
Posted By: orcities
Subject: Adding to Root menu
Date Posted: 21-Mar-2008 at 12:53pm
I have added a button to the root menu. I added a button called Edit and under that Options.
 
In the FoundationModule I have a CommandHandler for that button that needs to open up an editor.
I have the call to the editor to display an EntityEditorController that I have created.
 
I get an error here: (From the inherited reference to PageController) 

protected void CreateDefaultEntityManager() {

Guard.ArgumentNotNullOrEmptyString(Id, "Id"); // Id is null for some reason

 

Any ideas would be great?




Replies:
Posted By: Bill Jensen
Date Posted: 26-Mar-2008 at 11:06am
It looks like your EntityEditorController has not been passed the workitem that it controls or its workitem does not have an Id assigned.
 
How are you creating your editor?  Are you using the EntityEditorService?
 
The EntityEditorService contains (amongst a lot of other code) this method:

/// <summary>

/// Make a new Editor instance (to edit existing or new entity)

/// given the type of an Editor to make

/// that is not mapped to another type.

/// </summary>

private IEntityEditorController MakeUnmappedEditor<TEditor>()

where TEditor : IEntityEditorController {

ControlledWorkItem<TEditor> editorWorkItem =

WorkItem.WorkItems.AddNew<ControlledWorkItem<TEditor>>();

IEntityEditorController editor = editorWorkItem.Controller;

EditorKeys.Add(new EditorKey(editor));

return editor;

}

If you're not using the EntityEditorService, your command handler will need to do something similar.
 
(The line adding the new EditorKey is of course only needed in the service implementation).
 
Bill J.


Posted By: orcities
Date Posted: 26-Mar-2008 at 11:16am

From what I can tell that method is never used. So, I should create my instance of AddNew<> that calls the new method.



Posted By: Bill Jensen
Date Posted: 26-Mar-2008 at 11:31am

For your editor to work, it must be created as the controller of a ControlledWorkItem.  You accomplish that with:

WorkItem.WorkItems.AddNew<ControlledWorkItem<TEditor>>();

IEntityEditorController editor = editorWorkItem.Controller;

If you want to encapsulate that inside of an AddNew<TEditor>() method, that's OK.
 
Bill J.



Print Page | Close Window