Upgrade 7.6 to 7.7 HST code changes 

 

http://www.onehippo.org/binaries/sixteencolumn/content/gallery/connect/library/7.7_upgrade_hst_code.png

Several HST classes, methods, JSP tags, and configuration properties have been deprecated in CMS 7.7. Other already deprecated constructs have been removed. This page provides an overview of all the necessary changes.

    HST classes          Replace BaseFormHstComponent by FormUtils methods          Replace deprecated HstLinkCreator#create... methods          Replace BaseHstComponent#getQueryManager() 
        Replace @Parameter and @ParametersInfo annotations 
        Replace BeanUtils#createIncomingBeansQuery and BeanUtils#getIncomingBeans 
        New: use SearchInputParsingUtils for parsing free text queries 
    JSP tags 
        Replace hst:surfandeditlink by hst:cmseditlink 
        Remove hst:headContributions for 'hippoPagecomposer' 
        Replace hst:head-contribution, hst:head-contributions, and hst:writeHeadContributions 
        In hst:link replace attribute 'external' with 'fullyQualified' 
    HST configuration properties 
        Remove cms.location

HST classes

Replace BaseFormHstComponent by FormUtils methods

The BaseFormHstComponent has been deprecated and will be removed in some future release. Instead of BaseFormHstComponent, use static methods from FormUtils.

For example, you used to extend your form HST component from the BaseFormHstComponent and write something like:

import org.hippoecm.hst.component.support.forms.FormMap;
public class Detail extends BaseFormHstComponent {
    @Override
    public void doAction(HstRequest request, HstResponse response) throws HstComponentException {
        FormMap formMap = ...;
        persistFormMap(request, response, formMap, null);
    }
    @Override
    public void doBeforeRender(HstRequest request, HstResponse response) throws HstComponentException {
        FormMap formMap = ...;
        populate(request, formMap);
    }
}

Instead, you now extend from from BaseHstComponent and use static methods from FormUtils:

import org.hippoecm.hst.component.support.forms.FormMap;
import org.hippoecm.hst.component.support.forms.FormUtils;
public class Detail extends BaseHstComponent {
    @Override
    public void doAction(HstRequest request, HstResponse response) throws HstComponentException {
        FormMap formMap = ...;
        FormUtils.persistFormMap(request, response, formMap, null);
    }
    @Override
    public void doBeforeRender(HstRequest request, HstResponse response) throws HstComponentException {
        FormMap formMap = ...;
        FormUtils.populate(request, formMap);
    }
}

Replace deprecated HstLinkCreator#create... methods

Several methods in the class HstLinkCreator that had been deprecated for some versions are now removed completely. If you are using any of the deprecated HstLinkCreator#create methods, first upgrade the code to not use deprecated methods any more. The javadocs indicate which methods to use instead.

Replace BaseHstComponent#getQueryManager()

The method BaseHstComponent#getQueryManager() has been deprecated. Instead, use one of:

  • getQueryManager(HstRequest req)

  • getQueryManager(HstRequestContext ctx)

  • getQueryManager(Session session)

For example, instead of

@Override
public void doBeforeRender(HstRequest request, HstResponse response) throws HstComponentException {
    // DEPRECATED
    HstQueryManager queryMngr = getQueryManager();
}

you should use

@Override
public void doBeforeRender(HstRequest request, HstResponse response) throws HstComponentException {
    HstQueryManager queryMngr = getQueryManager(request);
}

Replace @Parameter and @ParametersInfo annotations

The annotations @Parameter and @ParametersInfo have been moved to another package. Furthermore, the @Parameter annotation no longer needs a 'typeHint' element (we now use the return type of the method instead).

Deprecated class

Use instead

org.hippoecm.hst.configuration.components.Parameter

org.hippoecm.hst.core.parameters.Parameter

org.hippoecm.hst.configuration.components.ParametersInfo

org.hippoecm.hst.core.parameters.ParametersInfo

More information:

Replace BeanUtils#createIncomingBeansQuery and BeanUtils#getIncomingBeans

The methods BeanUtils#createIncomingBeansQuery and BeanUtils#getIncomingBeans have been deprecated. Use the following replacements instead:

Deprecated method

Use instead

org.hippoecm.hst.utils.BeanUtils#createIncomingBeansQuery

org.hippoecm.hst.util.ContentBeanUtils#createIncomingBeansQuery

org.hippoecm.hst.utils.BeanUtils#getIncomingBeans

org.hippoecm.hst.util.ContentBeanUtils#getIncomingBeans

New: use SearchInputParsingUtils for parsing free text queries

It is strongly advised to always parse free text query via methods in the class SearchInputParsingUtils.

JSP tags

Replace hst:surfandeditlink by hst:cmseditlink

In 7.7 the tag hst:surfandeditlink is deprecated. Instead, use the tag hst:cmseditlink.

For example, the following JSP uses the tag hst:surfandeditlink to create a link for editing the document in the CMS:

<a href="<hst:surfandeditlink hippobean="${document}"/>" target="_blank">[surf&amp;edit]</a>

This code can be replaced with:

<hst:cmseditlink var="editLink" hippobean="${document}"/>
<a href="${editLink}" target="_blank">[surf&amp;edit]</a>

Note that you now must flush the output to some variable, like 'editLink' in the example code above.

The hst:cmseditlink tag can also be used to show an 'Edit content' button when previewing a channel in the CMS:

<hst:cmseditlink hippobean="${document}"/>

The second example will now only output an HTML comment when previewing the channel in the CMS. That comment is then used to dynamically inject an 'Edit content' button into the DOM.

For more information, see Enable 'edit content' button that opens document editor.

Remove hst:headContributions for 'hippoPagecomposer'

In the 'root' JSPs, you can remove

<hst:headContributions categoryIncludes="hippoPagecomposer"/>

everywhere as it is not needed any more. It used to generate some JSP libraries needed for the template composer, but since the template composer has been integrated into the CMS, this is not needed any more.

Replace hst:head-contribution , hst:head-contributions , and hst:writeHeadContributions

The tags hst:head-contributionhst:head-contributions, and hst:writeHeadContributions have been deprecated several HST versions back, and are now removed completely. The following tags can be used instead:

Deprecated tag

Use instead

hst:head-contribution

hst:headContribution

hst:head-contributions

hst:headContributions

hst:writeHeadContributions

hst:headContributions

In hst:link replace attribute 'external' with 'fullyQualified'

The attribute external of the hst:link tag has been deprecated. Instead, use use fullyQualified.

For example, getting a fully qualified link (including the protocol, hostname and if needed portnumber) used to look something like:

<hst:link var="link" hippobean="${doc}" external="true"/>

Instead, use something like:

<hst:link var="link" hippobean="${doc}" fullyQualified="true"/>

HST configuration properties

Remove cms.location

The property 'cms.location' in the file hst-config.properties has been deprecated. Instead, the CMS location should be configured in the repository HST configuration.

For example, the hst-config.properties file used to contain a cms.location property:

# the location of the cms for the [surf & edit] button
cms.location = http://localhost:8080/cms

Instead, you must now configure the CMS location on the hst:virtualhostgroup node in the repository. You can specify a diffent CMS location per hostgroup node. For example:

hst:hst
    ` hst:hosts
          |-dev-env (hst:cmslocation = http://localhost:8080/cms , hst:defaultport = 8080)
          |    ` localhost
          `-prod-env (hst:cmslocation = http://cms.example.com)
               ` com
                   ` example
                         ` www

Note: the 'dev-env' hostgroup also contains the property 'hst:defaultport = 8080'. This is unrelated to the deprecation of thecms.location property. However, when the 'preview' from the CMS Channel Manager needs to create a link containing a portnumber, the 'hst:defaultport' property must be specified.