on ‎2019 Jan 21 4:14 PM
hello all i want to add a hardcoded code in my controller so i add this in my project.properties myWebservices.v2.erpUrl=www.facebook.com and i called it from my controller like this
private static final String the url= "myWebservices.v2.erpUrl"
but the url prints "myWebservices.v2.erpUrl" not the value i want , what iam missing here ?
Request clarification before answering.
This is not the best solution.
Config.getParameter("myWebservices.v2.erpUrl")
As indicated you can/should use the configurationService. This is the better solution as this would make unittesting easier (more loosely coupled) compared to Config. The configurationService can be mocked.
configurationService.getConfiguration().getString(url)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can also use the services class provided -> configurationService.getConfiguration().getString(url)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please use the following code:
import de.hybris.platform.util.Config;
String url = Config.getParameter("myWebservices.v2.erpUrl");
Please note that you should first check if your configuration has been loaded or not. To do this, you can do any of the following:
a. Go to hAC > Platform > Configuration and enter myWebservices.v2.erpUrl in the Search field. It should display a Key as myWebservices.v2.erpUrl and its Value as www.facebook.com.
b. Go to hAC > Console > Scripting Languages. Ensure that Script type is set to groovy and enter the following code in the input box > Click Execute. The Result tab should display www.facebook.com.
import de.hybris.platform.util.Config
url = Config.getParameter("myWebservices.v2.erpUrl")
println url
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.