Cmobilecom AF 5.19 Developer Guide

7.9 Auto Complete

When a user starts typing in an input text field, a list of suggestions will drop down for the user to select. By default, input of a PersistenceEntity instance is autoComplete enabled. For example, Employee is a PersistenceEntity, so typing partial employee id or name will trigger drop down of suggestions.

Property annotations


	@Property(...
		renderStyle=@RenderStyleDef(autoComplete=false, minQueryLength=1, forceSelection=false))
By default, autoComplete is not enabled except for PersistenceEntity type. minQueryLength specifies how many characters will triger drop down of suggestions, and forceSelection specifies whether the selection from suggestions is required.

For PersistenceEntity type, the query criteria of suggestions for an EntityProperty is built from the following

Property selectPropertyQueryElements is used to build the query criteria for its value selections, and it can be specified using property annotations:

	@Property(...
		dynamicSelectQuery=false, selectQuery={PropertyCriterion})

Method Overrides

If property selectQuery is dynamic, its EntityBackingBean needs to override

	public CriteriaElement[] getDynamicSelectPropertyQueryElements(PersistenceDataBackingBean<T> backingBean, 
		T entity, EntityProperty<T> property) throws SystemException {
		// return an array of CriteriaElements that is used to build query criteria
	}
By default, entity property id and name are used to match the user input. Its EntityBackingBean can override the following method to provide the CriteriaElement (boolean) for retrieving entities as suggestions. The CriteriaExpression will be combined with the selectQuery (AND relation).

	@Override
	public <E extends PersistenceEntity> CriteriaExpression<Boolean> getAutoCompleteQueryElement(
			PersistenceDataBackingBean<E> backingBean, E entity, 
			EntityProperty<E> property, String userInput) throws SystemException {
	}
For non-PersistenceEntity type, its EntityBackingBean needs to override the following method to provide a list of suggestion for the user input.

	@Override
	public List<String> getAutoCompleteSuggestions(PersistenceDataBackingBean<T> backingBean, T entity, 
			EntityProperty<T> property, String userInput) throws SystemException {
		// return a list of string as suggestions
	}
View ConfigQuery BeanFrames / No Frames