- java.lang.Object
- 
- jakarta.faces.component.UIComponent
- 
- jakarta.faces.component.UIComponentBase
- 
- org.omnifaces.component.output.OutputFamily
- 
- org.omnifaces.component.output.SitemapUrl
 
 
 
 
- 
- All Implemented Interfaces:
- PartialStateHolder,- StateHolder,- TransientStateHolder,- ComponentSystemEventListener,- FacesListener,- SystemEventListenerHolder,- EventListener
 
 public class SitemapUrl extends OutputFamily The <o:sitemapUrl>is a component which renders the given target URL or Faces view ID as a sitemap URL with support for adding additional query string parameters to the URL via nested<f:param>and<o:param>.This component is largely based off the Urlcomponent behind<o:url>, but then tailored specifically for usage insitemap.xmlfile. TheViewResourceHandlermust be registered infaces-config.xmlin order to get Faces components to run in/sitemap.xml.ValuesYou can supply the sitemap URL via either the valueattribute or theviewIdattribute. When both are specified, thevalueattribute takes precedence and theviewIdattribute is ignored.DomainWhen the target URL is specified as viewId, then the domain of the target URL defaults to the current domain. It is possible to provide a full qualified domain name (FQDN) via thedomainattribute which the URL is to be prefixed with. This can be useful if a canonical page shall point to a different domain or a specific subdomain.Valid formats and values for domainattribute are:- <o:sitemapUrl ... domain="https://example.com" />
- <o:sitemapUrl ... domain="//example.com" />
- <o:sitemapUrl ... domain="example.com" />
- <o:sitemapUrl ... domain="/" />
- <o:sitemapUrl ... domain="//" />
 The domainvalue will be validated byURLand throw an illegal argument exception when invalid. If the domain equals/, then the URL becomes domain-relative. If the domain equals or starts with//, or does not contain any scheme, then the URL becomes scheme-relative. If thevalueattribute is specified, then thedomainattribute is ignored.Request parametersYou can add query string parameters to the URL via nested <f:param>and<o:param>. To conditionally add or override, use thedisabledattribute of<f|o:param>.UsageUsage example of /sitemap.xmlas a Faces view:<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:o="http://omnifaces.org/ui" > <ui:repeat value="#{sitemapBean.products}" var="product"> <o:sitemapUrl viewId="/product.xhtml" lastModified="#{product.lastModified}" changeFrequency="weekly" priority="1.0"> <o:param name="id" value="#{product}" converter="productConverter" /> </o:sitemapUrl> </ui:repeat> </urlset>- Since:
- 3.10
- Author:
- Bauke Scholtz
- See Also:
- OutputFamily,- ViewResourceHandler
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSitemapUrl.ChangeFrequencyThe available values of the "changefreq" element of the sitemap URL.
 - 
Field SummaryFields Modifier and Type Field Description static StringCOMPONENT_TYPEThe component type, which is "org.omnifaces.component.output.SitemapUrl".- 
Fields inherited from class org.omnifaces.component.output.OutputFamilyCOMPONENT_FAMILY
 - 
Fields inherited from class jakarta.faces.component.UIComponentATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
 
- 
 - 
Constructor SummaryConstructors Constructor Description SitemapUrl()Constructs theSitemapUrlcomponent.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencodeBegin(FacesContext context)Renders the start of the<url>parent element.protected voidencodeChangeFrequency(FacesContext context)Renders the<changefreq>child element with the value ofgetChangeFrequency(), if any.voidencodeChildren(FacesContext context)Delegates toencodeLocation(FacesContext),encodeLastModified(FacesContext),encodeChangeFrequency(FacesContext)andencodePriority(FacesContext)in this order.voidencodeEnd(FacesContext context)Renders the end of the<url>parent element.protected voidencodeLastModified(FacesContext context)Renders the<lastmod>child element with the value ofgetLastModified(), if any.protected voidencodeLocation(FacesContext context)Renders the<loc>child element with either the value ofgetValue(), or the value ofgetViewId()andgetDomain()combined.protected voidencodePriority(FacesContext context)Renders the<priority>child element with the value ofgetPriority(), if any.SitemapUrl.ChangeFrequencygetChangeFrequency()Returns the value of the "changefreq" element of the sitemap URL.StringgetDomain()Returns the domain of the "loc" element of the sitemap URL.TemporalgetLastModified()Returns the value of the "lastmod" element of the sitemap URL.BigDecimalgetPriority()Returns the value of the "priority" element of the sitemap URL.StringgetValue()Returns the value of the "loc" element of the sitemap URL.StringgetViewId()Returns the view ID to create the URI part of the "loc" element of the sitemap URL for.voidsetChangeFrequency(SitemapUrl.ChangeFrequency changeFrequency)Sets the value of the "changefreq" element of the sitemap URL.voidsetDomain(String domain)Sets the domain of the "loc" element of the sitemap URL.voidsetLastModified(Temporal lastModified)Sets the value of the "lastmod" element of the sitemap URL.voidsetPriority(BigDecimal priority)Sets the value of the "priority" element of the sitemap URL.voidsetValue(String value)Sets the value of the "loc" element of the sitemap URL.voidsetViewId(String viewId)Sets the view ID to create the URI part of the "loc" element of the sitemap URL for.- 
Methods inherited from class org.omnifaces.component.output.OutputFamilygetFamily, getRendersChildren
 - 
Methods inherited from class jakarta.faces.component.UIComponentBaseaddClientBehavior, addFacesListener, broadcast, clearInitialState, decode, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
 - 
Methods inherited from class jakarta.faces.component.UIComponentencodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
 
- 
 
- 
- 
- 
Field Detail- 
COMPONENT_TYPEpublic static final String COMPONENT_TYPE The component type, which is "org.omnifaces.component.output.SitemapUrl".- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
SitemapUrlpublic SitemapUrl() Constructs theSitemapUrlcomponent.- Throws:
- IllegalStateException- when- Application.getProjectStage()is- ProjectStage.Developmentand the current request is not for the- ViewResourceHandlerat all.
 
 
- 
 - 
Method Detail- 
encodeBeginpublic void encodeBegin(FacesContext context) throws IOException Renders the start of the<url>parent element.- Overrides:
- encodeBeginin class- UIComponentBase
- Throws:
- IOException
 
 - 
encodeChildrenpublic void encodeChildren(FacesContext context) throws IOException Delegates toencodeLocation(FacesContext),encodeLastModified(FacesContext),encodeChangeFrequency(FacesContext)andencodePriority(FacesContext)in this order.- Overrides:
- encodeChildrenin class- UIComponentBase
- Throws:
- IOException
 
 - 
encodeEndpublic void encodeEnd(FacesContext context) throws IOException Renders the end of the<url>parent element.- Overrides:
- encodeEndin class- UIComponentBase
- Throws:
- IOException
 
 - 
encodeLocationprotected void encodeLocation(FacesContext context) throws IOException Renders the<loc>child element with either the value ofgetValue(), or the value ofgetViewId()andgetDomain()combined.- Parameters:
- context- The involved faces context.
- Throws:
- IOException- When an I/O error occurs.
- IllegalArgumentException- When the- getDomain()does not represent a valid domain.
 
 - 
encodeLastModifiedprotected void encodeLastModified(FacesContext context) throws IOException Renders the<lastmod>child element with the value ofgetLastModified(), if any. It may only encode formats specified in https://www.w3.org/TR/NOTE-datetime- Parameters:
- context- The involved faces context.
- Throws:
- IOException- When an I/O error occurs.
 
 - 
encodeChangeFrequencyprotected void encodeChangeFrequency(FacesContext context) throws IOException Renders the<changefreq>child element with the value ofgetChangeFrequency(), if any.- Parameters:
- context- The involved faces context.
- Throws:
- IOException- When an I/O error occurs.
 
 - 
encodePriorityprotected void encodePriority(FacesContext context) throws IOException Renders the<priority>child element with the value ofgetPriority(), if any.- Parameters:
- context- The involved faces context.
- Throws:
- IOException- When an I/O error occurs.
- IllegalArgumentException- When the- getPriority()is not between 0.0 and 1.0 (inclusive).
 
 - 
getValuepublic String getValue() Returns the value of the "loc" element of the sitemap URL. Note: when specified, thengetViewId()andgetDomain()are ignored.- Returns:
- The value of the "loc" element of the sitemap URL.
 
 - 
setValuepublic void setValue(String value) Sets the value of the "loc" element of the sitemap URL. Note: when specified, thengetViewId()andgetDomain()are ignored.- Parameters:
- value- The value of the "loc" element of the sitemap URL.
 
 - 
getViewIdpublic String getViewId() Returns the view ID to create the URI part of the "loc" element of the sitemap URL for. Note: this is ignored whengetValue()is specified.- Returns:
- The view ID to create the URI part of the "loc" element of the sitemap URL for.
 
 - 
setViewIdpublic void setViewId(String viewId) Sets the view ID to create the URI part of the "loc" element of the sitemap URL for. Note: this is ignored whengetValue()is specified.- Parameters:
- viewId- The view ID to create the URI part of the "loc" element of the sitemap URL for.
 
 - 
getDomainpublic String getDomain() Returns the domain of the "loc" element of the sitemap URL. Note: this is ignored whengetValue()is specified.- Returns:
- The domain of the "loc" element of the sitemap URL for.
 
 - 
setDomainpublic void setDomain(String domain) Sets the domain of the "loc" element of the sitemap URL. Note: this is ignored whengetValue()is specified.- Parameters:
- domain- The domain of the "loc" element of the sitemap URL for.
 
 - 
getLastModifiedpublic Temporal getLastModified() Returns the value of the "lastmod" element of the sitemap URL.- Returns:
- The value of the "lastmod" element of the sitemap URL.
 
 - 
setLastModifiedpublic void setLastModified(Temporal lastModified) Sets the value of the "lastmod" element of the sitemap URL.- Parameters:
- lastModified- The value of the "lastmod" element of the sitemap URL.
 
 - 
getChangeFrequencypublic SitemapUrl.ChangeFrequency getChangeFrequency() Returns the value of the "changefreq" element of the sitemap URL.- Returns:
- The value of the "changefreq" element of the sitemap URL.
 
 - 
setChangeFrequencypublic void setChangeFrequency(SitemapUrl.ChangeFrequency changeFrequency) Sets the value of the "changefreq" element of the sitemap URL.- Parameters:
- changeFrequency- The value of the "changefreq" element of the sitemap URL.
 
 - 
getPrioritypublic BigDecimal getPriority() Returns the value of the "priority" element of the sitemap URL.- Returns:
- The value of the "priority" element of the sitemap URL.
 
 - 
setPrioritypublic void setPriority(BigDecimal priority) Sets the value of the "priority" element of the sitemap URL.- Parameters:
- priority- The value of the "priority" element of the sitemap URL.
 
 
- 
 
-