How to use constants in order to determine the application URL?

3
In our project we have multiple application (and database) servers based on the same .mdp (MPR). In some cases we would like to handle logic differently among the different application (URL's). I know we can use constants which contain the different application URL's, but how to deal with it? Further, I would like to know how to configure the the file 'application.conf.'?
asked
2 answers
4

Constants are a set of, well, 'constants'. These are values that never change and always have the same value in your project. The cool thing about them is that you can change them between different DTAP settings (dev, testing, acceptation, production).

This helps you if you were to, for instance, want to use a different URL in different environments to call a webservice. Note that you can set the settings for OT in the modeler, but you need to configure them in your application.conf in AP

Constant_mywebserviceURLconstantname = http://www.example.com

answered
2

Another way is to create a simple JavaAction which just returns the root url:

//2.4 application root
return com.mendix.core.conf.Configuration.getApplicationRootUrl() 
//2.5 application root
return com.mendix.core.CoreManager.getInstance().getConfiguration().getApplicationRootUrl()
answered