Interface GomIncludeValueProvider<T>


public interface GomIncludeValueProvider<T>
Hot-spot interface to provide a list of values for input components.

Some input components (e.g. CMS_INPUT_COMBOBOX) support an arbitrary list of values the user can choose from. This value list can be injected by an INCLUDE tag inside the GOM xml:

  <CMS_INCLUDE_OPTIONS type="public">
     <NAME>public_name</NAME>
     <PARAMS>
         <PARAM name="key1">value1</PARAM>
         <PARAM name="key2">value2</PARAM>
     </PARAMS>
  </CMS_INCLUDE_OPTIONS>
 
The paramters are provided to instances of type Parameterizable by a setParameters-call.
Since:
4.2
Example:
This is a basic example
import de.espirit.firstspirit.access.store.templatestore.gom.*;

import de.espirit.firstspirit.access.Language;
import de.espirit.firstspirit.agency.LanguageAgent;
import de.espirit.firstspirit.agency.SpecialistsBroker;

import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Map;


public class LanguageValueProviderExample implements GomIncludeValueProvider<Language>, Parameterizable {

	/**
	 * The generic gom-parameters. The field is not read in this example.
	 *
	 * @see #setParameters(java.util.Map)
	 */
	private Map<String, String> _parameters;


	@NotNull
	public Class<Language> getType() {
		return Language.class;
	}


	@NotNull
	public List<Language> getValues(@NotNull final SpecialistsBroker broker) {
		return broker.requireSpecialist(LanguageAgent.TYPE).getLanguages();
	}


	@NotNull
	public String getKey(@NotNull final Language value) {
		return value.getAbbreviation();
	}


	/**
	 * Receives the generic gom-parameters. The parameters itself are not used in this example.
	 *
	 * @param parameters The key-mapped parameters.
	 */
	public void setParameters(@NotNull final Map<String, String> parameters) {
		_parameters = parameters;
	}

}