Class CMSComponent
java.lang.Object
io.goobi.viewer.model.cms.pages.content.CMSComponent
- All Implemented Interfaces:
Serializable,Comparable<CMSComponent>
Represents a reusable UI component on a CMS page, combining a JSF component reference with
ordered content items, display metadata, and optional access restrictions.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAdditional properties that can be passed to the component to set certain behaviour. -
Constructor Summary
ConstructorsConstructorDescriptionCMSComponent(CMSComponent template, List<CMSContentItem> items) CMSComponent(CMSComponent template, Optional<PersistentCMSComponent> jpa) CMSComponent(JsfComponent jsfComponent, String label, String description, List<String> types, String templateFilename, CMSComponentScope scope, Map<String, CMSComponentAttribute> attributes, List<CMSComponent.Property> properties, Integer order) Constructor to create Component from template file. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddContentItem(CMSContentItem item) int<T extends CMSContent>
List<T> getAllContentOfType(Class<? extends CMSContent> clazz) getAttribute(String key) getAttributeValue(String key) booleangetBooleanAttributeValue(String key, boolean defaultValue) getContent(String itemId) getContentData(String itemId) getContentData(String itemId, Integer width, Integer height) getContentItem(String componentId) getFirstContentItem(String className) <T extends CMSContent>
TgetFirstContentOfType(Class<? extends CMSContent> clazz) getLabel()getOrder()longgetScope()getTypes()booleanbooleanhasContent(String itemId) Checks whether a contentItem with the given itemId exists and is not empty.booleanhasProperty(CMSComponent.Property property) booleanisPaged()booleanbooleanReturns whether this component should be displayed when the owning page is embedded in another page, rather than on the owning page itself.booleanbooleanbooleanvoidsetAttribute(String key, String value) voidsetBackendUiComponent(UIComponent backendUiComponent) voidsetOrder(int order) voidsetPreview(boolean preview) Sets whether this component should be displayed when the owning page is embedded in another page, rather than on the owning page itself.voidsetPrivate(boolean privat) voidsetPublicationState(ContentItemPublicationState publicationState) voidsetPublished(boolean published) voidsetScope(CMSComponentScope scope) voidsetUiComponent(UIComponent uiComponent) voidtoggleAttribute(String key, String value) voidvoidtoString()
-
Constructor Details
-
CMSComponent
- Parameters:
template- the component to copy structure fromitems- content items to populate the new component with
-
CMSComponent
- Parameters:
template- the component to copy structure and configuration fromjpa- optional persistentComponent to load persisted data from
-
CMSComponent
public CMSComponent(JsfComponent jsfComponent, String label, String description, List<String> types, String templateFilename, CMSComponentScope scope, Map<String, CMSComponentAttribute> attributes, List<CMSComponent.Property> properties, Integer order) Constructor to create Component from template file.- Parameters:
jsfComponent- the JSF component used to render this CMS componentlabel- human-readable display label of the componentdescription- short description of the component's purposetypes- list of category type strings for the component selection menutemplateFilename- filename of the component templatescope- visibility scope of the componentattributes- map of configurable component attributesproperties- list of additional behaviour propertiesorder- display order position of the component
-
-
Method Details
-
getPersistentComponent
-
setPublicationState
- Parameters:
publicationState- the publication state to set on the persistentComponent
-
getPublicationState
-
setOrder
public void setOrder(int order) - Parameters:
order- display order position of this component on the page
-
getOrder
-
addContentItem
- Parameters:
item- the content item to add to this component- Returns:
- true if item added successfully; false otherwise
-
removeContentItem
- Parameters:
item- the content item to remove from this component- Returns:
- true if item removed successfully; false otherwise
-
getContentItems
-
getFirstContentItem
-
getFirstContentOfType
-
getAllContentOfType
-
getFirstContentItem
-
getContentItem
-
getTranslatableContentItems
-
getJsfComponent
-
getLabel
-
getDescription
-
getTemplateFilename
-
isPageScope
public boolean isPageScope() -
compareTo
- Specified by:
compareToin interfaceComparable<CMSComponent>
-
getUiComponent
- Throws:
PresentationException
-
setUiComponent
- Parameters:
uiComponent- the frontend JSF UI component to set
-
getBackendUiComponent
- Throws:
PresentationException
-
setBackendUiComponent
- Parameters:
backendUiComponent- the backend JSF UI component to set
-
getAttribute
- Parameters:
key- attribute name to look up- Returns:
CMSComponentAttribute
-
getBooleanAttributeValue
- Parameters:
key- attribute name to look updefaultValue- value returned when attribute is absent- Returns:
- the boolean attribute value for the given key, or
defaultValueif no such attribute is set
-
getAttributeValue
- Parameters:
key- attribute name to look up- Returns:
String
-
setAttribute
- Parameters:
key- name of the attribute to setvalue- new string value to assign to the attribute
-
toggleAttribute
- Parameters:
key- name of the attribute to togglevalue- value to set, or clear if already set
-
getAttributes
-
isPublished
public boolean isPublished() -
setPublished
public void setPublished(boolean published) - Parameters:
published- true to publish the component; false to restrict to admins
-
isPrivate
public boolean isPrivate() -
setPrivate
public void setPrivate(boolean privat) - Parameters:
privat- true to restrict component visibility to admins
-
togglePrivate
public void togglePrivate() -
togglePublished
public void togglePublished() -
hasAccess
- Parameters:
user- the user whose access rights to check; may be null- Returns:
- true if the component is published, or if the given user is a CMS admin, false otherwise
-
getContentData
- Parameters:
itemId- ID of the content item to retrieve data for- Returns:
String
-
getContentData
- Parameters:
itemId- ID of the content item to retrieve data forwidth- optional width constraint passed to the content's getData methodheight- optional height constraint passed to the content's getData method- Returns:
String
-
hasContent
Checks whether a contentItem with the given itemId exists and is not empty.- Parameters:
itemId- ID of the content item to check- Returns:
- true if the contentItem with the given itemId exists and its
CMSContent.isEmpty()method returns false
-
getContent
-
setPreview
public void setPreview(boolean preview) Sets whether this component should be displayed when the owning page is embedded in another page, rather than on the owning page itself.- Parameters:
preview- true to set scope to preview; false for normal page view
-
isPreview
public boolean isPreview()Returns whether this component should be displayed when the owning page is embedded in another page, rather than on the owning page itself.- Returns:
- true if scope is CMSComponentScope.PREVIEW; false otherwise
-
getScope
-
setScope
-
getPersistenceId
public long getPersistenceId() -
getOwningPage
-
isPaged
public boolean isPaged() -
getTypes
-
getProperties
-
hasProperty
-
toString
-