Beginners questions about App Builder


John Clarke

Hi All,

I am new to using AppBuilder and as such I have a few questions. Please excuse me if they seem simple or trivial.

Implementing MVC in App Builder.

1. I use MVC in my Java Applications. How can I take the approach I use for MVC in Java (as demonstrated by this example http://www.austintek.com/mvc/) and implement it in AppBuilder ?

Using Custom JavaScript

1. I know I can use custom JavaScript by using the StartJS and EndJS Markers. However, how do I access the properties of UI Components using Javascript ?

2. If I create an external Javascript File where should I store the file to ensure ease of deployment when the app is finished ?

Views and the App

1. Can I treat views as Classes (as I would in Java) ?

2. Can I add Variables that are Global to the view ?

3. Can I add Variables that are Global for the whole App ?

4. Can I create Custom Functions for a View?


DecSoft

Hello John,

Many questions in the same thread. I will try to reply to all of them.

Hi All, I am new to using AppBuilder and as such I have a few questions. Please excuse me if they seem simple or trivial.

Any question is trivial! :-)

Implementing MVC in App Builder. 1. I use MVC in my Java Applications. How can I take the approach I use for MVC in Java (as demonstrated by this example http://www.austintek.com/mvc/) and implement it in AppBuilder ?

The App Builder apps follows the MVC pattern, since it's implemented by certain Javascript core component (Angular JS) used by App Builder. In fact, you can think in your app's variables and other source of data (like HTTP Clients, etc.) as the model. The view part is the app's view, which automatically reflect possible changes in the model and viceversa.

Every view have also an controller, which is composed by the view's events, view's controls events, etc. With this the controller you can control the model, and, the app's view reflect automatically the possible changes on the model by the controller.

The above basically means that you no need to do anything special, since the App Builder produces apps are based in an MVC pattern.

Using Custom JavaScript 1. I know I can use custom JavaScript by using the StartJS and EndJS Markers. However, how do I access the properties of UI Components using Javascript?

Maybe you want to take a look at the External Javascript tutorial of the App Builder's help.

2. If I create an external Javascript File where should I store the file to ensure ease of deployment when the app is finished ?

Probably the best is that every app have at least one root folder, for example, "MyApp". Inside this folder you can place more folders like "Javascript", then you can place inside your JS files and include it by the app's files manager. Doing that App Builder play with the Javascript files as "local files", that is, you can, for example, move your "MyApp" to another computer, and everything continue working.

Views and the App 1. Can I treat views as Classes (as I would in Java) ?

The app's views have certainly an variable in the app's scope and that variable is an Javascript object variable, with some possible useful properties. But you must explain a little more what you means by "treat views as classes" John.

2. Can I add Variables that are Global to the view ? 3. Can I add Variables that are Global for the whole App ?

All App Builder's apps variables are globals, in the sense that you can, for example, change the text of a button that is not in the current app's view. You can change the text... but the button's text is not shown... until the view who contain it is shown.

4. Can I create Custom Functions for a View?

Using pure Javascript, certainly you can do it, for example, in the app's view's Show event. You can place some functions inside the app's view's variable or in other place in the view's controller. However, commonly what you do is to create app's functions, using both App Builder actions and / or Javascript code, and then use that functions from one view or another.

Please, John, go ahead if you have any further questions.



John Clarke

Just to clarify the above points:

Views and the App 

1. Can I treat views as Classes (as I would in Java) ?

Basically I want to create Custom Functions inside the view that can only be used by that view and no other view.  I also want to create variables inside the view that are only accessible by that view and no other view.  Is this possible and if so how ?

Using Custom JavaScript 

1. I know I can use custom JavaScript by using the StartJS and EndJS Markers. However, how do I access the properties of UI Components using Javascript?

I had a look at the "External Javascript tutorial of the App Builder's help." but couldn't see how I can use it to change the value of a UI component (for example, the text of a label).



DecSoft

Hello John,

Basically I want to create Custom Functions inside the view that can only be used by that view and no other view. I also want to create variables inside the view that are only accessible by that view and no other view. Is this possible and if so how ?

Technically is possible to have functions only for an view, but, that is not how AB works, that is, the app's functions that you can prepare from the IDE, are functions availables for all the views. But probably is enough to use it or not... may depending on the "current view" ([App.CurrentView]), I don't know... may depend on the app that we are talking about.

I had a look at the "External Javascript tutorial of the App Builder's help." but couldn't see how I can use it to change the value of a UI component (for example, the text of a label).

You are right, that is, the tutorial is for other possible external Javascript usage. Again, commonly we no need to use Javascript code to set an app's var or an control's text, however, yes, is possible to do using the "window.App.RootScope", for example:

This action:

Is the equivalent to this other code:


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.