0

We are trying add some schema fields to page metadata and trying to access them thru page model but for doing this we may have to edit the pagebuilderImpl,viewModel and abstractViewModel from core framework and tridion provider.we dont want to edit the core stuff,we are looking for way to extend the pagebuilder and other required stuff into our custom module.we are looking for help on how to implement this in a best possible?

4 Answers 4

3

I don't think you need to modify any Builder for this. All you would need to do is

  • Create a custom model, inheriting from the default PageModel
  • Add your page metadata fields to this page model (just as if you would create another model for any schema
  • create a new page view and put in any html for your page. Also make sure to specify your new class as the page model on top of this view
  • Add your page model and view to your module initializer
  • make sure to republish the DXA settings, and that should be it.

Now, the model builder should automatically generate the correct model for your page.

This is also (briefly) explained in the DXA documentation : https://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v7/GUID-B90B888E-7A84-4BB7-8832-8563C26C2646

0
-1

We do not get any errors in the console. However, the page throws an Internal Server Error. We were able to view the assetType values in the preview section in Tridion but on the browser, the json format does not come up and throws the Internal server error.

Additionally, we also published the DXA settings and other configuration pages in Tridion, did an admin/refresh too. None of these steps helped us either.

Furthermore, we also compared our code changes with the sample project that we found in the forum :https://github.com/sdl/dxa-modules/blob/master/webapp-java/dxa-module-test/src/main/java/com/sdl/dxa/modules/model/TSI811/Tsi811PageModel.java

We have not succeeded in getting it to work so far.

One significant difference we noticed in the above sample project is, we found this line of code in the pageModelClass : @SemanticEntity(entityName = "TSI811PageMetadataSchema", vocabulary = SDL_CORE)

Question we have is: should we be creating a custom metadata schema like the one above or use the existing metadata schema?

1
  • This is really not an answer, is it? Please either ask a different (new) question, or share your additional inputs contributing to an answer as a comment, instead of asking additional questions as an answer.
    – Nuno Linhares
    Jan 13, 2019 at 12:27
-1

we did these steps and we dont have luck with seeing the page with new model?

Model:

public class XXXX extends defaultPageModel{

@JsonProperty("AssetsType")
protected String assetsType;


public String getAssetsType() {
    return assetsType;
}

public void setAssetsType(String assetsType) {
    this.assetsType = assetsType;
}

}

Custom Page view:

<jsp:useBean id="pageModel" type="com.sdl.dxa.modules.XXXXCustom.model.page.XXXX" scope="request"/>          

Custom Intializer:

@RegisteredViewModel(viewName = "MyPage", modelClass = XXXXX.class),

5
  • do you get any error ? if so, could you post it? or is the field AssetsType empty ? Also, did you republish the DXA settings page and call /admin/refresh in your website ? Nov 10, 2017 at 19:53
  • We do not get any errors in the console. However, the page throws an Internal Server Error. We were able to view the assetType values in the preview section in Tridion but on the browser, the json format does not come up and throws the Internal server error.
    – Avinash
    Nov 13, 2017 at 20:07
  • Additionally, we also published the DXA settings and other configuration pages in Tridion, did an admin/refresh too. None of these steps helped us either. Furthermore, we also compared our code changes with the sample project that we found in the forum :github.com/sdl/dxa-modules/blob/master/webapp-java/… We have not succeeded in getting it to work so far. One significant difference we noticed in the above sample project is, we found this line of code in the pageModelClass :
    – Avinash
    Nov 13, 2017 at 20:07
  • @SemanticEntity(entityName = "TSI811PageMetadataSchema", vocabulary = SDL_CORE) Question we have is: should we be creating a custom metadata schema like the one above or use the existing metadata schema?
    – Avinash
    Nov 13, 2017 at 20:07
  • The entityName variable should correspond to the name you specified in your existing Metadata Schema. You are saying you see an internal server error. This error should be logged somewhere. Could you check the dxa logs, or the tomcat logs (or whatever server you use) ? Nov 13, 2017 at 20:20
-1

Resolved.entityName that we are using didnt match with the metadata schema that we created and used on the page.After the correcting that, the page has come up.

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.