View snippets

View snippets allow embedding dynamic JSP content into the shop frontend.

View snippets are configured using the configureViewSnippetMapping method in the configurer of your plugin.

It is necessary to define on which page and in which location a jsp file is embedded. A location is a placeholder in the novomind iSHOP. The snippet is rendered into the placeholders only at the specified pages. To render a snippet on all pages you can use the method onAllPages(). Please check the interface for all available options.

// Show the twitter.jsp at the page end, but only on product pages
//Show the footer.jsp on every page at the end

All view snippets are located in the folder META-INF\resources\plugin\plugin-helloworld, where plugin-helloworld is the name of your plugin.

There is the useful plugin ishop-plugin-devtool to display all standard locations in a novomind iSHOP.

Using models

A model can be passed to the JSPs to supply extra data.

In the configurer a modelBuilder can be registered with the withModel method.

configurer.withViewSnippet("content.jsp").onHomePage().onBelowBody().withModel(new SocialModelBuilder());

The model builder has to implement the ModelBuilder interface. The interface requires to implement the method createModel(ViewSnippetContext arg0) which is called every time the specified view snippet is rendered. Depending on where the snippet is rendered there may also be some information available in the ViewSnippetContext, like the product or the category.

public class SocialModelBuilder implements ModelBuilder {
  public Object createModel(ViewSnippetContext context) {
    return new SocialModel("myApiKey", 123);

The model is just a simple getter class.

public SocialModel() {
  public SocialModel(String apiKey, int productTrackingId);
  public String getApiKey();
  public int getProductTrackingId();

The modelTag makes the passed model accessible in a variable.

<%@ taglib uri="" prefix="api" %>
<api:model var="socialModel" />

API-KEY: <c:out value="${socialModel.apiKey}" />
Tracking Id: <c:out value="${socialModel.productTrackingId}" />

Including resources

The ResourceTag of the ishop-api tag library helps you embed static resources like images or javascript and css files into a view snippet.

Conditional rendering

You can define that the view snippet will only be rendered if a condition is met. In this case you have to implement the ViewSnippetCondition and add it to the configuration call.


Example: You want to display some content on german web sites only. Therefore you have to create a ViewSnippetCondition checking the current country. Every ViewSnippetCondition has to implement the apply method to check if your condition is met.

public class CountryDECondition implements ViewSnippetConfigurer.ViewSnippetCondition {

  private final ApiShopContext apiShopContext;
  private static final String country = "DE";

  public CountryDECondition(ApiShopContextFactory apiShopContextFactory) {
    this.apiShopContext = apiShopContextFactory.getDefaultShopContext();

  public boolean apply() {
    return country.equalsIgnoreCase(apiShopContext.getMcs().getCountry());

This condition needs to be registered in the PluginConfigurer#configureViewSnippetMapping method. You can simply add the when method to the withViewSnippet call. We will do the rest for you.

@ComponentScan(basePackageClasses = DefaultPluginConfigurer.class)
public class DefaultPluginConfigurer extends PluginConfigurerAdapter {
  CountryDECondition countryDECondition;

  public void configureViewSnippetMapping(final ViewSnippetConfigurer configurer) {