Question

I have a "Download File" action in the "Installer" step of Install4j. This action downloads a file and saves it to the installation directory. All of that works fine. However, the URL of the file to be downloaded is dependent upon user input. How can I set the URL to a variable (from my main class) that I can then use from within the download file action? I have only been able to find a way to get variables in the main class, but not set them. Any ideas?

Was it helpful?

Solution

Before your "Download file" action, add a "Set a variable" action. In the action's configuration change the "Script" to return the desired URL string:

// Get some user input from some screen's input field.
String userInput = (String)context.getVariable("sometextbox");

// Call your custom code with user input and return a url
String url = com.mycompany.getDownloadFileUrl(userInput);

// Set it to the runtime variable.
return url;

Set the "Variable" property to a recognizable name.

Then, go back to your "Download file" action and click the arrow that appears if you click within the entry field for "URL".

Click insert runtime variable -> Bound variables and click the variable you created in the earlier step.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top