Class PropertiesMap
java.lang.Object
org.onehippo.forge.properties.bean.PropertiesMap
Bean representing a properties document that holds a map of name/value pairs.
In an HST Component, a bean like this can be created with a PropertiesBean object
as argument and subsequently set on the request for access in jsp.
Example 1:
// get a document named "properties" at same level as current bean
Properties propertiesDoc = this.getContentBean(request).getParentBean().getBean("properties", Properties.class);
if (propertiesDoc != null) {
request.setAttribute("properties", new PropertiesMap(new PropertiesBean(propertiesDoc)));
}
Example 2:
There is also a Spring instantiated PropertiesManager present with which
beans can be gotten from content:
ComponentManager componentManager = HstServices.getComponentManager();;
this.propertiesManager = componentManager.getComponent(PropertiesManager.class.getName());
Map<String, String> properties = new PropertiesMap(this.propertiesManager.getPropertiesBean(this.getSiteContentBaseBean(request)));
Example 3:
There is also a static utility class that creates PropertiesMaps.
Map<String, String> properties = PropertiesUtil.toMap(this.propertiesManager.getPropertiesBean(this.getSiteContentBaseBean(request)));
Because it is a map, access in jsp can be done using direct expression
language notation like "labels['label.header']"-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPropertiesMap
(Collection<PropertiesBean> propertiesCol) Create a new map with multiple properties beans.PropertiesMap
(PropertiesBean properties) Create a new map with a properties bean. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
isEmpty()
keySet()
void
int
size()
values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
PropertiesMap
Create a new map with a properties bean. -
PropertiesMap
Create a new map with multiple properties beans. Note that properties are not overwritten, so in case of duplicates the first entered remains!
-
-
Method Details
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
String>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
String>
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
-
put
-
putAll
-
remove
-
size
public int size() -
values
-