[izpack-users] How to use validations in TargetPanel?
Miraodb
miraodb at hotmail.com
Wed Mar 29 13:50:50 CEST 2006
Hi,
You can't do that using the normal targetpanel.
You would have to use a custom panel to do the trick.
Here is the one i use:
/*
* Created on 29.06.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.izforge.izpack.panels;
import com.izforge.izpack.installer.InstallData;
import com.izforge.izpack.installer.InstallerFrame;
/**
* @author fabrice mirabile
*/
public class NonBlankTargetPanel extends TargetPanel
{
private static final long serialVersionUID = 3248705610571943817L;
public NonBlankTargetPanel(InstallerFrame parent, InstallData idata)
{
super(parent, idata);
}
public boolean isValidated()
{
String chosenPath = pathSelectionPanel.getPath();
if(chosenPath == null || chosenPath.length() < 1 )
return( false );
if( chosenPath.indexOf(" ") >= 0 )
{
emitError(parent.langpack.getString("installer.error"),
parent.langpack.getString("NonBlankTargetPanel.noBlanks"));
return( false );
}
return(super.isValidated() );
}
public void panelActivate()
{
super.panelActivate();
String chosenPath = pathSelectionPanel.getPath();
if(chosenPath == null || chosenPath.length() < 1 )
return;
if( chosenPath.indexOf(" ") >= 0 )
pathSelectionPanel.setPath("");
}
}
To use it:
Create NonBlankTargetPanel.java file with this code in it.
Add it to the izpack-src\src\lib\com\izforge\izpack\panels folder.
Add the following tagert rule into the ant build.xml:
<build-panel name="NonBlankTargetPanel">
<include name="com/izforge/izpack/panels/PathInputPanel.java"/>
<include
name="com/izforge/izpack/panels/PathSelectionPanel.java"/>
<include name="com/izforge/izpack/panels/TargetPanel.java"/>
<include
name="com/izforge/izpack/panels/TargetPanelAutomationHelper.java"/>
<include
name="com/izforge/izpack/panels/NonBlankTargetPanel.java"/>
</build-panel>
Then run ant clean, ant all.
Now you can use this new panel as follows in install.xml:
<panel classname="NonBlankTargetPanel"/>
instead of <panel classname="TargetPanel"/>
Hope that helps,
Fabrice
----- Original Message -----
From: "sagar shah" <sagarbs at gmail.com>
To: <izpack-users at berlios.de>
Sent: Wednesday, March 29, 2006 1:42 PM
Subject: [izpack-users] How to use validations in TargetPanel?
Hi all,
I am using TargetPanel of Izpack.But I want to use validations for it e.g.
like i dont want my users tio enter the directory name with space in
between. So how i can i restrict the users from doin this. I
Please help me.
Thanking in advance.
Sagar Shah.
email : sagarbs at gmail.com
More information about the izpack-users
mailing list