LRP-614 practice question 14 of 25
All render logic must be implemented in the JSP when using MVCPortlet:
Full set: 144 questionsThis statement is false. The MVCPortlet framework is designed based on the Model-View-Controller (MVC) design pattern, which emphasizes the separation of concerns. In this pattern, the Controller is responsible for handling user input and business logic, while the View is responsible for presentation. In a Liferay MVCPortlet, the portlet class itself acts as the Controller. The render() method within this class is the designated place to implement render-phase logic. This includes tasks like retrieving data from services, performing calculations, and preparing the data for display by setting attributes in the renderRequest. The JSP file serves as the View, and its primary role is to render the user interface using the data prepared by the Controller. Placing all render logic in the JSP would violate the MVC pattern by mixing business logic with presentation code, making the application harder to maintain and test.
The statement "True" is incorrect because it fundamentally misunderstands the purpose of the MVCPortlet framework. The framework provides the render() method in the Java portlet class specifically to house the logic that prepares content for rendering. The JSP is then invoked by the controller to display that content. The logic and presentation are intentionally separated.
1. Liferay Developer Documentation, "MVC Portlet": This official guide explains the structure of an MVC Portlet. It explicitly shows that the portlet class's @ProcessAction and render methods (the Controller) handle logic, while JSPs (the View) handle the presentation. The render method is shown preparing data before the JSP is included.
Source: Liferay Learn Portal, "Creating an MVC Portlet" tutorial.
Reference: The tutorial demonstrates the render method in the Portlet.java file being used to set request attributes before the super.render(renderRequest, renderResponse); call, which dispatches to the JSP. This clearly separates the logic (in the Java method) from the presentation (in the JSP).
2. Liferay DXP Javadocs for MVCPortlet: The official Javadoc for the com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet class describes the render method. Its purpose is to handle the render request and then delegate to a view layer (typically a JSP) via the include method.
Source: Liferay DXP 7.4 Javadocs.
Reference: The documentation for the render(RenderRequest renderRequest, RenderResponse renderResponse) method states it "is the default handler for the render phase." It then calls include(String, PortletRequest, PortletResponse) to forward to the view, confirming its role as a controller dispatching to a view.
3. Liferay Developer Documentation, "Understanding the Portlet Lifecycle": This document details the different phases of a portlet's life. It describes the Render Phase, where the render method is invoked to generate the portlet's content. This generation process is the "render logic" that occurs in the controller before the view is rendered.
Source: Liferay Learn Portal, "Portlet Lifecycle".
Reference: The "Render Phase" section explains that the render method is called to allow the portlet to generate content. This confirms that logic is executed within the portlet class during this phase, separate from the JSP that ultimately displays the output.
Keep practicing
Take the free LRP-614 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other LRP-614 practice questions
- Question 1The best way to add a new language key to the portal is through:
- Question 2In a JSP that includes the tag, the method to check permissions is:
- Question 3A hook plugin can be used to: (Please select all correct answers.)
- Question 4An administrator would like to add a new travel preferences section in the Miscellaneous …
- Question 5The following statements about plugins are true: (Please select all correct answers.)
- Question 6All Service Builder entities contain a local reference to: (Please select all correct ans…
