5

Steps followed-
(Referring to Special Offer module from DXA sdl docs-(http://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v2/GUID-3613D1ED-4F0C-47CF-82B6-07D412AF4416))

  • Created new Module (Offers) and followed Folder structure convention to create Schema and Component Template
  • Created dxa-module-offers in Java project, created view SpecialOffer.jsp at proper directory & SpecialOffer Entity with Semantic properties as described (matching with xml name of Schema fields)
  • Initialized/Registered my View Model.
  • Published the Publish settings system page.
  • Refreshed the cache in web application using /admin/refresh

Able to get my CP rendered on a page but my JSP is just rendering with empty/null values for all fields (just the html), while debugging DXA code I see that entity is populated with all values of properties as null (in com.sdl.webapp.common.impl.mapping.createEntity method)

Am I missing any steps here to just render simple CP using view & model from my custom module(also tried putting the view,model in Core module)? What should be used as the vocabulary for my entity? ..also little confused regarding specification of semantics

UPDATE
Schema -
schema Entity - (Just the part with semantic mappings etc entity contains other getter/setters as well)
partial-entity UPDATE2-

is it mandatory to specify semantics/vocabulary etc in tridion using some custom page for all new schemas added?

  • Can you edit your question and add the details of what your Schema looks like and also copy the source of your SpecialOffer entity (in case they are not exactly as in the documentation)? – Bart Koopman Jan 13 '16 at 11:52
  • @bart updated the question with required information as i did minor edits to entity & schema now. – Ashutosh Jan 13 '16 at 15:19
  • question added as update2 after trying some more options. – Ashutosh Jan 18 '16 at 16:06
3

Answer to the second Question (in Update 2; note that this is getting messy): no, it is not required to specify explicit semantic mappings on the CM-side (nor on the CD-side, BTW). There will always be an implicit mapping to semantic type [Schema Root Element Name] in the Core vocabulary.

Likewise, on the CD-side (i.e. on your View Model Types), there is always an implicit mapping to semantic type [View Model Type Name] in the Core vocabulary.

That means that if your View Model Type name matches the Root Element Name of your CM Schema, you don't need explicit mappings on either side.

  • Thanks for the confirmation @Rick, i got it working after i focused on other parts not the semantics. :) – Ashutosh Jan 19 '16 at 4:42
2

You must check following:

  1. In binarydata folder on your application, do you see your Schema details in schemas.json file. Binarydata folder is created at run time on root directory of your web application.
  2. And your entity in Java project is annotated with Schema RootElement name, apart from properties mapping.

@SemanticEntities({@SemanticEntity(entityName = "Event", vocabulary = SDL_CORE, prefix = "e"), @SemanticEntity(entityName = "Article", vocabulary = SDL_CORE, prefix = "a"),})

  • vocabularies.json will contains the prefixes and vocabulary namespaces, I think you mean schemas.json, which will contains the Schema details and semantics – Bart Koopman Jan 13 '16 at 11:50
  • can you tell me more about this binary data folder, haven't come across . where can i find it? – Ashutosh Jan 13 '16 at 12:08
  • Ya Bart , my bad. – Raj Kumar Jan 13 '16 at 12:23
  • @AshutoshGoel i have updated my answer. – Raj Kumar Jan 13 '16 at 13:31
  • @raj as i am using eclipse with tomcat i was able to find this binary data folder in one of the eclipse's temp folder,i see that schemas.json has details for my schema, and also validated my entity name is same as RootElement name of schema. though one thing i observed in schemas.json is that prefix for all fields is tri do i need to use that while mapping,how? – Ashutosh Jan 13 '16 at 14:37
1

After @Rick's confirmation on semantic mappings, i went back and checked all steps in details, as soon as i change the package of my entity to package com.sdl.webapp.common.api.model.entity this started working (can get data in my CP).

Also to cross-check i tried few other package names for my entity keeping entity/Semantic mappings etc same but it doesn't work with other package names.

Looks like only the entities available in this particular package are registered/initialized by default by DXA.

  • It should be possible (I would even highly recommend) to put your View Model Types in your own package. You do have to ensure that your View Model Types (and associated View) are registered, though. – Rick Pannekoek Jan 19 '16 at 18:24
  • See topic "Registering a custom Module in DXA" in the DXA 1.2 docs. – Rick Pannekoek Jan 19 '16 at 18:32
  • @Rick, yeah i am doing that correctly, i would investigate further if there is a specific package under which this entity should fall if not the exact package name (may be have to do with spring component-scan of that particular package) – Ashutosh Jan 20 '16 at 3:58
  • i think you should select @rick answer as your accepted solution as he helped you to figure out the problem. – Raj Kumar Jan 25 '16 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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