Reputation: 403
I have seen methods in Hybris returning a JSP or dynamically doing getViewForPage.What is the difference between the two approaches.Is it the static or dynamic difference?What should be used when?Can I add new components with just returning a JSP using return statement?
Upvotes: 0
Views: 694
Reputation: 1822
I would strongly recommend to use the getViewForPage method every time. There are a lot of reasons why. Here are just the 2 most important from my point of view:
As long as you use the "storeCmsPageInModel" method, you can use CMS Components in your template. No matter if you use JSP or getViewForPage. However with the getViewForPage method you make sure, that the right JSP is used and that the configured frontend template name has the right content slots to display your components.
Maybe this question is not intended, but I would strongly recommend to use CMS Pages for every possible purpose. We developers have seen requirements change over time and CMS Pages offer all the flexibility you need to respond to this change.
Upvotes: 2