Flex 4 component is created before dataprovider gets data - list

I have a custom component (List) which gets the dataprovider from external xml which calls a service again.Dataprovider is set to custom list by ID.
For the first time when screen loads the list is generated with data but later after if I refresh the screen the list is loaded with empty because list is getting created before dataprovider gets values from xml and service.
Every time if I run in debug mode I will get the list generated as I will wait till dataprovider gets data..but if I run in normal mode I could see empty list some times.

You can try Binding the Dataprovider to the list. So even if it is updated late it will automatically update the list.
You can use metadata tag something like:
[Bindable]
private var arrayCollection:ArrayCollection;
and update the 'arrayCollection' when you get data dynamically.
Hope it helps.

The data binding could be the solution for your problem.
Other way could be set the dataprovider of the list when the service gets the result
- Call the service
- The service obtains the data
- list.dataProvider = result of the service
Anyway, data binding seems the best solution
[Bindable]
private var arrayCollection:ArrayCollection;
<s:List dataProvider="{arrayCollection}" ....

Related

Asynchronously populate/pre-fill multiple, user mutable `#State` values when using SwiftUI?

I have some TextField(s) with “.text” values that are supposed to be populated by a method called within “init()” (can be moved) that asynchronously calls a completion handler with a struct of data from the network.
The thing is... the user can also begin typing into them manually in the meantime and the completion callback shouldn’t overwrite the manually edited values.
I’m not sure how to:
Update the values of the #State String variables to replace the existing values only if they haven’t been modified by the user yet... while also having them be mutable by the end-user.
Update N number of the #State values from the same request at once. One request is used to pull all of the data in, so mapping into a single value while having it be mutable as noted above is a head scratcher at the moment.
It seems like a job for Combine, just not sure where to start yet.
I'm assuming the user-edit is per-field and all other fields should be left alone.
Move all state inside an ObservableObject, make the state variables #Published, take a publisher from each and create a sink from each setting a variable if stateX != initialStateXValue { stateXUserModified = true } inside each sink and have a method networkUpdate(loadedData:) on the ObservableObject which only sets the state if the associated stateXUserModified is false.

How to get all goals triggered during Sitecore session in commitDataSet Analytics pipeline?

I have an Analytics pipeline added just before the standard one in section to delete duplicate triggered pageevents before submitting all to database so I can have unique triggered events as there seems to be a bug on android/ios devices that triggers several events within few seconds interval.
In this custom pipeline I need to get the list of all goals/events the current user triggered in his session so I can compare with the values in dataset obtained from args parameter and delete the ones already triggered.
The args.DataSet.Tables["PageEvents"] only returns the set to be submitted to database and that doesn't help since it is changing each time this pipeline runs. I also tried Sitecore.Analytics.Tracker.Visitor.DataSet but I get a null value for these properties.
Does anyone knows a way how to get a list with all goals the user triggered so far in his session without requesting it directly to the database ?
Some code:
public class CommitUniqueAnalytics : CommitDataSetProcessor
{
public override void Process(CommitDataSetArgs args)
{
Assert.ArgumentNotNull(args, "args");
var table = args.DataSet.Tables["PageEvents"];
if (table != null)
{
//Sitecore.Analytics.Tracker.Visitor.DataSet.PageEvents - this list always empty
...........
}
}
}
I had a similar question.
In Sitecore 7.5 I found that this worked:
Tracker.Current.Session.Interaction.Pages.SelectMany(x=>x.PageEvents)
However I'm a little worried that this will be inefficient if the Pages collection is very large.

EmberJS client side record management (ember-data)

I have just started trying to use ember-data. I have an ember app for which I need to produce all the data on the client side and then save it all at once. So my object graph has a "Project" as the root object, then a project can have many "Sections" and then each section can have many "Items".
I am up to the stage where I am trying to create Item records on the client side and add them to the correct Section. When I am ready to save the data I just want to use project.save() and have it go and save the object graph instead of saving every time the model changes.
I am trying to look up the section to place the items in by name using store.filter({name:"section1"}) but ember keeps trying to go to the server to look them up. I see this in the console: GET http://localhost:4200/sections?name=Section1 404 (Not Found).
This is what I am trying to do:
store.filter('section', {name:'Section1'}, function(section) {
return section;
}).then(function(section)
{
var record;
//create a record
section.pushObject(record);
});
You are doing server side filtering and you want client side filtering.
Please read this article carefully.
In short, you should do
store.filter('section', function(section) {
return section.get('name') == 'Section1';
});

Microsoft Dynamics CRM - Pass Parameters from Web Service to IPlugins

We are building some plugins in Microsoft Dynamics CRM by inheriting from IPlugin. We have these configured so they fire whenever an Account is updated.
The problem is the plugins are calling our services, which causes our service to respond with an update. We are doing some pretty hacky things right now to prevent these cyclical updates from happening.
We were wondering if there was a way to pass a value to the IOrganizationService service (the web service) that a plugin can look at. Our other system could send a flag ("hey, don't bothing sending an update!") and the plugin could skip calling back.
Can we pass parameters from web service to the plugins?
Good idea could be usage of custom flag-field. For example you add bit field and call it CallFromExternalSystem. So when you make an update from your external system through IOranizationService you just fill this flag with true field and in plugin you can check condition that this field is present in fields list so you have no need to call external system endpoint again.
We decided the correct solution was to use the value found in IPluginExecutionContext.InputParameters["Target"]. In the case of an Update, this returns an Entity containing attributes for all the attributes that were updated.
We basically have a list of attribute names we cared about. We loop through names and see if any of them appear in the entity attribute list. If so, we send an update to our other system. The good news is, Dynamics CRM ignores updates where the values don't actually change, so trying to update a value to itself is no-op.
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = serviceProvider.GetService(typeof(IPluginExecutionContext));
Entity entity = (Entity)context.InputParameters["Target"];
string[] fields = new string[] { "name", "statecode", "address1_line1" };
bool hasUpdates = fields.Where(f => entity.Attributes.Contains(f)).Any();
if (!hasUpdates)
{
return;
}
}

How to refresh an Infragistics UltraGrid?

I am using Infragistics UltraGrid with datasouce Windows Bindingsouce.
On change, I provide datasouce to Bindingsouce and call DataBinding of UltraGrid. Value in the datasouce of Bindingsouce changes, but that is not reflected in the UltraGrid.
Your binding source must raise some event to trigger grid refresh. For example, if you are using BindingList it should raise the ListChanged event.
Also, make sure that whatever class that you are using as your Binding Object implements INotifyPropertyChanged so that when you update the BindingObject at run time it gets channeled to BindingSource which eventually gets picked up by Grid.
i.e.:
BindingList<Foo> lstItems = new BindingList<Foo>;
BindingSource bso = ;
bso.DataSource = lstItems;
Grid.DataSource = bso;
public class Foo : INotifyPropertyChanged
see MDSN article here
Also depends if you changing the collection outside Grid (at runtime, because if you do, you need to use BindingList<T> and assign it to BindingSource