[izpack-devel] Dynamic controls&validation in UserInputPanel

Vladimir Ralev vralev at redhat.com
Wed Mar 14 11:38:18 CET 2007


I will need some help with the docs. Which files should I update and 
should I use a special editor?
In the mean time here is it in plain text. There is an important note at 
the end, you may want to highlight it, it's a limitation I realized 
today, I'll see if it can be fixed without sacrificing something:

Dynamic validation of controls

You can add revalidate="yes" attribute to checkbox and radio controls in 
the UserInputPanel specification to force a redraw of all fields in the 
current panel, including controls associated with a condiotionid. This 
is useful if you need to show or hide particular set of controls 
depending on the current state of other controls on the panel.

Sample checkbox declaration:
      <field type="check" variable="var">
         <spec txt="Some text" revalidate="yes" id="text" set="true" 
size="32" true="true" false="false"/>
      </field>

Sample radio declaration:
      <field type="radio" variable="installConfig">
         <description align="left" txt="Select Standard installation or 
select Advanced to make changes"
            id="installConfig.text"/>
         <spec>
           <choice txt="Standard" revalidate="yes" 
id="installConfig.radio.standard" value="standard"  set="true"/>        
           <choice txt="Advance" revalidate="yes" 
id="installConfig.radio.advanced" value="advanced" />          
         </spec>
      </field>

By default the panels are placed on the vertical center of the available 
space. With dynamic showing/hiding of fields this causes your panel to 
move up and down depending on it's height. To avoid this behavior, 
declare your panel with attribute topBuffer="0". See the following example:
   <panel order="0" topBuffer="0">
      <field type="radio" variable="installConfig">
         <description align="left" txt="Select Standard installation or 
select Advanced to make changes"
            id="installConfig.text"/>
         <spec>
           <choice txt="Standard" revalidate="yes" 
id="installConfig.radio.standard" value="standard"  set="true"/>        
           <choice txt="Advance" revalidate="yes" 
id="installConfig.radio.advanced" value="advanced" />          
         </spec>
      </field>     
      <field type="divider" align="center"/>
      <field type="combo" conditionid="advanced" variable="database">
         <description align="left" txt="Select Database" 
id="database.text"/>
         <spec>
           <choice txt="DB2-400" id="combo.db2-400" value="db2-400"/>
           <choice txt="DB2" id="combo.db2-ds" value="db2"/>
         </spec>
      </field>
   </panel>

There are two radio buttons that cause revalidation 
(installConfig.radio.standard and installConfig.radio.advanced) and one 
combo box which is only displayed when the condition called "advanced" 
is satisfied. The condition "advanced" depends on the variable 
"installConfig":
        <condition type="variable" id="advanced">
                <name>installConfig</name>
                <value>advanced</value>
        </condition>

Each time the user clicks on one of the radio buttons the variable 
"installConfig" changes, and with it the condition "advanced" is either 
satisfied or not. Since the combo is revalidated with each click 
(together with all other components) it's being hidden or shown based on 
the condition.

IMPORTANT NOTE: All controls that cause revalidation must be declared 
before any conditionaly displayed controls. This is because the order of 
evaluation of the variables follows the order of declaration. If you 
declare your conditionaly displayed control before a control associated 
with a variable it depends on, the conditionaly displayed controls will 
not be able to see the updated variable and will use the previous value 
(before the revalidation).

Julien Ponge wrote:
> Hi Vladimir,
>
>   
>> If you approve this feature I will commit it to the trunk or the 3.10.1
>> branch (it's just 20 lines of code)?
>>     
>
> * +1, that would be great.
> * This would go to the trunk.
> * Do not forget to update the documentation else it won't be useful ;-)
>
> Cheers
> _______________________________________________
> izpack-devel mailing list
> izpack-devel at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/izpack-devel
>   



More information about the izpack-devel mailing list