on 03-27-2015 6:24 AM
Hi Experts,
I have several question regarding xml fragment and controller development with UI5:
1. I have a fragment.xml witch contains a Dialog with sap.ui.unified.FileUploader control. I have defined an 'id' property on the control.
The problem is that when i close the dialog and open it again in my application it says that the Dialog could not be created because of the duplicate id of the FileUploader. In order to overcome the problem call oDialog.destroy() when i close the dialog.
Is it the correct solution for duplicate id problem ?
2. I have created a model, fragment.xml and a controller. I set the model to the fragment using setModel() method, but i want my controller to update the model either. I did not find a method on the controller that sets a model so i created a new method on the controller setDataModel() which sets the model and updates the controller private property pointing to the model.
Is it the correct solution ? Is there a way to pass my model to the controller using another api ?
3. My Dialog has FileUploader and a button that adds a tree control on the fly. Initially the dialog has does not displays the tree control.
I use Grid control to layout FileUploader and the button.
When i add the tree control i use addContent(oTree) method. It works fine.
My colleagues told me that probably the best solution will be to place an empty HTML control when i create the dialog and fill it later when user presses on the button. What do you think ?
4. The tree control that i add to the dialog on the fly is got from an asynchronous method. Is there any support in UI5 to do things asynchronously ?
Regards,
Slavik.
Slava,
1) do you open it OR instantiate ( sap.ui.xmlfragment(...) ) and open? when you deal with fragments - instantiate it once in onInit and reuse later on with open and close
2) set the model to core, so you can use from any place of your app
3) addContent should work just fine. HTML control is a very special "beast", for past 2 years i can't remember a case where I would really need to use it
4) sapui5 has pretty much everything async, odatamodel.read has a callback + all the events it fires (RequestCompleted/RequestFailed/RequestSent)
btw, you will get much more responses if you split your questions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maksim,
Your answer is very helpful .
1. When i create my fragment i pass a controller to it:
var oController = sap.ui.controller("controller_name")
var oFragment = sap.ui.xmlfragment("fragment_name", oController);
Is there a method to get the controller from the fragment , like this oFragment.getController or to get fragment from controller oC ?ontroller.getFragment() ?
Regards,
Slavik
Hi Santhosh,
Yes i know how to bind a control property to a controller method.
I just need a way to get a controller instance in code when i create my fragment like this:
var oController = sap.ui.controller("controller_name")
var oFragment = sap.ui.xmlfragment("fragment_name", oController);
I just need something like : oFragment.getController()
I know for example that there is such a method in a view.
Regards,
Slavik.
Hello Stanislav,
controller will be controls the execusion, if u run your application, controller will execute first and view will be next. so if u create instance in view and if u r going to control the execution from view itself then what is the need of the controller.As of my knowledge it is going opposite to MVC architecture(UI5 follows MVC). And of course in JSP u can do control by view itself but that type of application is not follows MVC.
Thanks,
Santhosh Gowda
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.