Hi all,
I need to validate a user input (string) value in my custom form. I need to check if the value entered is already present in the docbase table or not. Please let me know on how to create a validator class and use it in my form.
TIA,
Shiv
Hi,
You can create a custom validator, see forms builder development guide.
There is a sample,
public class EmailAddressValidator extends ItemValidator implements IStringValidator { public boolean validateString(String value) throws AdaptorException { int index = value.indexOf("@); int index1 = value.lastIndexOf(."); boolean retval = true; if ( index == -1 || index1 == -1 || index1 < index ) { retval = false; } return retval; } public void init(IAdaptorConfiguration iAdaptorConfiguration) throws AdaptorException {} // No initialization needed public void destroy() throws AdaptorException {} // Nothing to destroy}
Hope that helps
Imran,
Thanks.
But i am looking on how to create a docbase session in my validator class. Should I create a docbase session explicitly?
Please read the Forms Builder Development guide. It has details on how to create validators as well as how to get session from the form.
There is a method called getSessionManager() in DocbaseXFormsContext class, you can use it to obtain a session.
But as Johnny suggests please read the development guide.