Search code examples
izpack

UserInputPanel variable modification Izpack


I have a variable="name" in my userInputSpec.xml . I use it to create the directory inside installation. $INSTALL_PATH/${name}

I want to remove the spaces supplied in the name before it triggers the installpanel. I do not want to restrict the user to enter the spaces.


Solution

  • In IzPack 5.0, you might use dynamic variables with a regexp filter for it, see http://docs.codehaus.org/display/IZPACK/Dynamic+Variables:

    <conditions>
      <condition id="nameIsSet" type="exists">
        <variable>name</variable>
      </condition>
    </conditions>
    
    <dynamicvariables>
      <variable name="name.nospace" value="${name}" checkonce="true" condition="nameIsSet">
        <filters>
          <regex regexp="\s+"
                 replace=""
                 defaultValue="${name}"
                 global="true"/>
        </filters>
      </variable>
    </dynamicvariables>
    

    In this case, ${name.nospace} might be the variable to reuse, which would be set once the ${name} variable is set (and never changed after that).