LRP-614 practice question 2 of 25
In a JSP that includes the tag, the method to check permissions is:
Full set: 144 questionsThe tag makes several implicit scriptlet variables available within a JSP for convenience. One of these is permissionChecker, which is an instance of com.liferay.portal.kernel.security.permission.PermissionChecker. This object is exposed directly to allow for straightforward permission checks. Therefore, the most direct and standard method to check permissions in a JSP after including this tag is by calling the hasPermission() method on the readily available permissionChecker object.
B. portalUtil.getPermissionChecker().hasPermission() This is an indirect approach. The portalUtil.getPermissionChecker() static method requires a PortletRequest argument, which is unnecessary when the permissionChecker object is already in scope.
C. permissionUtil.hasPermission() PermissionUtil is not a standard Liferay utility class for invoking permission checks in this manner. The primary API for this is the PermissionChecker interface.
D. renderRequest.getPermissionChecker().hasPermission() While renderRequest is also made available and this call is technically valid, it is less direct than using the permissionChecker object that explicitly provides for this purpose.
1. Official Liferay Documentation: The Liferay Portal 6.2 Developer's Guide explains the objects made available by the tag. It lists permissionChecker as one of the key variables available for use in JSPs.
Source: Liferay, Inc. (2013). Liferay Portal 6.2 Developer's Guide. Section: "Accessing Objects from Your Theme", p. 103. It lists the available variables, including themeDisplay, user, and permissionChecker.
2. Liferay Taglib Definition: The implementation of the DefineObjectsTag class in the Liferay Portal source code confirms that it retrieves the PermissionChecker instance from ThemeDisplay and sets it as a page context attribute named permissionChecker.
Source: Liferay Portal 6.1/6.2 Source Code, portal-impl/src/com/liferay/taglib/theme/DefineObjectsTag.java. The doStartTag() method contains the logic: pageContext.setAttribute(WebKeys.PERMISSIONCHECKER, themeDisplay.getPermissionChecker());.
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 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…
- Question 7A class that extends MVCPortlet must implement:
