How to load data into Ext.tree.TreePanel (not through ajax) - extjs3

in example here
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.tree.TreePanel
i can see property dataUrl: 'get-nodes.php',
but how i can change data from inside my code? there is no store property or setSource method
EDIT:
as i found, one of the possibilities is to create my own Ext.tree.TreeLoader that would have setSource method and use it instead of default
maybe there is more variants?
EDIT:
seems there is already a solution for this
http://www.sencha.com/forum/showthread.php?4595-Creating-Ext.tree.TreePanel-from-static-JSON-data-in-one-shot

seems there is already a solution for this
http://www.sencha.com/forum/showthread.php?4595-Creating-Ext.tree.TreePanel-from-static-JSON-data-in-one-shot

Related

How to make copy of array's elements in the dart

Getting wired issue like main array has been changed if changed value of another array. I think issue is about copying same address, not sure but just thinking of it. I have tried from last 3 hours but unable to get rid from it.
Look at below illustration to get better idea.
List<page> _pageList;
List<page> _orderList = [];
_pageList = _apiResponse.result as List<page>;
_orderList.add(_pageList[0].element);
_orderList[0].title = "XYZ"
//--> Here if I change the `_orderList[0].title` then it also change the `title` inside "_pageList"
How can we prevent the changes in main array?
I got same issue in my one of the project. What I have done is, use json to encode and decode object that help you to make copy of the object so that will not be affected to the main List.
After 3rd line of your code, make changes like below
Elements copyObject = Elements.fromJson(_pageList[0].element.toJson());
// First of all you have to convert your object to the Map and and map to original object like above
_orderList.add(copyObject);
Hope that will help you.
You can use a getter function to create a copy of your list and use that instead of
altering your actual list.
example:
List<Page> get orderList{
return [..._orderList];
}
Lists in Dart store references for complex types, so this is intended behaviour.
From your code:
_orderList.add(_pageList[0].element);
_orderList[0] and _pageList[0].element point to the same reference (if they are non-primitive).
There is no general copy() or clone() method in dart, as far as i know. So you need to copy the object yourself, if you want a separate instance. (see this question)

How can I read out the "glade ID" of a gtk3 object

In glade it is possible to set an unique ID to an object. In the code one can obtain a pointer to this object by searching for it's "glade ID" via gtk_builder_get_object().
However for my current use-case I just want to read out this ID from an GObject. What's the API to do so ?
You can't. The builder ID is stored in the builder internally, not in the GObject.
The reason for this is that IDs must be unique per builder, which would be impossible to enforce if you were able to get and set them via some GObject API.
You could use gtk_widget_get_name() to identify an object.
It is possible using Gtk.Buildable.get_name(object). This method will return the Glade object id.
This snippet will print all object ids in your Glade XML:
builder = Gtk.Builder()
builder.add_from_file("my-window.glade"))
for obj in builder.get_objects():
print(Gtk.Buildable.get_name(obj))
As stated by #ptomato it's seems not possible.
I found that in that line in the documentation:
All the fields in the GObject structure are private to the
implementation and should never be accessed directly.
But you can circumvent it because at one point in your code you were refering to it by the id that you typed in (or the code you wrote type in) so you just need to store it at that point. And link it somehow (with a variable or a data structure) to the name of the variable holding the object.

Xamarin Sport App - What does IsDirty do?

I am looking through the Xamarin Sport app code and trying to understand some of the cool things they are doing in it. I cannot understand what IsDirty is being used for exactly. It gets defined here and implemented here and used in many places, such as here.
I read a little about and ICommand's IsDirty property so maybe it is a way to call an entire model as being dirty, but what implications does that have?
I also see it being used here which I am assuming is why they created it in the first place.
Thanks for y'all's insight into it.
They're just using it as a clever way to handle modification detection. Consider a "Save Changes" feature; you don't actually want to enable the "Save" button until something has changed, and you can key off the IsDirty property to test that.
Technically, you could handle this yourself by having a base class hook INotifyPropertyChanged.PropertyChanged and maintaining a dirty bit of your own (possibly in a base class), but rather than require all of their classes to have an IsDirty property that they may or may not need, they've made it an optional feature that a class can implement. For example, take a look at GameResult for an example of something that can't be changed, and therefore, can't be marked as dirty.
With this approach, you've minimized the amount of code you need to write to implement this functionality. All your derived classes need to do is derive from BaseNotify, implement IDirty, and call SetPropertyChanged(...) as the setter to set the private tracking field, signal to any observers that a property has changed, and automatically set the dirty bit.
NOTE: I did just make an interesting observation: while the implementation of the SetProperty extension method does set the IsDirty flag, the BaseNotify class' IsDirty implementation doesn't call anything to bubble up a PropertyChanged event for IsDirty, which means bindings against it won't get updated when it changes. I believe the fix would be for that extension method to invoke PropertyChanged with the property name "IsDirty":
if(dirty != null) {
dirty.IsDirty = true;
handler.Invoke(sender, new PropertyChangedEventArgs("IsDirty"));
// Yes, I'm a bad person for hard-coding the name.
}
Alternately, you could defer signaling the IsDirty change until after you signal the original property has changed. I just chose to keep it with the original logic.
I think it's relatively simple and you're on the right track: the purpose of that property is to have an easy way to know whether some property has been changed, so the whole object has to be saved. It's baked in to the way property changes are propagated, so you don't have to set it by yourself whenever a property value is being set.
tl;dr: You can use it to check if you your (view)model is worth a save operation ,-).

MyBatis mapper to call factory method

I want mybatis to call a factory method to create an object instead of a constructor. So that for null valued attributes i can return a NULL object(which has overridden behavior to handle all the edge cases) instead of actual object. Can i achieve that with mapper.xml?
Define your own ObjectFactory
http://www.mybatis.org/core/configuration.html#objectFactory
To answer your specific question, there is no way to specify a factory method directly (and only) in the mapper.xml file itself, as far as I know. However, there are two options in MyBatis to do what you want:
As stated in Bhaskar's answer you can use an ObjectFactory.
In theory, you can also define a TypeHandler, but I was unable to get this to work in my recent testing.
If you would like to see a working example of how to use a MyBatis ObjectFactory to implement a Null object, see koan19 of my MyBatis koans: https://github.com/midpeter444/mybatis-koans. (Look in the completed-koans/koan19 directory for the solution I came up with.)

Programatic property injection with Microsoft Unity

I use contructor injection in my solution, but this one class has a property that i do not want to pass in the constructor where i have the invariant dependencies.
Let's say i got an ILogger and it has a FileName property i want to set, while still having it set the dependancies in the contructor.
How do i go about registering the type, and at the same time pass the defaunt connection string.
I hope there is an easy way to do it - preferably without decorating the property with an attribute, but if the setup is easier with the attribute i guess that's cool :)
So the question is, how do i inject a property value on an object that also uses contructor injection - with Unity.
UPDATE: I mentioned it in the title, but i forgot to elaborate in the body of the text - i want to set these dependencies up manually (in code) as opposed to in a config file.
Ok i guess it helped to ask the question, i found out - here it is.
container.Configure<InjectedMembers>().ConfigureInjectionFor<BasicLogger>(
new InjectionProperty("FileName", #"C:\test.log")
);
If you are injecting properties you have to use [Dependency] or else manually inject that dependency.
You usually want an IConfiguration interface to be injected. This would probably have a LogFile property that you can read.
The Configuration implimentation is usually just a simple wrapper to read items from the config file.