Radiobuttons in Component Selection Page

Answered

Comments

3 comments

  • Avatar
    juanjo

    Regarding the first question, do you mean to present the child components as radiobuttons so just one can be selected? If so, it is not possible but you could hide the childs and us a <choiceParameter> in a regular page as explained in the second example of this section.

    About the visibility, you could use the below code:

    <preInstallationActionList>
        <setInstallerVariable>
            <name>component(nonEnglish).show</name>
            <value>0</value>
            <ruleList>
                <compareText>
                    <logic>equals</logic>
                    <text>${installation_language_code}</text>
                    <value>en</value>
                </compareText>
            </ruleList>
        </setInstallerVariable>
        <actionGroup>
            <actionList>
                <setInstallerVariable>
                    <name>component(componentA).show</name>
                    <value>0</value>
                </setInstallerVariable>
                <setInstallerVariable>
                    <name>component(componentB).show</name>
                    <value>0</value>
                </setInstallerVariable>
                <setInstallerVariable>
                    <name>component(componentC).show</name>
                    <value>0</value>
                </setInstallerVariable>
            </actionList>
            <ruleList>
                <compareText>
                    <logic>does_not_equal</logic>
                    <text>${installation_language_code}</text>
                    <value>en</value>
                </compareText>
            </ruleList>
        </actionGroup>
    </preInstallationActionList>
    

    It will hide the components componentA, componentB and componentC if the selected language is not English.

  • Avatar
    Vertius

    First question - Yes, I want to display child components as radiobuttons. I'm really surprise that you can't define component group display type/style. Can I do this using rules (If component A is selected, then deselect components B i C etc.)?

    Second question - Thanks :) Can I hide and deselect them at the same time?

  • Avatar
    juanjo

    It is not possible to automatically deselect the other child components when the user clicks but you could use the <componentSelectionValidationActionList> to make sure the user do not select multiple childs and even disable all but one:

     <componentGroup>
        <name>parent</name>
        <description>Parent Component</description>
        <componentList>
           <component>
              <name>childA</name>
               <description>Child A</description>
           </component>
           <component>
              <name>childB</name>
               <description>Child B</description>
           </component>
               <component>
              <name>childC</name>
               <description>Child C</description>
           </component>
        </componentList>
        ...
        <componentSelectionValidationActionList>
           <setInstallerVariable name="selected" value=""/>
           <setInstallerVariable name="multiple_selection" value="0"/>
           <foreach>
              <variables>child</variables>
              <values>childA childB childC</values>
              <actionList>
                  <actionGroup>
                      <actionList>
                         <actionGroup>
                             <actionList>
                                <setInstallerVariable name="multiple_selection" value="1"/>
                                <setInstallerVariable name="project.component(parent).component(${child}).selected" value="0"/>
                                <continue/>
                             </actionList>
                              <ruleList>
                                  <compareText text="${selected}" logic="does_not_equal" value=""/>
                               </ruleList>
                           </actionGroup>
                        <setInstallerVariable name="selected" value="${child}"/>
                     </actionList>
                     <ruleList>
                           <isTrue value="${project.component(parent).component(${child}).selected}"/>
                      </ruleList>
                  </actionGroup>
           </actionList>
        </foreach>
          <throwError>
            <text>You cannot select multiple child components. Just ${selected} will be selected</text>
            <ruleList>
                 <isTrue value="${multiple_selection}"/>
            </ruleList>
          </throwError>
           <throwError>
            <text>You must select at least one child</text>
            <ruleList>
                 <compareText text="${selected}" logic="equals" value=""/>
            </ruleList>
          </throwError>
        </componentSelectionValidationActionList>
        ...
      </componentGroup>
    

    About selecting and deselecting, you could use the below code:

    <actionGroup>
         <actionList>
                <setInstallerVariable>
                    <name>component(componentA).show</name>
                    <value>0</value>
                </setInstallerVariable>
                    <setInstallerVariable>
                    <name>component(componentA).selected</name>
                    <value>0</value>
                </setInstallerVariable>
         </actionList>
          <ruleList>
                <compareText>
                    <logic>does_not_equal</logic>
                    <text>${installation_language_code}</text>
                    <value>en</value>
                </compareText>
            </ruleList>
     </actionGroup>
    

Please sign in to leave a comment.