Binding navigation properties to formview - entity-framework-4

I'm using formview and objectdatasource for editing/inserting objectdatasource.
I want to update an entityobject properties together with its navigation properties in a single formview.
Is this possible? Any ideas on how to do it?

Yes, it's possible. One way is to override the FormView.ItemInserting/ItemUpdating methods and add add new values of any type and kind (including navigation properties) by hand here.

Related

Vaadin the view change, forget the information

I wanted to save the information, during the view change.
When I go from one view to another view, I Be Lost the load information of the opposite view.
How can i keep the information or how can i keep the view
I use in my application that source code
http://www.programcreek.com/java-api-examples/index.php?source_dir=java_learn-master/vd7_learn/src/main/java/com/mycompany/MyVaadinUI.java
Thank you in advance
According to your code, you provide View for navigator as class, so it creates new instance of class on each navigation.
You should use addView with instance of your class.
Example:
getNavigator().addView("page1", new PageView());
I believe you need to save the information in the VaadinSession.
In view1, do this:
UI.getCurrent().getSession().setAttribute("param_name", "param_value");
In view 2, do this:
String param_value = UI.getCurrent().getSession().getAttribute("param_name");
param_value could be instance of any class.

Swift 2 / XCode 7 - "EXC_BAD_ACCESS (code=2...)" when calling "ViewController().view" in another class

why is this error happening and what can i do to fix/prevent in the future? thanks!
NOTE: my other class is set up as such:
class Other {
//then all relevant funcs called
}
am i missing some basic setup information in order for this to run?
The formal explanation would be:
You're trying to access the view property before it was initialized. Another way to look at it is that you're trying to access the view property before it was loaded (in viewDidLoad).
Solution:
Depends what you're using that view for. I've never had to access another view controller's property like that. Consider exploring other strategies such as delegation, weak references to another controller, and passing variables in prepareForSegue if you need a reference from a view controller from another.

Connecting event handler to custom UIView component

I have a custom UIView component called ControlsDockView and I have a couple of buttons in the view. I know that you can add the click event for the buttons directly to the UIViewController and proceed further. But would it be possible for me to add the event handler to the ControlsDockView? If so, how?
For android, I know we can directly have the event handler written in the view but is it different with swift?
Do I have to go through the view controller for it? Maybe it is a newbie question but I need to know how I can proceed with this.
Thanks in advance for your help
Yes. You can create an action for a button in your custom view. Easiest way is probably to ctrl-drag from interface builder to your view code.
you will then get an IBAction func actionHandler(sender: UIButton) {} in your view code.
Another way to set this up is by adding the action to the buttons in your loadFromNib method or constructor in the custom view.
However, be careful about adding any kind of logic that isn't directly related to the view in those actions as it's considered an extremely bad coding practise to add business logic to you views in such a manner.

Databinding in iOS/OSX frameworks

I wonder if there is any frameworks I'm not aware that I can use to achieve the concept of databinding, bind a NSObject derived class (the model) to a UIControl/NSControl derived component properties.
For example I have a class with a property name and I need to bind it to a UITextView text property so that when the model's name property changes the UITextView text property updates.
I guess that there would be something built on the Key-Value Observing concept.
I would like something that is working in both OSX and iOS or any other related frameworks for the platforms.
Thank you.
You're looking for ReactiveCocoa - super awesome framework that does exactly what you asked for and more. Also a good way to implement MVVM - they have cool extensions that enable that ReactiveViewModel as well as extensions for AFNetworking
Take a look at AKA Beacon (https://github.com/mutech/aka-ios-beacon). It's a binding framework that allows you to bind views to properties right from interface builder. The view controller (by default) serves as view model for bindings. You just have to add one line of code to the view controller to activate binding support and the framework takes care for all the rest.
Beacon supports most standard views (Label, TextField/View, Image, Slider, Stepper, Switch, TableView, etc.). It's relatively easy to write extension bindings for custom views.

Singleton-Like UIView Access?

I have a UIView I need to access the properties of from all around my app. I know you can't create a Singleton around a UIView object, so what might be a good way of doing similar?
E.g. The view has a label. From any view controller in my app I want to be able to change the text of this view (sitting in a parent view controller).
Thanks.
EDIT:
Success! Using KVO to track changes in my Singleton object worked a charm, and a very simple solution.
I think what you’re trying to do violates the separation of concerns of the MVC pattern: The only thing that should interact with a view is its controller. In your case, you should probably be creating a model that is watched by your view controller (maybe through key–value observing), and then the controller can propagate the necessary changes to your view.
If you know (read: you really know for now and forever!) that there will be at most one instance of that view alive at one point in time, you can just use a global variable to store that. Or use a class property on that view - which is as close as being a singleton as possible.
Or you might just fix your design, which has proven to be the better choice in every case I can remember. :) Just add some forward and backward references in your classes (and stick to MVC principle). It takes much less time to implement that worrying about those awkward workaround, and it will pay of rather sooner than later.

Resources