1

We are trying to add a Region for our Global alerts site wide in Page Template.

Detailed implementation steps:

CT: Component template

Include PT: Include PT

PT: Page template

Page: Page

Initialize:

@RegisteredViewModel(viewName = "NWAlert", modelClass = RegionModelImpl.class),
@RegisteredViewModel(viewName = "AlertMessage", modelClass = AlertModel.class)

AlertRegion:

<jsp:useBean id="region" type="com.sdl.webapp.common.api.model.RegionModel" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>
<div ${markup.region(region)}>
    <dxa:entities/>
</div>

Page.jsp:

<dxa:region name="NWAlert" />

Workaround:

I can see the Alert related data in Page Model data JSON response. Looks the content pre-rendered is happening properly.

When I do debug, I can see the Region of NWAlert was properly initializing and it’s not throwing any error but still the Region part is not displaying in the Page.

[/WEB-INF/Views/xxx/Region/NWAlert.jsp]: Initialization successful

Also, I noticed when I do view source of my Page the Region tag is appending without data.

<div typeof="Region" resource="NWAlert">
<!--  Start Region: {title: "NWAlert", allowedComponentTypes: [{schema: "tcm:xx-xx-x", template: "tcm:xx-xx-xx"}], minOccurs: 0}  --> 
</div>

2 Answers 2

2

Following the example of a available Include Page in DXA 1.5, lets take the Content Tools for example (https://github.com/sdl/dxa-modules/blob/release/1.5/webapp-java/dxa-module-core/src/main/resources/META-INF/resources/WEB-INF/Views/Core/Region/Content-Tools.jsp). You should have a Region View for the Include Page. That should be a copy of https://github.com/sdl/dxa-modules/blob/release/1.5/webapp-java/dxa-module-core/src/main/resources/META-INF/resources/WEB-INF/Views/Core/Page/IncludePage.jsp basically (looks like your Page.jsp is an extract of that).

Then for the Region that will be rendered as part of the Include Page, you will need the following Region View markup:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="dxa" uri="http://www.sdl.com/tridion-dxa" %>
<%@ taglib prefix="xpm" uri="http://www.sdl.com/tridion-xpm" %>

<jsp:useBean id="region" type="com.sdl.webapp.common.api.model.RegionModel" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>
<xpm:button region="${region}"/>

<div ${markup.region(region)}>
    <dxa:regions/>
</div>

(similar to https://github.com/sdl/dxa-modules/blob/release/1.5/webapp-java/dxa-module-core/src/main/resources/META-INF/resources/WEB-INF/Views/Core/Region/Content-Tools.jsp)

Then in that Include Page, you will add Content, which will again be in a Region, and that Region needs the following Region View markup:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="dxa" uri="http://www.sdl.com/tridion-dxa" %>
<jsp:useBean id="region" type="com.sdl.webapp.common.api.model.RegionModel" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>

<div ${markup.region(region)}>
    <dxa:entities/>
</div>

(similar to https://github.com/sdl/dxa-modules/blob/release/1.5/webapp-java/dxa-module-core/src/main/resources/META-INF/resources/WEB-INF/Views/Core/Region/Tools.jsp as defined by the CT Social Sharing [Tools] for example)

So my example defines the following views:

  • IncludePage [Page View]
  • SocialSharing [Entity View]
  • Tools [Region View]
  • Content-Tools [Region View]

But from your description I make up the following:

  • IncludePage [Page View]
  • AlertMessage [Entity View]
  • NWAlert [Region View]
  • nwalert [Region View]

And the last one has a naming conflict, since both the Include Region and its Entity Region have the same name. If you follow the example of the Content Tools Include Page, you should name the Include Page different than the Region, so you can register both of those Regions and add the missing Region View (jsp).

1

Thanks for you suggestion @Tory and Bart Koopman

I have implemented as below. Its working now.

  1. HomePage [Page View]
  2. IncludePage [Page View]
  3. AlertMessage [EntityView]
  4. NWAlert [Region View]
  5. GlobalAlert [Region View]

CT: CT

IncludePage PT: IncludePage PT

HomePage PT: HomePage PT

Page: Page

AlertMessage Model and AlertMessage View :

Initialize:

@RegisteredViewModel(viewName = "HomePage", modelClass = PageModelImpl.class),
@RegisteredViewModel(viewName = "IncludePage", modelClass = PageModelImpl.class),
@RegisteredViewModel(viewName = "GlobalAlert", modelClass = RegionModelImpl.class),
@RegisteredViewModel(viewName = "NWAlert", modelClass = RegionModelImpl.class),
@RegisteredViewModel(viewName = "AlertMessage", modelClass = AlertModel.class),

GlobalAlert.jsp:

<%@ taglib prefix="dxa" uri="http://www.sdl.com/tridion-dxa"%>

<jsp:useBean id="region" type="com.sdl.webapp.common.api.model.RegionModel" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>

<div ${markup.region(region)}>
    <dxa:entities/>
</div>

NWAlert.jsp:

<%@ taglib prefix="dxa" uri="http://www.sdl.com/tridion-dxa"%>

<jsp:useBean id="region" type="com.sdl.webapp.common.api.model.RegionModel" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>

<div ${markup.region(region)}>
    <dxa:region name="GlobalAlert" />
</div>

IncludePage.jsp:

<dxa:region name="GlobalAlert" />

HomePage.jsp:

<dxa:region name="NWAlert" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.