#1 2018-01-30 16:50:43

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,715
Website

Introducing the new app views Params variable

Hello to all,

You know that DecSoft's App Builder create HTML5 apps, Progressive WebApps and WebExtensions for the modern mobile and desktop browsers, and, additionally, can also create hybrid apps for various mobile and desktop platforms like Android, iOS, etc.

If we want to deploy our app as an HTML5 app or an Progressive WebApp, that is, by place the app in some internet server, we can just launch the app's URL in order to reach it, for example, by using an URL like the below one:

https://www.appserver.com/#!/View1

Now, what happen if we want to pass some params to our app? The first way that we can think is to use an URL like the below one:

https://www.appserver.com/#!/View1?param1=value1

However, the above is not the best way, because, for example, the "param1=value1" are then propagated around any successive app view. Not to mention that we must extract the "param1" value from the URL by using some Javascript code.

To solve this, the current DecSoft's App Builder release introduce a new Params variable in all app views except the master one.

In order to pass one or more params to our app using the URL we can use an URL like the below one:

https://www.appserver.com/#!/View1/param1=value1

Note how we use the "/" character next to the view name, instead of the "?" character.

The above URL causes than the new "[View1.Params]" variable are filled and we can access to the "param1" value in this way from the View1 Show event:

Alert "" "You pass the [View1.Params.param1] value for the param1"

Of course we can pass more than one param in the app view URL:

https://www.appserver.com/#!/View1/param1=value1&param2=value2&param3=value3

And then access to that params using the view Params variable: [View1.Params.param1], [View1.Params.param2] and [View1.Params.param3] in this case.

We can use the above kind of URLs not only with the main app view, but, with any view. In fact the Params variable has been introduced to be used with the main app view, in other words, to pass some optional arguments to our main app view.

However, the Params variable is available to any other view too. And, in fact, we can now use the "ShowView" and "ReplaceView" actions to pass params too. Remember that we can use the "ShowView" action to load an other app view:

ShowView "OtherView"

Now, we can use the "ShowView" action in this way:

ShowView "OtherView/param1=value1&param2=value2"

The above works as expected, that is, we can access to the [OtherView.Params.param1] and the [OtherView.Params.param2] variables from the OtherView Show event.

And that's all!

The current release of DecSoft's App Builder also includes a new "ViewParams" app sample (number 170!) that shows the usage of the new app views Params variable, and how we can use it with the "ShowView" action too.

Upgrade your AB copy, play with the new Params variable and the new "ViewParams" app sample and post here if you have further questions or comments around this!

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.