Hi, I need to run validationActions based on user choices when setting up parameters. Values set per user choice in one parametergroup are used in subsequent parameterGrouping. The continuation of installation is conditional on proper validation of these choices. So, I'm running a few custom Java classes to validate user choices to determine installation progression. All works fine when the installer runs in the UI mode, but when I run it in unattended mode, the validationActions dont run and none of my Java validations are taking place. I'm including the relevant snippets of my project file:

In the first choice, I ask the user to select between MSS and Oracle databases, based on which I set up JDBC drivers (and other DB-specific values). In a subsequent parameter, I run a Java class to check for database connectivity to check if the DB specified is accessible. The installer is expected to fail if the connection cant be established. This part fails with unattended installations. Is there a way I can validate the choices, run a series of SetInstallerVariables in unattended mode?

<choiceparameter> <name>DATABASE_TYPE</name> <title>Choose a database</title> <description></description> <explanation>Select database</explanation> <value></value> <default></default> <allowemptyvalue>0</allowemptyvalue> <clioptionname>${project.shortName}_database</clioptionname> <displaytype>radiobuttons</displaytype> <ordering>default</ordering> <width>40</width> <optionlist> <option> <description></description> <image></image> <text>MSS</text> <value>MSS</value> </option> <option> <description></description> <image></image> <text>Oracle</text> <value>ORA</value> </option> </optionlist> <validationactionlist> <setinstallervariable name="DBMS_DRIVER_CLASS_NAME" value="net.sourceforge.jtds.jdbc.Driver"> <rulelist> <comparetext> <logic>equals</logic> <text>${DATABASE_TYPE}</text> <value>MSS</value> </comparetext> </rulelist> </setinstallervariable> <setinstallervariable name="DBMS_DRIVER_CLASS_NAME" value="oracle.jdbc.driver.OracleDriver"> <rulelist> <comparetext> <logic>equals</logic> <text>${DATABASE_TYPE}</text> <value>ORA</value> </comparetext> </rulelist> </setinstallervariable> </validationactionlist> </choiceparameter> <parametergroup> <name>CheckDatabaseConnectivity</name> <title>Check Database Connectivity</title> <explanation></explanation> <value></value> <default></default> <parameterlist> <booleanparameter> <name>chk_database</name> <description>Check if you want to verify database connectivity</description> <explanation></explanation> <value>1</value> <default></default> <displaystyle>checkbox-left</displaystyle> </booleanparameter> </parameterlist> <validationactionlist> <runprogram> <program>${java_exe}</program> <programarguments> -cp <classpath-with-db-jars> com.acme.DatabaseConnectionAction ${LOGID} ${LOGPASSWORD} ${DATABASE_URL} ${DBMS_DRIVER_CLASS_NAME} </programarguments> </runprogram> </validationactionlist> </parametergroup>

Thanks, Reddy

asked 30 Jan '13, 13:42

laxmireddy's gravatar image

laxmireddy
1202020
accept rate: 0%


Reformatting the snippets in code sample:

    <choiceParameter>
        <name>DATABASE_TYPE</name>
        <title>Choose a database</title>
        <description></description>
        <explanation>Select database</explanation>
        <value></value>
        <default></default>
        <allowEmptyValue>0</allowEmptyValue>
        <cliOptionName>${project.shortName}_database</cliOptionName>
        <displayType>radiobuttons</displayType>
        <ordering>default</ordering>
        <width>40</width>
        <optionList>
            <option>
                <description></description>
                <image></image>
                <text>MSS</text>
                <value>MSS</value>
            </option>
            <option>
                <description></description>
                <image></image>
                <text>Oracle</text>
                <value>ORA</value>
            </option>
        </optionList>
        <validationActionList>
            <setInstallerVariable name="DBMS_DRIVER_CLASS_NAME" value="net.sourceforge.jtds.jdbc.Driver">
                <ruleList>
                    <compareText>
                        <logic>equals</logic>
                        <text>${DATABASE_TYPE}</text>
                        <value>MSS</value>
                    </compareText>
                </ruleList>
            </setInstallerVariable>
            <setInstallerVariable name="DBMS_DRIVER_CLASS_NAME" value="oracle.jdbc.driver.OracleDriver">
                <ruleList>
                    <compareText>
                        <logic>equals</logic>
                        <text>${DATABASE_TYPE}</text>
                        <value>ORA</value>
                    </compareText>
                </ruleList>
            </setInstallerVariable>
        </validationActionList>
    </choiceParameter>

    <parameterGroup>
        <name>CheckDatabaseConnectivity</name>
        <title>Check Database Connectivity</title>
        <explanation></explanation>
        <value></value>
        <default></default>
        <parameterList>
            <booleanParameter>
                <name>chk_database</name>
                <description>Check if you want to verify database connectivity</description>
                <explanation></explanation>
                <value>1</value>
                <default></default>
                <displayStyle>checkbox-left</displayStyle>
            </booleanParameter>
        </parameterList>
        <validationActionList>
            <runProgram>
                <program>${java_exe}</program>
                <programArguments> -cp <Classpath-with-db-jars>  com.acme.DatabaseConnectionAction  ${LOGID} ${LOGPASSWORD}  ${DATABASE_URL} ${DBMS_DRIVER_CLASS_NAME} </programArguments>
            </runProgram>
        </validationActionList>
    </parameterGroup>
link

answered 30 Jan '13, 13:46

laxmireddy's gravatar image

laxmireddy
1202020
accept rate: 0%

The parameter validations are not run in unattended mode. This is the reason for not detecting it.

What you should do is also run the same checks in <readyToInstallActionList> to double-check the parameter values - for example:

<readyToInstallActionList> <if> <actionList> <setInstallerVariable name="DBMS_DRIVER_CLASS_NAME" value="net.sourceforge.jtds.jdbc.Driver"> <ruleList> <compareText> <logic>equals</logic> <text>${DATABASE_TYPE}</text> <value>MSS</value> </compareText> </ruleList> </setInstallerVariable> <setInstallerVariable name="DBMS_DRIVER_CLASS_NAME" value="oracle.jdbc.driver.OracleDriver"> <ruleList> <compareText> <logic>equals</logic> <text>${DATABASE_TYPE}</text> <value>ORA</value> </compareText> </ruleList> </setInstallerVariable> <runProgram> <program>${java_exe}</program> <programArguments> -cp (Classpath-with-db-jars&gt;) com.acme.DatabaseConnectionAction ${LOGID} ${LOGPASSWORD} ${DATABASE_URL} ${DBMS_DRIVER_CLASS_NAME} </programArguments> </runProgram> </actionList> <conditionRuleList> <compareValues> <logic>does_not_equal</logic> <value1>${installer_interactivity}</value1> <value2>normal</value2> </compareValues> </conditionRuleList> </if> </readyToInstallActionList>

link

answered 31 Jan '13, 09:23

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

This works well, thanks. However, putting the Java class in readyToInstallActionList seems to be running the class twice.

Thanks, Reddy

(11 Feb '13, 10:38) laxmireddy

The reatyToInstall actions should only be run once. Is it possible it is in the XML twice? Also, is it in the project's or component's <readyToInstallActionList>?

Can you add a <showText> action to doublecheck that it is also run twice?

Does this also happen with latest (8.5.2) version of InstallBuilder? Also, does your project use <allowAddRemoveComponents> option?

(11 Feb '13, 12:05) wojciechka ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×36
×4

Asked: 30 Jan '13, 13:42

Seen: 1,383 times

Last updated: 11 Feb '13, 12:05