New Posts New Posts RSS Feed: [SOLVED] Implementing Command Handlers
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[SOLVED] Implementing Command Handlers

 Post Reply Post Reply
Author
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] Implementing Command Handlers
    Posted: 28-Sep-2007 at 2:44pm
I followed the MasterDetailTabViewController paradigm for adding command handlers in a specific context.  My code is relatively simple since I removed the master/detail complexity from the methods that I employed.  It is working...kind of...
 
I have a couple of issues:
 
1)  The save button does not display even though I registered a SaveCommandHandler.  This may have to do with the naming of the command name in the ToolStripAdapter.  The save button was not part of the example.  Is there something different that needs to happen for the save button?
 
2)  The add button, when clicked does nothing.  No entity seems to be created or displayed.  How do I get the bindingsource to update with the newly created entity?
 
3)  I suspect the saveall command will save all dirty entities in the manager...for all classes (customer and contact are probably in the same manager).  Is it possible to establish a save within the toolbar for the contacts class (even an individual contact) only?  (this may be a more DevForce issue than CAB)
 
Thanks!
Bill


Edited by Linguinut - 29-Sep-2007 at 8:04am
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 28-Sep-2007 at 4:05pm
I was able to get the save button to work.  I had the wrong wiring back in the ToolStripAdapter.  The save does save both the parent and the child entities (and any changes therein).  Not a big deal...that's quite workable.
 
I am still having trouble with the add new command.  Not quite sure how to handle this animal.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2007 at 8:03am
OK...here is what I did...
 
Within my new ControlViewTabViewController (in IdeaBlade.Cab.UI), I have
 
private void AddNewCommandHandler<T>(object sender, EventArgs e) where T : class { AddNewItem(); }
 
and
 
protected abstract void AddNewItem() ;
 
From the controller in my application, I simply override AddNewItem, like this:
 
protected override void AddNewItem()
{
    //Create a new Contact with default property values
    ContactMaster aContact = ContactMaster.Create(PersistenceManager.DefaultManager, 1, mCustIndex, 0, "[Last Name]", "[First Name]");
    //Add the new contact to the list that's feeding the form.
    mBindingSource.Add(aContact);
    mBindingSource.MoveLast();
}
 
I would imagine that there is a better way to reference the PersistenceManager, but for now, this works perfectly.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2007 at 8:32am
Sure, the item shows up in the control view, but when I click save, the popup says, "There is nothing to save."  So, I try the save button on the parent toolbar...same thing.
 
We are definitely NOT is Kansas, anymore!
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2007 at 9:04am
Solution:  override the command handler's save method...similar to the AddNewItem code.  From the controller in my app, I simply called this:
 
EntityManager.SaveAll();
 
Cha-ching!  Good as gold!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down