LRP-614 practice question 25 of 25

Portlets that extend MVCPortlet require annotations on action methods.

Full set: 144 questions
Answer options
A: True
B: False
Correct Answer:
FALSE
Explanation

The statement is false because while using annotations like @ProcessAction is the modern, recommended, and most common way to handle action requests in a Liferay MVCPortlet, it is not a strict requirement. The MVCPortlet framework provides this annotation-driven mechanism for convenience and to reduce boilerplate code. However, developers can still fall back on the standard Java Portlet Specification (JSR 286/362) pattern by overriding the processAction(ActionRequest, ActionResponse) method directly in their portlet class. In this overridden method, they can implement their own logic to dispatch requests, for example, by using a switch statement on a request parameter. The annotation-based approach is an abstraction layer provided by Liferay, not a mandatory replacement for the underlying portlet lifecycle method.

Why Incorrect

The "True" option is incorrect because the word "require" implies that there is no other way to implement action phase logic in a portlet extending MVCPortlet. This is factually wrong, as overriding the processAction method is a valid, albeit more verbose, alternative that bypasses the need for action method annotations. ---

References

1. Liferay Developer Documentation, "Processing an Action": This official guide describes the annotation-based approach. Crucially, it states, "The recommended way to implement action methods is to annotate them with @ProcessAction". The use of the word "recommended" explicitly implies that other, non-recommended ways exist, thus confirming that annotations are not a strict requirement.

Source: Liferay Learn, "Processing an Action" tutorial for Liferay 7.4. (The principle is identical for all Liferay 7.x versions relevant to the LRP 614 exam).

2. Liferay Developer Documentation, "MVC Portlet": This documentation explains that MVCPortlet is Liferay's implementation of the Model-View-Controller pattern for portlets, designed to simplify development. It builds upon the standard portlet lifecycle. The ability to override base methods like processAction is fundamental to the Java inheritance model upon which MVCPortlet is built.

Source: Liferay Learn, "MVC Portlet" documentation.

3. Jakarta Portlet Specification (JSR 362), Section 15.3.2, "The Action Phase": The official specification defines the processAction method as the entry point for the action phase. Any class that implements the Portlet interface (which MVCPortlet does via its inheritance chain) must adhere to this contract. Liferay's annotation system is a layer on top of this fundamental contract, which can still be implemented directly by the developer.

Source: Jakarta Portlet Specification 3.0 (JSR 362), Page 103, Section 15.3.2. This specification is the foundation upon which Liferay portlets are built.

Scroll to Top