Question

Is there any way to get the component ID for a component which also has a custom ID set?

My use case is as follows: I have an installer with downloadable/external components and I want to display one of them in the GUI only if the .dat file is present in the installer layout.

The problem is that the .dat file uses the component ID in its filename, whereas I have been using a custom ID throughout the installer in order to more easily identify each component. With a custom ID set, the getId() function returns said custom ID and not the regular one, so I can't use that in order to programatically build the component filename which is used to enable the component visibility in the GUI.

Right now I'm using a workaround by not setting a custom ID for the components which I want invisible unless already present and then manually matching that ID with a particular component via its name (something like if(component.getName().equalsIgnoreCase("compName")) { context.setVariable("compNameID", component.getId()); }) and then using that compNameID variable in the rest of the scripts.

Was it helpful?

Solution

You can call

import install4j.runtime.installer.ContextImpl.InstallationComponentSetupImpl;   

String id = ((InstallationComponentSetupImpl)component).getInternalId()

to get the internal ID of an installation component.

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