Stripes Module for Magnolia CMS

Version 5.0.10 is available for Magnolia 4.5.

Stripes Module for Magnolia CMS is a custom magnolia module which integrates the Stripes MVC framework into Magnolia.

This module lets you use any available Stripes action as a Magnolia paragraph, any magically-converted Stripes action will still be able to use any standard Stripes feature, plus it will enjoy the automatic injection of any paragraph property.

The latest version of the Stripes Module for Magnolia CMS requires Magnolia 4.x and Stripes 1.5.1.

Configuration

1) Copy all openutils-mgnlstripes and stripes JAR files into Magnolia WEB-INF/lib directory or, if you are using Maven, just add the dependency to your pom.xml.

2) Configure stripes in your web.xml as usual (see http://www.stripesframework.org/display/stripes/Quick+Start+Guidee for this).

3) Change the configuration for the Stripes ActionResolver.Class in order to use it.openutils.magnoliastripes.MgnlActionResolver.

You can do that by adding/modifying the following init parameter in WEB.xml:

<init-param>
    <param-name>ActionResolver.Class</param-name>
    <param-value>it.openutils.magnoliastripes.MgnlActionResolver</param-value>
</init-param>

Usage

When magnolia and stripes will startup any auto-discovered stripes action will be configured in order to be used as a magnolia paragraph. This means that paragraphs will be auto-generated, and they don't need to be configured into jcr.

You should see a few info logs that lists all configured stripes paragraphs. By convention the name of the paragraph is the same name of the Stripes action class minus action and lowercase.

So it.myapp.web.MyStripesAction will be available as a paragraph named mystripes.

Before being able to use any paragraph you will need to create a dialog for that. By convention the dialog should have the same name of the paragraph so, following the previous example, you will need to configure a dialog called mystripes.

Try to put a property called title in such dialog for a test.

You are ready to use your paragraph into any magnolia template as usual:

<cms:contentNodeIterator contentNodeCollectionName="column">
    <cms:editBar adminOnly="true" />
    <cms:includeTemplate />
  </cms:contentNodeIterator>
  <cms:newBar contentNodeCollectionName="column" paragraph="mystripes" adminOnly="true" />

Try to add an instance of the mystripes paragraph. Set the title property to whatever you want, you will be able to use it in your Stripes action bean.

The following example show the code for the simple MyStripesAction that prints out the configured title to the log:

package it.myapp.web;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class MyStripesAction implements ActionBean
{

    private Logger log = LoggerFactory.getLogger(MyStripesAction.class);

    private String title;

    @Override
    public ActionBeanContext getContext()
    {
        // TODO
        return null;
    }

    @Override
    public void setContext(ActionBeanContext context)
    {
        // TODO
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    @DefaultHandler
    public Resolution show()
    {

        log.info("My title is: {}!", title);

        return new ForwardResolution("/templates/paragraphs/anyjsp.jsp");
    }
}

As you can see, you will be able to mix parameters that you can use in Stripes action with pure content. Note that you will not need to configure and use any magnolia paragraph property into your action since you can still use also the standard magnolia tags in the jsp that is rendered by Stripes!

    Project info & quick links