View Full Version : how do you validate fields in custom panels?

05-26-2004, 07:24 PM
I have created a simple panel that has a username field, a password field, and a password confirm field.

When the user selects "next" I want to validate the fields to ensure:

1) The username field is 8 chars or greater
2) The password field is 8 chars or greater
3) The password confirm field value matches the password field value.

how do I do this?


05-27-2004, 04:35 PM
an thread that I had with a support personal on this issue:

Chirag Shah: Mike,

I understand your concern. But as you know the only way to validate the input would be to write a event for your dialog and implement the queryExit() event here. Basically you can just copy the code for checking the input in both swing and console events which I believe should not be an big thing to do. Only when you display a message to the user the code would change. This would be the case even when you write the validator classes in 5. Also silent mode will not require any of this as there will not be any user interaction.

Please let me know if you need further assistance regarding this.
Thanks 05/27/04, 11:40 AM PDT
Michael Hollander (c): Can you explain your answer in a bit more detail? What is the "queryExit()" event? How do I find it using the IDE? Would I write one validator and then import it into both the console and swing events area? Then in queryExitI) I could call the method from my custom validator? Where is this documented in the help documentatino? I'm struggling a bit here b/c I can't find any documentation on this type of thing anywhere.

thanks for teh response,
mike. 05/27/04, 11:45 AM PDT
Chirag Shah: Mike,

If you go to Installation Designer -> User Interface -> Dialogs, you can edit your dialogs here. If you highlight any of your dialogs here, you will see a Context and Event section on the right. If you select Dialog as the context and use the drop down menu for selecting event you would see a queryExit() event over here. Basically this method would be called when the dialog is exited. So, in this event you can get the value of the variable as $V(variablename) which the user enters and check for necessary validations in this method. You can copy the same code in the queryExit event for console events. You do not have to write any custom validator or call any method from there.

I also tried to call you but was not able to reach you. Please let me know if you need further assistance regarding this or you can just call the support number and mention the service request no. there.
Thanks 05/27/04, 12:57 PM PDT
Michael Hollander (c): Thank you. A few more questions associated with this.
1) It makes sense to me to write a custom validator class that will have several different validator methods. I can then use the methods in this class in several different dialogs as well as in several different installshield projects that I will be creating. How can I write custom java code and then include it in my project? If there are any docs on how to do this, I would be happy to be pointed at them and work from there.
2) Are there any javadocs/apis for installshield available? I will need to know how to do things like:
* popup a message to the user that the data in the field was invalid
* return to the dialog instead of exitingif the fields aren't valid

mike. 05/27/04, 1:08 PM PDT
Chirag Shah: Mike,

If you go to the Home Directory where InstallShield X is installed and then go to Universal Installer -> Advanced API, there is a index.html document will displays a javadoc for InstallShield APIs. However popping up a message or returning a dialog will be purely Java based and you can refer to java api for the same.

For using your own class you would need to put your class in a package then compile your java class and put the class file in the classes directory with the same package hierarchy. Then from the Universal Installer IDE you will need to go to Tools -> Options -> Compiler Options and add the class path where this class exists. Then in the event where you want to use this class you would need to import the package and use this class. Unfortunately at this point there is no documentation available for this.

Please let me know if you need further assistance regarding this.
Thanks 05/27/04, 1:58 PM PDT
Michael Hollander (c): Chirag - Thanks. You basically answered all of my questions. I'm still unclear, though, on how I would return to the dialog that I was just on if one of the field validations fail.

mike. 05/27/04, 2:02 PM PDT
Chirag Shah: Mike,

Well when you write you code in the queryExit() method if the validation fails you will set the return value as false. eg. arg0.setReturnValue(false); or arg0.setReturnValue(true) where arg0 is the default argument passed in the queryExit method. Based on the return value you set here the panel will either exit or not.

Please let me know if you need further assistance regarding this.
Thanks 05/27/04, 2:07 PM PDT
Michael Hollander (c): thanks for the speedy response.

and this will work in the console event as well?

mike. 05/27/04, 2:11 PM PDT
Chirag Shah: Yes, the only code that will change in your console event is how you display the message to the user.