Skip to Content
0
Jul 27, 2016 at 07:31 AM

Defaulting view controls with parameters passed via URL

49 Views

Hi All,

Let's say UI5 app runs via following URL (and in addition, I am passing a URL parameter param01):

http://mydomain.com:1080/sap/bc/ui5_ui5/zmyui5app/index.html?sap-client=030&param01=1000

Obviously, I can read this parameter using following statement in view controller onInit() or Component.js:

var sParam01 = jQuery.sap.getUriParameters().get("param01");


//Now sParam01 is set to 1000 from URL parameter.



Let's say we have a Select (dropdown combo box) on the view.


Can we set the default value (setSelectedItem) of this Select using sParam01?


I have tried it in all functions responsible for the creation/load of view. I can access the value and the label and the value sets ok but it is not displayed. The reason for this is binding (Select is bound to JSON datamodel) occurs AFTER onInit() and overwrites what was assigned from the parameters. I have also tried to rerender the view where possible.


The requirement is such that I have an app which defaults to certain values. Each business unit would like to see their own defaults as soon as the app loads.


What can be done to achieve this? Can someone show an example?


Thanks.