Hello I Used CSLDataProvider Command Manager with button to Add object but it is disabled?

Hello I Used CSLDataProvider Command Manager with button to Add object but it is disabled?

Old forum URL: forums.lhotka.net/forums/t/6429.aspx


Programmer1987 posted on Monday, February 16, 2009

hello this is my first post  and this is my first project using CSLA

I used cslaDataprovider to insert new object ot the list that bound to listbox

the button that Add

<Button  Name="BtnAddItemType" Command="ApplicationCommands.New"

CommandParameter="{Binding}"

CommandTarget="{Binding Source={StaticResource ItemTypesProvider},Path=ComandManager,BindsDirectlyToSource=True}"

>+</Button>

But it is disabled Why and how can i make it enabled

the csla data probider is :

<csla:CslaDataProvider x:Key="ItemTypesProvider"

ManageObjectLifetime="True"

>

</csla:CslaDataProvider>

and I put the ObjectInstance in Code Behind .

 

Notice : I didn't put any authorization or validation roles in my business layer is there any relalion ??

RockfordLhotka replied on Monday, February 16, 2009

Save is enabled only if all these are met:

  1. The object is valid
  2. The object is dirty
  3. The user has authorization

 

dtabako replied on Tuesday, February 17, 2009

I am seeing the same issue. The Save button works great - I love the way it automatically enables/disables itself without having to write any code for that. But the "New" button (using ApplicationCommands.New) is disabled and I'm also not sure why that is.

Incidentally - as a related issue - how would you set up a "New" button for a true child object. Project Tracker uses the click event - assumedly because it interacts with the Assignment object. But if I just have, say, a Customer object that has an editable child list of CustomerAddress objects, is there a way I can use commanding to set up a "New Address" button?

James Thomas replied on Tuesday, February 17, 2009

I'm using Silverlight - is this the kind of thing you meant dtabako?

private void AddProposalManagementButton_Click(object sender, RoutedEventArgs e)
        {
            ((Proposal)((CslaDataProvider)this.Resources["ProposalData"]).Data).ProposalManagement.AddNew();
        }

RockfordLhotka replied on Tuesday, February 17, 2009

The New command only works if the business object is a list that has AllowNew=true and overrides AddNewCore() – it uses the same mechanism as other data binding models to create the new item.

 

Rocky

 

 

From: dtabako [mailto:cslanet@lhotka.net]
Sent: Tuesday, February 17, 2009 8:27 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Hello I Used CSLDataProvider Command Manager with button to Add object but it is disabled?

 

I am seeing the same issue. The Save button works great - I love the way it automatically enables/disables itself without having to write any code for that. But the "New" button (using ApplicationCommands.New) is disabled and I'm also not sure why that is.

Incidentally - as a related issue - how would you set up a "New" button for a true child object. Project Tracker uses the click event - assumedly because it interacts with the Assignment object. But if I just have, say, a Customer object that has an editable child list of CustomerAddress objects, is there a way I can use commanding to set up a "New Address" button?



dtabako replied on Tuesday, February 17, 2009

James,

Thanks for the reply. I actually was looking for a way to use the WPF stock application command ApplicationCommands.New so that I could get my "New" button hooked up via markup without using code (like the Save and Cancel buttons do).

Rocky,

OK, so to make sure I have this right then: for my main object (Customer) I will not be able to use the ApplicationCommands.New markup to generate a new Customer object. I will have to use a click event handler that grabs a new Customer object and feeds that to the DataProvider. That should be easy enough so it's no big deal. I just liked how clean it was to set up the other buttons' functionality directly in markup.

But I should be able to set up the child object CustomerAddresses to utilize the ApplicationCommands.New to add a new address (as long as I set up the AllowNew and AddNewCore) correct? I just don't know what to use as the binding source for the command.

Thanks, Dennis

RockfordLhotka replied on Tuesday, February 17, 2009

Normally you’d set the factory method name of the CslaDataProvider to your “new object” factory if you want to create a new root object.

 

You’ll need a CslaDataProvider for the CustomerAddresses object if you want to use the data provider’s New command to add items to the collection.

 

Rocky

 

 

From: dtabako [mailto:cslanet@lhotka.net]
Sent: Tuesday, February 17, 2009 11:51 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: Hello I Used CSLDataProvider Command Manager with button to Add object but it is disabled?

 

James,

Thanks for the reply. I actually was looking for a way to use the WPF stock application command ApplicationCommands.New so that I could get my "New" button hooked up via markup without using code (like the Save and Cancel buttons do).

Rocky,

OK, so to make sure I have this right then: for my main object (Customer) I will not be able to use the ApplicationCommands.New markup to generate a new Customer object. I will have to use a click event handler that grabs a new Customer object and feeds that to the DataProvider. That should be easy enough so it's no big deal. I just liked how clean it was to set up the other buttons' functionality directly in markup.

But I should be able to set up the child object CustomerAddresses to utilize the ApplicationCommands.New to add a new address (as long as I set up the AllowNew and AddNewCore) correct? I just don't know what to use as the binding source for the command.

Thanks, Dennis



Copyright (c) Marimer LLC