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?

3
  • 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)? Commented Jan 13, 2016 at 11:52
  • @bart updated the question with required information as i did minor edits to entity & schema now.
    – Ashutosh
    Commented Jan 13, 2016 at 15:19
  • question added as update2 after trying some more options.
    – Ashutosh
    Commented Jan 18, 2016 at 16:06

3 Answers 3

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.

1
  • Thanks for the confirmation @Rick, i got it working after i focused on other parts not the semantics. :)
    – Ashutosh
    Commented Jan 19, 2016 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"),})

9
  • vocabularies.json will contains the prefixes and vocabulary namespaces, I think you mean schemas.json, which will contains the Schema details and semantics Commented Jan 13, 2016 at 11:50
  • can you tell me more about this binary data folder, haven't come across . where can i find it?
    – Ashutosh
    Commented Jan 13, 2016 at 12:08
  • Ya Bart , my bad.
    – Raj Kumar
    Commented Jan 13, 2016 at 12:23
  • @AshutoshGoel i have updated my answer.
    – Raj Kumar
    Commented Jan 13, 2016 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
    Commented Jan 13, 2016 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.

4
  • 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. Commented Jan 19, 2016 at 18:24
  • See topic "Registering a custom Module in DXA" in the DXA 1.2 docs. Commented Jan 19, 2016 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
    Commented Jan 20, 2016 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
    Commented Jan 25, 2016 at 8:29

Your Answer

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

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