Refresh after ApplicationCommands.Save

Refresh after ApplicationCommands.Save

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


PederSvaleng posted on Monday, January 12, 2009

I need some help to refresh ClinicalDocumentAutPatRecRoList bound to a listbox after using the ApplicationCommands.Save on ClinicalDocumentSW. Does anybody know how I can do that.

I tried to search the forum, but couldn't find an answer..

<csla:CslaDataProvider x:Key="ClinicalDocumentAutPatRecRoList"
ObjectType="{x:Type APBusinessObjectsFlat:ClinicalDocumentAutPatRecRoList}"
FactoryMethod="GetClinicalDocumentAutRecList" IsAsynchronous="False" IsInitialLoadEnabled="False">
</csla:CslaDataProvider>

<csla:CslaDataProvider x:Key="ClinicalDocumentSW"
ObjectType="{x:Type APBusinessObjectsFlat:ClinicalDocumentSW}" FactoryMethod="GetClinicalDocumentSW" IsAsynchronous="False" IsInitialLoadEnabled="False"
DataChanged="DataChanged"
ManageObjectLifetime="True">
</csla:CslaDataProvider>

<Button Command="ApplicationCommands.Save" 
   
CommandTarget="{Binding Source={StaticResource ClinicalDocumentSW}, Path=CommandManager,    BindsDirectlyToSource=True}"HorizontalAlignment="Left" IsDefault="True">Save</Button>

Thanks

Fintanv replied on Monday, January 12, 2009

My readonly lists support the MS Cache block, I also have a static method on the various list classes that will flush the cache of lists of a given type.  When the appropriate editable object/object list completes a save which may invalidate one or more lists, I call the flush methods post save (within the editable BO).  The end userof the BOs therefore never need to know what items are cached and when they need to be cleared.

I am sure you can modify the pattern even if you are not using the caching block.

Best regards,
Fintan

RockfordLhotka replied on Monday, January 12, 2009

He still needs the UI to re-read the data from the list (thus triggering the reload of the list from the database).

The CslaDataProvider control has a Refresh() method that should force a re-read of the data. I don't know if you can invoke that entirely from XAML though - at least not without creating a command handler or something along that line.

PederSvaleng replied on Tuesday, January 13, 2009

Thanks Rocky! For your respond.

Currently I don't know to much about creating a command handler :) I have to check it out..

<Button CommandTarget="{Binding Source={StaticResource ClinicalDocumentSW}, Path=CommandManager, BindsDirectlyToSource=True}"
HorizontalAlignment="Left"
IsDefault="True"
Click="Button_Click" Name="buttonSave">Save
</Button>

I removed the Command="ApplicationCommands.Save" from my button and added a button eventhandler

private void Button_Click(object sender, RoutedEventArgs e)
{
   
if (_clinicalDocumentSW.IsSavable)
   {
      dpClinDocSW.Save();
      DisplayList();
   
}
}

Now, I can update my list, but my button is stateless....

 

 

Copyright (c) Marimer LLC