The ComponentRenderingURL
A ComponentRenderingURL allows you to render a single HstComponent or a subtree of HstComponents without reloading the entire page. Like an HST action URL, a component rendering URL targets a specific HST component, which may include its descendant components. When you configure an HST component with hst:async = true, HST generates a component rendering URL instead of rendering the component directly. You can use this URL to asynchronously retrieve the component. For more information, see Asynchronous HST Components and Containers.
Component rendering URLs are commonly used in the Experience manager within the CMS. For example, when you update a property of a component, the Experience manager reloads only that component in the background using a component rendering URL.
Creating a ComponentRenderingURL
Using the HST Tag
In a JSP file, you can generate a component rendering URL with the following tag:
<hst:componentRenderingURL var="componentRenderingURL"/> <a href="${componentRenderingURL}" target="_blank"> Render only this component </a>
For example, if the current URL is /news and you add the tag above to the MIDDLE block in the following layout:
_____________________________________________
| TOP |
|___________________________________________|
| | | |
| | | |
| LEFT | MIDDLE | RIGHT |
| | | |
| | | |
|___________|________________|______________|
The generated URL might look like:
/news?_hn:type=component-rendering&_hn:ref=r34_r1_r1
This URL includes the original path (/news) and query parameters _hn:type and _hn:ref. These parameters instruct HST to process the request as a component rendering URL. The _hn:ref value identifies the MIDDLE component, so only that component will be rendered in the new window when you click the link. This mechanism is similar to how HST action URLs work.
Programmatic Creation
You can also create a component rendering URL programmatically:
{ HstResponse response = ... HstURL componentRenderingURL = response.createComponentRenderingURL(); }
This code creates a component rendering URL for the HstComponent associated with the provided HstResponse instance.
Standalone Component Rendering (Advanced)
You can control how HST processes component rendering URLs by setting the hst:standalone property on a hst:component node in the JCR configuration. This property is a boolean flag. If the property is missing, the default value is hst:standalone = true.
Note: By default, all
hst:componentnodes are treated as standalone, even if thehst:standaloneproperty is not explicitly set.
When HST processes a component rendering URL, it targets a specific HST component. If hst:standalone = true for the targeted component, HST processes only the doBeforeRender method and the renderer (JSP or Freemarker) for that component and its descendants. If hst:standalone = false, HST assumes the targeted component may depend on the doBeforeRender logic of ancestor or sibling components. In this case, HST invokes the doBeforeRender methods for all components belonging to the root component of the matched sitemap item, but only renders the targeted component and its descendants.
When Is a Component Standalone?
A component is considered standalone if it and all its descendants have hst:standalone = true. If any descendant is not standalone, then its ancestors cannot be standalone either. If you do not configure the hst:standalone property anywhere, all HST components are standalone by default.
Warning: Setting
hst:standalone = falseis strongly discouraged. It introduces dependencies between HST components and reduces the efficiency of asynchronous page loading.