1 .I am getting a promotional entity
in my spring controller and then replacing the default entity
that came with my CP
.
@RequestMapping(method = RequestMethod.GET, value = "GetPromoItem/{entityId}")
public String getPromoItem(HttpServletRequest request,@PathVariable String entityId, @RequestParam String regionName) throws Exception {
//Get the entity from request
EntityModel entity = getEntityFromRequest(request, entityId);
final MvcData mvcData = entity.getMvcData();
//Get the Promotional item if returned for the current page/region combination
//Some code to get the promotional component id,template id based on region
PromoItemModel item=(PromoItemModel) contentProvider.getEntityModel(compId.getItemId()+"-"+templateId.getItemId(), localization);
if(item !=null)
entity=item;
request.setAttribute(ENTITY_MODEL, entity);
return resolveView(mvcData, "Entity", request);
}
2. Registered ViewModel , rendered using promotion.jsp
<jsp:useBean id="entity" type="com.sdl.webapp.common.api.model.entity.PromoItemModel" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>
<%@ taglib prefix="dxa" uri="http://www.sdl.com/tridion-dxa" %>
<div class="container-fluid ${entity.htmlClasses}" ${markup.entity(entity)}>
<div id="location-tile" class="row">
<div class="col-sm-6">
<div class="tile">
<h1 ${markup.property(entity, "headline")}> ${ entity.headline }</h1>
</div>
</div>
</div>
</div>
On my page I can see the promotional content if available and default if not, but the XPM markup is for the default entity always.
Question-
i- how can i generate and use the XPM Markup for my promotional entity using DXA?
ii- how can i modify this markup?
(Use case is appending some extra markup - like we add Smart Target Promotion XPMMarkup)
Any examples or pointers to similar markup generation within DXA projects are welcome.