<!-- (And this is an example of a Page displaying a specific category by using the previously shown Information Template. We will show in more detail how to create and use Information Templates later on)
Display Page Templates | Information Templates | |
---|---|---|
Supports Assets | ❌ | ✅ |
Display Page Templates | Information Templates | |
---|---|---|
Editing Mode | Visual 👁️ | Freemarker <#> |
Display Page Templates | Information Templates | |
---|---|---|
Page |
Whole | Portion |
Dedicated URL |
✅ | ❌ |
1) Implement InfoItemDetailsProvider
2) Add InfoFieldSet to InfoForm in InfoItemFormProvider
3) Add InfoFieldValue to InfoItemFieldValues in InfoItemFieldValuesProvider
4) Implement InfoItemCapabilitiesProvider
@Component(immediate = true, service = InfoItemDetailsProvider.class)
public class MyEntityInfoItemDetailsProvider
implements InfoItemDetailsProvider<MyEntity> {
@Override
public InfoItemClassDetails getInfoItemClassDetails() {
return new InfoItemClassDetails(MyEntity.class.getName());
}
@Override
public InfoItemDetails getInfoItemDetails(MyEntity myEntity) {
return new InfoItemDetails(
getInfoItemClassDetails(),
new InfoItemReference(MyEntity.class.getName(), myEntity.getId()));
}
}
@Component(immediate = true, service = InfoItemFormProvider.class)
public class MyEntityInfoItemFormProvider
implements InfoItemFormProvider<MyEntity> {
@Override
public InfoForm getInfoForm() {
return InfoForm.builder(
).infoFieldSetEntry(
InfoFieldSet.builder(
).infoFieldSetEntry(
// ... other fields available for mapping and templates
).infoFieldSetEntry(
_templateInfoItemFieldSetProvider.getInfoFieldSet(
MyEntity.class.getName())
).labelInfoLocalizedValue(
InfoLocalizedValue.localize(
MyEntityInfoFields.class, "myEntity")
).build()
).name(
"MyEntity"
).build();
}
@Reference
private TemplateInfoItemFieldSetProvider _templateInfoItemFieldSetProvider;
}
@Component(immediate = true, service = InfoItemFieldValuesProvider.class)
public class MyEntityInfoItemFieldValuesProvider
implements InfoItemFieldValuesProvider<MyEntity> {
@Override
public InfoItemFieldValues getInfoItemFieldValues(MyEntity myEntity) {
List<InfoFieldValue<Object>> infoFieldValues = new ArrayList<>();
// ...
infoFieldValues.addAll(
_templateInfoItemFieldSetProvider.getInfoFieldValues(
MyEntity.class.getName(), myEntity));
return InfoItemFieldValues.builder(
).infoFieldValues(
infoFieldValues
).infoItemReference(
new InfoItemReference(MyEntity.class.getName(), myEntity.getId())
).build();
}
@Reference
private TemplateInfoItemFieldSetProvider _templateInfoItemFieldSetProvider;
}
@Component(service = InfoItemCapabilitiesProvider.class)
public class MyEntityInfoItemCapabilitiesProvider
implements InfoItemCapabilitiesProvider<MyEntity> {
@Override
public List<InfoItemCapability> getInfoItemCapabilities() {
return ListUtil.fromArray(_templatePageInfoItemCapability);
}
@Reference
private TemplateInfoItemCapability _templatePageInfoItemCapability;
}