public class BaseHstComponent extends GenericHstComponent
ObjectBeanManager
, request parameters, query manager, etc.
This implementation enables developers to make use of HST Content Bean's ObjectBeanManager
which provides a simple object-content mapping solution.
To use ObjectBeanManager
, you can invoke getObjectBeanManager(HstRequest)
, which retrieves
a JCR session from HstRequestContext.getSession()
internally.
When you need to persist beans through ecm workflow, you can use getWorkflowPersistenceManager(Session)
. Make
sure that the jcr session you use as parameter is obtained through getPersistableSession(HstRequest)
or
getPersistableSession(HstRequest, Credentials)
.
Modifier and Type | Field and Description |
---|---|
static String |
BEANS_ANNOTATED_CLASSES_CONF_PARAM
Deprecated.
since 2.26.05 : do not use any more, In the 2.28.00 this static class variable is removed.
|
protected boolean |
beansInitialized
Deprecated.
since 2.26.05 : do not use any more, In the 2.28.00 this protected member is removed.
|
static String |
DEFAULT_BEANS_ANNOTATED_CLASSES_CONF
Deprecated.
since 2.26.05 : do not use any more, In the 2.28.00 this static class variable is removed.
|
protected HstQueryManagerFactory |
hstQueryManagerFactory
Deprecated.
since 2.26.05 : do not use any more, In the 2.28.00 this protected member is removed.
Use
HstRequestContext.getHstQueryManagerFactory() instead |
static String |
OBJECT_CONVERTER_CONTEXT_ATTRIBUTE
Deprecated.
since 2.26.05 : do not use any more, In the 2.28.00 this static class variable is removed.
|
protected ObjectConverter |
objectConverter
Deprecated.
since 2.26.05 : do not use any more, In the 2.28.00 this protected member is removed.
Use
getObjectConverter() instead |
RESOURCE_PATH_BY_RESOURCE_ID
Constructor and Description |
---|
BaseHstComponent() |
Modifier and Type | Method and Description |
---|---|
HippoFolderBean |
getAssetBaseBean(HstRequest request) |
HippoBean |
getBeanForResolvedSiteMapItem(HstRequest request,
ResolvedSiteMapItem resolvedSiteMapItem)
Return a
HippoBean when it can be found for the relativeContentPath for the . |
String |
getComponentLocalParameter(String name)
See
getComponentParameter(String) , but now, only resolved parameters directly on the HstComponent are taken into
account: in other words, no inheritance of parameters is applied |
Map<String,String> |
getComponentLocalParameters()
See
getComponentParameters() , but now, only resolved parameter map of parameters is returned that is directly on
the HstComponenConfiguration, thus, no inheritance is applied |
String |
getComponentParameter(String name)
Returns resolved parameter from HstComponentConfiguration : resolved means that possible property placeholders like
${1} or ${year}, where the first refers to the first wildcard matcher in a resolved sitemap item, and the latter
to a resolved parameter in the resolved HstSiteMapItem
The parameter map used has inherited parameters from ancestor components, which have precedence over child components)
|
Map<String,String> |
getComponentParameters()
See
getComponentParameter(String) , where we now return all resolved parameters (thus with inheritance of
ancestor components) |
protected <T> T |
getComponentParametersInfo(HstRequest request)
Returns a proxy ParametersInfo object which resolves parameter from HstComponentConfiguration : resolved means that possible property placeholders like
${1} or ${year}, where the first refers to the first wildcard matcher in a resolved sitemap item, and the latter
to a resolved parameter in the resolved HstSiteMapItem
|
HippoBean |
getContentBean(HstRequest request)
When the
belonging to the current requestUri has a relativeContentPath that points to an
existing jcr Node, a HippoBean wrapping this node is returned. |
<T extends HippoBean> |
getContentBean(HstRequest request,
Class<T> beanMappingClass) |
ComponentManager |
getDefaultClientComponentManager()
This returns the client ComponentManager if one is configured with its default name.
|
HippoFolderBean |
getGalleryBaseBean(HstRequest request) |
HstSite |
getHstSite(HstRequest request) |
protected List<Class<? extends HippoBean>> |
getLocalAnnotatedClasses()
Deprecated.
since 7.8.3 : There is no replacement. Since automatic beans scanning this method is completely redundant. Make
sure that through the 'hst-beans-annotated-classes' in the web.xml all annotated beans can be found. For example
|
String |
getLocalParameter(String name,
HstRequest request)
Deprecated.
since 2.26.01. Use
getComponentLocalParameter(String) instead |
Map<String,String> |
getLocalParameters(HstRequest request)
Deprecated.
since 2.26.01. Use
getComponentLocalParameters() instead |
Mount |
getMount(HstRequest request) |
ObjectBeanManager |
getObjectBeanManager(HstRequest request) |
ObjectConverter |
getObjectConverter() |
String |
getParameter(String name,
HstRequest request)
Deprecated.
since 2.26.01. Use
getComponentParameter(String) instead |
Map<String,String> |
getParameters(HstRequest request)
Deprecated.
since 2.26.01. Use #getComponentParameters(} instead
|
protected <T> T |
getParametersInfo(HstRequest request)
Deprecated.
since 2.26.01. Use #getComponentParametersInfo(org.hippoecm.hst.core.component.HstRequest)} instead
|
protected javax.jcr.Session |
getPersistableSession(HstRequest request)
Creates a persistable JCR session with the default credentials
|
protected javax.jcr.Session |
getPersistableSession(HstRequest request,
javax.jcr.Credentials credentials)
Creates a persistable JCR session with provided credentials.
|
String |
getPublicRequestParameter(HstRequest request,
String parameterName)
A public request parameter is a
HttpServletRequest parameter that is not namespaced. |
String[] |
getPublicRequestParameters(HstRequest request,
String parameterName)
|
HstQueryManager |
getQueryManager(HstRequest request) |
HstQueryManager |
getQueryManager(HstRequestContext ctx) |
HstQueryManager |
getQueryManager(javax.jcr.Session session) |
ResolvedMount |
getResolvedMount(HstRequest request) |
HippoBean |
getSiteContentBaseBean(HstRequest request) |
String |
getSiteContentBasePath(HstRequest request) |
protected WorkflowPersistenceManager |
getWorkflowPersistenceManager(javax.jcr.Session session)
Returns a
WorkflowPersistenceManager instance. |
protected WorkflowPersistenceManager |
getWorkflowPersistenceManager(javax.jcr.Session session,
Map<String,ContentNodeBinder> contentNodeBinders)
Returns a
WorkflowPersistenceManager instance with custom binders map. |
void |
init(javax.servlet.ServletContext servletContext,
ComponentConfiguration componentConfig)
Allows the component to initialize itself
|
boolean |
isPreview(HstRequest request) |
void |
sendRedirect(String path,
HstRequest request,
HstResponse response)
Facility method for sending a redirect to a sitemap path.
|
void |
sendRedirect(String path,
HstRequest request,
HstResponse response,
Map<String,String[]> queryParams)
Facility method for sending a redirect to a sitemap path including query params.
|
void |
sendRedirect(String path,
HstRequest request,
HstResponse response,
Map<String,String[]> queryParams,
String characterEncoding)
Facility method for sending a redirect to a sitemap path including query params and characterEncoding.
|
destroy, doAction, doBeforeRender, doBeforeServeResource, getComponentConfiguration
@Deprecated public static final String BEANS_ANNOTATED_CLASSES_CONF_PARAM
@Deprecated public static final String DEFAULT_BEANS_ANNOTATED_CLASSES_CONF
@Deprecated public static final String OBJECT_CONVERTER_CONTEXT_ATTRIBUTE
@Deprecated protected boolean beansInitialized
@Deprecated protected ObjectConverter objectConverter
getObjectConverter()
instead@Deprecated protected HstQueryManagerFactory hstQueryManagerFactory
HstRequestContext.getHstQueryManagerFactory()
insteadpublic void init(javax.servlet.ServletContext servletContext, ComponentConfiguration componentConfig) throws HstComponentException
HstComponent
init
in interface HstComponent
init
in class GenericHstComponent
servletContext
- the servletConfig of the HST container servletcomponentConfig
- the componentConfigBean configurationHstComponentException
@Deprecated public String getParameter(String name, HstRequest request)
getComponentParameter(String)
instead#getComponentParameter(String)}
public String getComponentParameter(String name)
name
- null if not present
@Deprecated public Map<String,String> getParameters(HstRequest request)
#getComponentParameters()}
public Map<String,String> getComponentParameters()
getComponentParameter(String)
, where we now return all resolved parameters (thus with inheritance of
ancestor components)@Deprecated public String getLocalParameter(String name, HstRequest request)
getComponentLocalParameter(String)
instead#getComponentLocalParameter(String)}
public String getComponentLocalParameter(String name)
getComponentParameter(String)
, but now, only resolved parameters directly on the HstComponent are taken into
account: in other words, no inheritance of parameters is appliedname
- null if not present
@Deprecated public Map<String,String> getLocalParameters(HstRequest request)
getComponentLocalParameters()
insteadpublic Map<String,String> getComponentLocalParameters()
getComponentParameters()
, but now, only resolved parameter map of parameters is returned that is directly on
the HstComponenConfiguration, thus, no inheritance is appliedpublic String getPublicRequestParameter(HstRequest request, String parameterName)
HttpServletRequest
parameter that is not namespaced. Thus for example ?foo=bar. Typically,
a namespaced request parameter for example looks like ?r1_r4:foo=bar.
Public request parameters are used when some parameter from some hst component needs to be readable by another hst
component. For example when you have a search box in the top of your webpage. The input value there should be
readable by the center content block displaying the search results. In that case, this method can be used
to fetch the public request parameter. Also see getPublicRequestParameters(HstRequest, String)
request
- parameterName
- null
is returnedpublic String[] getPublicRequestParameters(HstRequest request, String parameterName)
request
- parameterName
- new String[0]
is returnedpublic HstSite getHstSite(HstRequest request)
public ResolvedMount getResolvedMount(HstRequest request)
public Mount getMount(HstRequest request)
public String getSiteContentBasePath(HstRequest request)
request
- public boolean isPreview(HstRequest request)
true
when this request is matched to a preview siteMount.isPreview()
public HippoBean getContentBean(HstRequest request)
ResolvedSiteMapItem
belonging to the current requestUri has a relativeContentPath that points to an
existing jcr Node, a HippoBean wrapping this node is returned. When there is no relativeContentPath or the location does not exist,
null
is returnedrequest
- HippoBean
or null
when there cannot be created a content bean for the resolvedSiteMapItem belonging to the current requestpublic <T extends HippoBean> T getContentBean(HstRequest request, Class<T> beanMappingClass)
request
- beanMappingClass
- the class of the bean that you expectbeanMappingClass
or null
if bean cannot be found or is of a different class#getContentBean(HstRequest)} but only returns the bean if the found content bean is of type {@code beanMappingClass}. When the bean cannot be found, or is not of type
{@code beanMappingClass}, null
is returned
public HippoBean getSiteContentBaseBean(HstRequest request)
public HippoFolderBean getGalleryBaseBean(HstRequest request)
request
- /content/gallery
and null
if it does not existpublic HippoFolderBean getAssetBaseBean(HstRequest request)
request
- /content/assets
and null if it does not existpublic HippoBean getBeanForResolvedSiteMapItem(HstRequest request, ResolvedSiteMapItem resolvedSiteMapItem)
HippoBean
when it can be found for the relativeContentPath for the ResolvedSiteMapItem
. If there is no
relativeContentPath available in the ResolvedSiteMapItem
, or when the relativeContentPath does not point to an existing jcr node,
null
will be returnedrequest
- resolvedSiteMapItem
- HippoBean
or null
when there cannot be created a content bean for this resolvedSiteMapItempublic HstQueryManager getQueryManager(HstRequest request)
request
- the HstRequest
HstQueryManager
#getQueryManager(HstRequestContext)} and {@link #getQueryManager(Session)}
public HstQueryManager getQueryManager(HstRequestContext ctx)
ctx
- the HstRequestContext
HstQueryManager
#getQueryManager(HstRequest)} and {@link #getQueryManager(Session)}
public HstQueryManager getQueryManager(javax.jcr.Session session)
session
- the Session
HstQueryManager
#getQueryManager(HstRequestContext)} and {@link #getQueryManager(HstRequest)}
public ObjectBeanManager getObjectBeanManager(HstRequest request)
public ComponentManager getDefaultClientComponentManager()
null
if none configuredpublic void sendRedirect(String path, HstRequest request, HstResponse response)
Facility method for sending a redirect to a sitemap path. You do not have to take into account the context path or Mount
path
path
- the sitemap path you want to redirect torequest
- the HstRequestresponse
- the HstResponseHstResponse.sendRedirect(String)
public void sendRedirect(String path, HstRequest request, HstResponse response, Map<String,String[]> queryParams)
Facility method for sending a redirect to a sitemap path including query params. You do not have to take into account the context path or Mount
path
path
- the sitemap path you want to redirect torequest
- the HstRequestqueryParams
- query parameters to append to the redirection urlresponse
- the HstResponseHstResponse.sendRedirect(String)
public void sendRedirect(String path, HstRequest request, HstResponse response, Map<String,String[]> queryParams, String characterEncoding)
Facility method for sending a redirect to a sitemap path including query params and characterEncoding. You do not have to take into account the context path or Mount
path
path
- the sitemap path you want to redirect torequest
- the HstRequestqueryParams
- query parameters to append to the redirection urlresponse
- the HstResponsecharacterEncoding
- character encoding for query parametersHstResponse.sendRedirect(String)
public ObjectConverter getObjectConverter() throws HstComponentException
HstComponentException
@Deprecated protected List<Class<? extends HippoBean>> getLocalAnnotatedClasses()
<param-value>
classpath*:com/onehippo/myproject/beans/**\/\*.class,
classpath*:org/onehippo/forge/poll/**\/\*.class,
classpath*:org/onehippo/forge/properties/**\/\*.class,
classpath*:org/onehippo/forge/tcmp/**\/\*.class,
</param-value>
when you want to inject specific component only custom annotated classes override this method
This method is only called during the init() phase of a component
protected javax.jcr.Session getPersistableSession(HstRequest request) throws javax.jcr.RepositoryException
Note: The client should invoke logout()
method on the session after use.
Internally, Session.impersonate(Credentials)
method will be used to create a
persistable JCR session. The method is invoked on the session from the session pooling repository.
request
- javax.jcr.RepositoryException
protected javax.jcr.Session getPersistableSession(HstRequest request, javax.jcr.Credentials credentials) throws javax.jcr.RepositoryException
Note: The client should invoke logout()
method on the session after use.
Internally, Session.impersonate(Credentials)
method will be used to create a
persistable JCR session. The method is invoked on the session from the session pooling repository.
request
- javax.jcr.RepositoryException
protected WorkflowPersistenceManager getWorkflowPersistenceManager(javax.jcr.Session session)
WorkflowPersistenceManager
instance.session
- make sure this is a persistable session, obtained through or {@link #getPersistableSession(HstRequest, Credentials)}
protected WorkflowPersistenceManager getWorkflowPersistenceManager(javax.jcr.Session session, Map<String,ContentNodeBinder> contentNodeBinders)
WorkflowPersistenceManager
instance with custom binders map.session
- make sure this is a persistable session, obtained through or {@link #getPersistableSession(HstRequest, Credentials)}
contentNodeBinders
- protected <T> T getComponentParametersInfo(HstRequest request)
NOTE: Because the returned ParametersInfo proxy instance is bound to the current request, you MUST NOT store the returned object in a member variable or session. You should retrieve that per request.
The parameter map used has inherited parameters from ancestor components, which have precedence over child components)request
- the HST requestnull if not present
@Deprecated protected <T> T getParametersInfo(HstRequest request)
#getComponentParametersInfo(org.hippoecm.hst.core.component.HstRequest)}
Copyright © 2008-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.