New Posts New Posts RSS Feed: [SOLVED] ListConverters
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[SOLVED] ListConverters

 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] ListConverters
    Posted: 18-Sep-2007 at 4:56pm
Here's the 411:
 
1)  Enter the ListConverter name pairs for each list involved (e.g. Shipper and ShipperID) in the ListConverterNames.cs file in the Interface.Constants project/folder.
2)  Add the pair to the CreateServiceItemCore method of the ListConverterService (Foundation Module)
Market example:

case (ListConverterNames.MarketList):
return MakeMarketListConverter();
case (ListConverterNames.MarketIDList):
return MakeMarketIDListConverter();
 
3)  Create the MakeListConverter methods...one for each of the pair
Market example:

/// <summary> Make the global ListConverter for all Markets; </summary>
private ListConverter MakeMarketListConverter()
{
EntityListConverter<MarketMaster> converter = new EntityListConverter<MarketMaster>(EntityManager, EntityPropertyDescriptors.MarketMaster.MarketMstrDesc.Name, Editability.Optional);
AddListManager_KeepExistingEntitiesOnly(converter);
return converter;
}
/// <summary>
/// Make the global ListConverter for all Markets which can be Customers;
/// use with a MarketMstrIdx property.
/// </summary>
private ListConverter MakeMarketIDListConverter()
{
ListConverter converter = CopyConverter<MarketMaster>ListConverterNames.MarketList);
// Matches and updates the *Id* (index) rather than the Market object
converter.ValueMember = EntityPropertyDescriptors.MarketMaster.MarketMstrIdx.Name;
return converter;
}
 
4) Bind the lists in the view's presenter
Market example:

EntityPropertyDescriptors.CustomerMasterPropertyDescriptor descriptors = EntityPropertyDescriptors.CustomerMaster;
SetBindingListConverter(descriptors.MarketMaster,
ListConverterNames.MarketList);
SetBindingListConverter(descriptors.Market,
ListConverterNames.MarketIDList);
 
Note:  make sure that these bindings fire before the base.OnViewSet().
 
5)  When binding the loose controls, add the index/ID field (not the entity)...make sure to change the control to a comboxbox.  Leave all defaults in the ListConverter
 
Build and run.  That seems to work for me.  It is a bit different than standard DevForce binding.
 
Again, for more examples, please see the Shared Editor module of the Cabana app.


Edited by Linguinut - 18-Sep-2007 at 4:58pm
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: 18-Sep-2007 at 2:29pm
Btw, I am now referencing the SharedEditor for a little better example.
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: 18-Sep-2007 at 2:22pm
Sorry for the contradiction.  The AutoValidate property of the form is not the issue, anyway.
 
The DevForce Object Mapper was used to create the business objects being referenced.  The ControlBindingManager is used to populate the view with loose controls based on the selected bound type.  I am following all DevForce protocols for creating a databound combobox...I have done this dozens of times in a non-CAB environments.  I drag the desired entitylist for autopopulation, then verify that the dataconverter is set to ListConverter, then (following the CAB example for TitleOfCourtesy) I set the DisplayMember to the appropriate property (valuemember is __Self).  The SetBindingListConverter (see above) *does* populate the combobox, but no item is selected when the main entity (Customer) is displayed on the view.  Even if I select a value from any combobox, then navigate away from the entity (or simply away from the combobox!), when I return no value is selected.
 
Somehow, I am not tying the ListConverter from the ListConverterService to the one created by the ControlBindingManager.


Edited by Linguinut - 18-Sep-2007 at 2:32pm
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 18-Sep-2007 at 1:56pm

You wrote:

EnablePreventFocusChange is the option that I desire; however, it does not work--the screen is still "stuck";
 
This seems contradictory--"EnablePreventFocusChange" will prevent shifting the focus away from the control while the value is invalid.  I.e., the cursor will be "stuck".  Which do you want?
 
It sounds like the list is working fine--the problem is that the bound value of the control isn't showing up.
 
Are you sure there is an entity to bind to and that its bound property has a legal value?
 
Was the binding created with the DevForce Object Mapper?
 
Is the bound property of the proper type?  Of the same type as the ValueMember specification of the ListConverter?
 
Bill J.
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: 18-Sep-2007 at 12:43pm

Not sure.  I did recreate the code in my view and presenter.

Several problems:
1)  EnablePreventFocusChange is the option that I desire; however, it does not work--the screen is still "stuck";
2)  EnableAllowFocusChange allows the user to move between controls (the "stuck" part is taken care of); however, the proper list item is still *not* selected.
3)  The Inherit and Disable options seem like they may violate other desireable features (validation, etc.).
 
So, I guess my original question about the binding still needs to be addressed.  How do I fill a list from a listconverter and select the proper item based on the object in view?  It just seems like the order of binding is swapped somehow.  Is there a different way to bind the lists earlier than the view?
 
Of course, I may not even be asking the right question, either.  I am still learning.  Thanks for being patient with me.
 
Bill
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 18-Sep-2007 at 10:49am
How is your view's AutoValidation property set? 
 
(AutoValidate is a property of System.Windows.Forms.UserControl)
 
In SalesRepGeneralView, at line 38 we see:

/// <summary>Configure the presenter for this view.</summary>

/// <remarks>

/// Configuration that can be done immediately after setting

/// the Presenter's View reference.

/// </remarks>

private void ConfigurePresenter(SalesRepGeneralViewPresenter pPresenter) {

pPresenter.BindCountryControl(mCountryTextBox);

pPresenter.AgePlausibilityEvent += AgePlausibilityEventHandler;

AutoValidate = pPresenter.SetAutoValidation();

}

In it's presenter, at line 54 we see:
 

/// <summary>Set how the View constrains focus change when validation fails.</summary>

/// <remarks>Can also disable auto validation altogether.</remarks>

public AutoValidate SetAutoValidation() {

// Play with the choices.

return AutoValidate.EnablePreventFocusChange; // Locked in control

//return AutoValidate.EnableAllowFocusChange; // Can move

//return AutoValidate.Inherit; // Do what the parent container does

//return AutoValidate.Disable; // Don't autovalidate.

}

Have you tried playing around with these values to get the behavior you want?
 
Bill J.
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: 12-Sep-2007 at 7:46pm

These are still a bit enigmatic within the CAB.  Could someone walk me through implementing a new, data-dependent ListConverter?

Thanks,
Bill
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: 11-Sep-2007 at 11:38am
I created a new presenter for the view that was created by the wizard.  Within the presenter I added the code to set the list converter, as follows:
 
SetBindingListConverter(CustomerMaster.Descriptors.MarketMaster, ListConverterNames.MarketList);
 
I am following the Cabana example app.  The problem is that when the view is displayed, the list is filled properly; however, the screen is "stuck" in that combobox.  No value is selected for any combobox with an assigned ListConverter (total of three on this view).  I am forced to select an item from the list, then I can move to another field or even another page.
 
This is odd behavior.  I must be missing some little thing within the framework.
 
Thanks, in advance, for any help,
Bill
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: 11-Sep-2007 at 10:30am
In the Cabana sample application the list converters are created in the presenter.  When I created a new search summary detail page, no presenter was created with the summary control.  I have three lists that I need to fill on the page.  I have created the lists using the service in the foundation module.  What is the best way to do this?

Edited by Linguinut - 19-Sep-2007 at 12:30pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down