com.sap.portal.admin.wizard.validators
Interface IValidator

All Known Implementing Classes:
ObjectIdValidator

public interface IValidator

Validating panes input is done using classes implementing this interface. First usage of is shown in the visible panes com.sap.portal.admin.wizard.panes.InfoPane, com.sap.portal.admin.wizard.panes.PageLayoutsPane

(panes that extend com.sapportals.admin.wizardframework.components.GridContainer, com.sapportals.admin.wizardframework.components.FlowContainer or com.sapportals.admin.wizardframework.components.HTMLScriptComponent).

Implementation of the API method com.sapportals.admin.wizardframework.components.AbstractWizardComponent.getErrorMessages(IWizardContext) by such panes should use this API which keeps the syntax plain and simple.

Usage example:

 public List getErrorMessages(IWizardContext ctx)
 {
 		PageLayoutsValidator validator = new PageLayoutsValidator();
		StringBuffer validatorKey = new StringBuffer(getPath())
									.append(PageLayoutsPane.LAYOUTS_AVAILABLE_LIST_KEY) 
									.append(WizardSession.PATH_SEPERATOR) 
 									.append(MultiSelectionComponent.VALUE);
		if (!validator.isValid(validatorKey.toString(), ctx))
		{
			List errKeyList = validator.getErrorKeyList(ctx);
			LinkedList errValList = new LinkedList();
			for (Iterator iter = errKeyList.iterator(); iter.hasNext();) 
			{
				String key = (String) iter.next();
				errValList.add(_basicObjService.getBundleString(key, ctx));
			}
			return errValList;
		}
 } 
 
You should always call the isValid method and provide the key for the input you want to check. You can use the key argument to get values from the wizard session, or other purposes(some other internal or external use). Typically, each IValidator implementor should do its validations on a single parameter, such as the object ID or selected layouts. Finally, if something is wrong get the error list from the implementor that holds bundle keys to get the error messages from the resource bundle.


Method Summary
 java.util.List getErrorKeyList(IWizardContext context)
          Get a list that holds the resource bundle keys for the collected errors in case the validity check failed.
 boolean isValid(java.lang.Object key, IWizardContext context)
          Checks to see if the required field/input/key/value is valid/correct/any other check.
 

Method Detail

isValid

public boolean isValid(java.lang.Object key,
                       IWizardContext context)
Checks to see if the required field/input/key/value is valid/correct/any other check.
Parameters:
key - the key to check upon.
context - wizard context.
Returns:
True if everything ok, false otherwise.

getErrorKeyList

public java.util.List getErrorKeyList(IWizardContext context)
Get a list that holds the resource bundle keys for the collected errors in case the validity check failed.
Parameters:
context - wizard context
Returns:
Error list, empty list if no errors were found.