Say I want the user to be able to specify several server settings on a custom page. I have all my validation actions working well for this page, such as the server port seen below. The only parameter that seems to be having validation issues is the number of threads setting. It always evaluates to true and does not warn the user, even if the value is out of range. I use a stringParameter for the maximum number of threads and then compare that to the stringParameter of user input number of threads, as follows.

...
    <parameterList>
        <!-- Hidden string parameters for custom variables -->
        <stringParameter name="server_threads_max" value="255" ask="0" />
...
                              <parameterList>
                                    <stringParameter>
                                        <name>server_port</name>
                                        <description>Port</description>
                                        <default>6666</default>
                                        <allowEmptyValue>0</allowEmptyValue>
                                        <width>20</width>
                                        <validationActionList>
                                            <showWarning>
                                                <text>Cannot bind to port ${server_port}.</text>
                                                <ruleList>
                                                    <portTest condition="cannot_bind" port="${server_port}" />
                                                </ruleList>
                                            </showWarning>
                                        </validationActionList>
                                    </stringParameter>
                                    <stringParameter>
                                        <name>server_threads</name>
                                        <description>Number of Threads</description>
                                        <default>${machine_cpu_count}</default>
                                        <allowEmptyValue>0</allowEmptyValue>
                                        <width>10</width>
                                        <validationActionList>
                                            <showWarning>
                                                <text>Invalid thread option.  The number of threads must be greater than 0 and less than ${server_threads_max}.</text>
                                                <ruleList>
                                                        <compareValues>
                                                            <logic>greater</logic>
                                                            <value1>${server_threads)</value1>
                                                            <value2>${server_threads_max}</value2>
                                                        </compareValues>
                                                        <compareValues>
                                                            <logic>less_or_equal</logic>
                                                            <value1>${server_threads}</value1>
                                                            <value2>0</value2>
                                                        </compareValues>                                            
                                                </ruleList>
                                            </showWarning>                                              
                                        </validationActionList>
                                    </stringParameter>
                                </parameterList>
    ...

Is there something wrong with the way I am using compareValues here? Should server_threads and server_threads_max not be stringParameters? I need the ability to set server_threads_max at build time. Testing this validation code in the debugger, using "Evaluate XML Code" during this custom page seemed to work as I expected (popping up a dialog if invalid input). But, the installer itself, always evaluates this to true and never shows the warning.

More Info

So, testing this out, wojciechka is correct that this should be "or" logic. However, the greater than comparison still fails, even on its own. Stepping through the debugger, it doesn't even appear to evaluate this rule. This is using Enterprise 8.1.0 builder-cli.exe.

...
<ruleList>
    <compareValues>
        <logic>greater_or_equal</logic>
        <value1>${ls_server_threads)</value1>
        <value2>${ls_server_threads_max}</value2>
    </compareValues>
</ruleList>
...

asked 03 Apr '12, 22:44

DevHopeful_2012's gravatar image

DevHopeful_2012
176131521
accept rate: 9%


By default multiple rules are evaluated so that the action is run when all actions are true. You can change it by adding <ruleEvaluationLogic>or</ruleEvaluationLogic>. For your example it would be:

              <parameterList>
                <stringParameter>
                  <name>server_port</name>
                  <description>Port</description>
                  <default>6666</default>
                  <allowEmptyValue>0</allowEmptyValue>
                  <width>20</width>
                  <validationActionList>
                    <showWarning>
                      <text>Cannot bind to port ${server_port}.</text>
                      <ruleList>
                        <portTest condition="cannot_bind" port="${server_port}" />
                      </ruleList>
                    </showWarning>
                  </validationActionList>
                </stringParameter>
                <stringParameter>
                  <name>server_threads</name>
                  <description>Number of Threads</description>
                  <default>${machine_cpu_count}</default>
                  <allowEmptyValue>0</allowEmptyValue>
                  <width>10</width>
                  <validationActionList>
                    <showWarning>
                      <text>Invalid thread option.  The number of threads must be greater than 0 and less than ${server_threads_max}.</text>
                      <ruleEvaluationLogic>or</ruleEvaluationLogic>
                      <ruleList>
                          <compareValues>
                            <logic>greater</logic>
                            <value1>${server_threads)</value1>
                            <value2>${server_threads_max}</value2>
                          </compareValues>
                          <compareValues>
                            <logic>less_or_equal</logic>
                            <value1>${server_threads}</value1>
                            <value2>0</value2>
                          </compareValues>                      
                      </ruleList>
                    </showWarning>                        
                  </validationActionList>
                </stringParameter>
              </parameterList>
link

answered 04 Apr '12, 03:58

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

You are absolutely right. For some reason I had it stuck in my head that the logic was correct. I knew that the default ruleEvaluationLogic was "and". But, I just missed the fact that the math logic was "or".

But...

This almost worked. The server_threads > server_threads_max is not evaluating correctly, even though the warning message displays the max as 255. Any ideas? Does compareValues treats both values as integers even though these are stringParameter's?

(04 Apr '12, 14:40) DevHopeful_2012
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:

×2
×2

Asked: 03 Apr '12, 22:44

Seen: 881 times

Last updated: 04 Apr '12, 15:07