Markdown Extension

The Markdown value type is intended to render HTML markup that is authored using Markdown markup language, as per the CommonMark spec.

A common use case is to render help pages or technical manuals.

Although properties of this type can be edited, the Wicket viewer does not provide any specialized authoring environment. It is therefore most suitable for read-only values.

Setup

Dependency Management

In your application’s top level pom.xml, add a dependency for this module’s own bill of materials (BOM):

pom.xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.valuetypes</groupId>
            <artifactId>causeway-valuetypes-markdown</artifactId>
            <scope>import</scope>
            <type>pom</type>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Dependencies / Imports

In those modules where there are domain objects that use the Markdown value type:

  • add this dependency:

    pom.xml
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.valuetypes</groupId>
            <artifactId>causeway-valuetypes-markdown-applib</artifactId>
        </dependency>
    </dependencies>
  • and @Import this module:

    MyModule.java
    @Configuration
    @Import({
        CausewayModuleValMarkdownApplib.class,
        // ...
    })
    public class MyModule { ... }

In addition, in the webapp module of your application, add the following dependencies:

  • for the Wicket viewer:

    pom.xml
    <dependency>
        <groupId>org.apache.causeway.valuetypes</groupId>
        <artifactId>causeway-valuetypes-markdown-ui-wkt</artifactId>
    </dependency>
  • and for persistence:

    pom.xml
    <dependency>
        <groupId>org.apache.causeway.valuetypes</groupId>
        <artifactId>causeway-valuetypes-markdown-xxx</artifactId>   (1)
    </dependency>
    1 where xxx is jpa (if using JPA/Eclipselink) or jdo (if using JDO/DataNucleus).

And in your application’s App Manifest, import the extension’s implementation module:

AppManifest.java
@Configuration
@Import({
        CausewayModuleValMarkdownUiWkt.class,
        CausewayModuleValMarkdownPersistenceXxx.class,  (1)
        ...
})
public class AppManifest {
}
1 where Xxx is Jpa (if using JPA/Eclipselink) or Jdo (if using JDO/DataNucleus).

Usage

The property can be declared and used in both entities and view models. If declared in an entity, then it should most likely be mapped to a CLOB:

  • if declared in an JPA entity:

    @Property
    @PropertyLayout
    @Column(nullable = false) @Lob @Basic(fetch=FetchType.LAZY) (1)
    @Getter @Setter
    private Markdown helpText;
    1 maps to a (c)lob
  • if declared in an JDO entity:

    @Property
    @PropertyLayout
    @Column(allowsNull = "false", jdbcType = "CLOB")        (1)
    @Getter @Setter
    private Markdown helpText;
    1 maps to a CLOB
  • if declared in a JAXB view model:

    @Property
    @PropertyLayout
    @XmlElement(required = true)
    @Getter @Setter
    private Markdown helpText;