Skip to main content

Posts

Creating a DXA Java Module (part 2)

In my previous post Creating a DXA Java Module , I started presenting the steps for creating the Tridion items on the Content Manager needed for the new DXA module. In this current post, I present the Java code and configuration for having the DXA module run in a web-application. I wrote my code as a separate JAR using IntelliJ and then running the DXA v1.5 web-application on Tomcat as part of the standard DXA reference implementation project dxa-web-application-java  (available in GIT at https://github.com/sdl/dxa-web-application-java/tree/release/1.5 ). What follows are the steps on how to create the DXA Java module classes and configurations. 1. Create the IntelliJ Emerald Module In IntelliJ, create a new Java Module and enable Maven for it. Add the following dependencies in its pom.xml file: <dependencies> <dependency> <groupId> com.sdl.dxa </groupId> <artifactId> dxa-common-api </artifactId>...

Creating a DXA Java Module

In my previous blog post Troubleshoot a DXA Java Module , I presented a solution for a very specific issue with loading a DXA Java module. Then I had the idea for this blog post -- write a short tutorial on how to write a DXA module. What follows are the steps to create a new DXA Java module (I am using DXA v1.5). In this post, I present the Content Manager items needed for the new module. In fact, these are the minimum items and properties needed for having a new working DXA module. In next post Creating a DXA Java Module (part 2) , I present the Java code and configuration needed to run the new DXA module in a web-application. 1. Create a New Module in Tridion Content Manager I am using DXA reference implementation, and I created a new module called Emerald, next to the Core module of the reference implementation. Create the following Tridion folder structure starting from Folder Emerald : 2. Create Module Configuration Component In Folder Admin , create new Componen...

Troubleshoot a DXA Java Module

I was asked recently to troubleshoot a DXA 1.5 module that was not behaving properly. The apparent issue was that nested embedded fields in all models were not filled in with values once the Semantic Mapper would execute and create the models. This prompted me to do a little bit of digging into the Semantic Mapper and its registries of model entities, property and field maps. It turned out the models in the custom module were not being scanned and as such not registered as entities by the Semantic Mapper. The Semantic Mapper is DXA's de facto model factory that converts a Generic Page or Component into a specific page or component model, by mapping fields in the generic object to properties in the specific object. The solution was to simply call method registerEntities on the SemanticMapperRegistry singleton and pass it the base package name. The logic will then scan for entity models (i.e. classes that extend DXA's  AbstractEntityModel class) in sub-packages and regis...

Enable XPM Session Preview in Web 8 using Microservices

If you implemented the steps in the previous post Implementing Experience Manager in DD4T 2.0 .NET , then at this moment you can run your web application and XPM markup will appear in your HTML output. Also XPM functionality is working. However, if there are modifications on the Page or any Components on the Page that are not published, the "Update Preview" button will flash in the XPM GUI. Pressing this button will eventually end up in an error and the Update Preview button will keep flashing. This is due to the fact that we have not configured Session Preview yet. The following sections will guide you through installing and configuring Session Preview and database and services it uses. Experience Manager Database This database, aka Session Preview Database , has the same structure as a Tridion Content Data Store database, only that it is used as temporary storage for items that have been modified in XPM and previewed (i.e. rendered with templates), but not yet publi...

Implementing Experience Manager in DD4T 2 .NET

This post describes an implementation of Experience Manager (XPM) for DD4T 2 .NET using the CIL (REST) providers in SDL Web 8. The implementation would be basically the same in a more standard architecture where the Tridion Content Delivery stack would be used. XPM Configuration Switch In you web application's web.config , add the following line inside the configuration / appSettings node: <add key= "DD4T.IsPreview" value= "true" /> Only if this switch is present and set to true, the XPM markup will be generated in your HTML sources. Models Ready for XPM In order for XPM utility methods provided by DD4T out of the box to work, the models must: implement interface  DD4T.Core.Contracts.ViewModels.IViewModel ; annotate their Tridion fields with attributes; The code below shows a simple model that is XPM ready: using DD4T.ContentModel ; using DD4T.Core.Contracts.ViewModels ; using DD4T.Mvc.ViewModels.Attributes ; using DD4T....

Usage and Configuration of the .NET Cache Invalidation Callback

In the previous post, I described a way to intercept in .NET cache invalidate events generated in Java. This post presents the way to configure, use and write your own code that handles the Java generated invalidate events. The entire code presented here is available on this blog's GIT repository. Link here . Java Stuff Modify your cd_storage_conf.xml (located in your .net website /bin/conf folder), and reference class com.tridion.cache.DD4TDependencyTracker as the Feature inside node ObjectCache : <Configuration Version= "7.1" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "schemas/cd_storage_conf.xsd" > <Global> <ObjectCache Enabled= "true" > <Policy Type= "LRU" Class= "com.tridion.cache.LRUPolicy" > <Param Name= "MemSize" Value= "512mb" /> </Policy> ...

.Net Callback from Java Cache Invalidate Message

The problem this post solves is as follows: the Content Delivery API has a mechanism called Cache Decorator, which allows the implementor to define custom code that will be called when things are added/removed/flushed from the internal Tridion Broker Cache. This mechanism allows external actors to interact and synchronize with the Tridion Broker Cache. Namely, a DD4T cache should listen to Tridion Broker Cache messages in order to invalidate its own entries. In Java world, this is simply implemented by extending the CacheDecorator Tridion class. However, in a .NET environment, there is no easy way of intercepting Java method execution back in .NET. This is precisely what this post describes. In a .NET architecture, the Tridion Content Delivery API runs as a Java byte code embedded inside the .NET runtime inside IIS worker process. Communication between .NET and Java happens using a standard called JNI (Java Native Interfaces). Namely the .NET runtime calls Java code that is mapped ...