1

Not able to render the components in a Page JSP using view name defined as meta field in CT. I am using the tag in the page JSP but when I hit the page url its looking for component jsp created exactly with CT name instead of view name.

5
  • Can you share with us some details like the relevant code, screenshots, url you're hitting, routes configuration, logs? In general, try this more efficient approach: tridion.stackexchange.com/help/how-to-ask Commented Jan 26, 2016 at 23:45
  • How did you define the @ViewModel property? How did you define the usebean tag in your view?
    – Raimond
    Commented Jan 27, 2016 at 10:49
  • 1
    After some investigation - I believe this may be a bug in dd4t-2.0. Can you tell me what the key name is of your metadata field to denote the view?
    – Raimond
    Commented Jan 27, 2016 at 11:21
  • 1
    It's a confirmed issue. See github.com/dd4t/dd4t-2-java/issues/34. I will release a build shortly.
    – Raimond
    Commented Jan 27, 2016 at 11:44
  • Hi; I am using below in viewModel Class @ViewModel(viewModelNames = {"header"}, setComponentObject = true, setRawData = false) and below tag used in page JSP to make a call to render component view <dd4t:componentpresentations view="header" /> In the CT i have one metafield fieldname=view value=header Commented Jan 27, 2016 at 21:03

1 Answer 1

2

There was a bug in dd4t 2.0.1-beta and 2.0.2, which caused rendering component presentations to by default look at the metadata key viewName instead of view.

This has been fixed in dd4t-java version 2.0.3 and that build is now in Maven Central, so please update the version in your build to make this work properly.

To reconfirm how the JSP view-finding logic works:

DD4T renders views for CPs by first determining the view name from either the Component Template name or by looking at the "view" metadata key if it is set on the Component Template.

If no view metadata key is present in the Component Presentation, DD4T will take the title of the Component Template. In all cases, the following rules apply:

  • Both the value of the view metadata field and the title of the component template will be lower cased;
  • Spaces in the value will be dashed ('-').

If for example your view name is: 'generic Content', the JSP view name should be: generic-content.jsp. The determined view name should then be present in the web application as a JSP file. If it is, then a sub Servlet request is fired which outputs the rendered JSP into the parent - usually Page - JSP.

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.