What method should be used to get the value of a custom field for a User object named "user"?

Prepare for the Liferay Developer Certification Exam with interactive quizzes, flashcards, and multiple-choice questions. Each question comes with hints and detailed explanations to help you master the exam content. Ace your certification exam with confidence!

To retrieve the value of a custom field from a User object in Liferay, using the method provided in the selected answer is appropriate because it utilizes the ExpandoBridge associated with the User object. The ExpandoBridge allows access to dynamic fields—those that are not hard-coded in the database schema but rather stored as custom attributes.

By calling user.getExpandoBridge().getAttribute(), you are specifically referencing the ExpandoBridge tied to the User, which manages the custom fields. This method is designed to fetch the value of a specific custom field based on the field name provided as an argument, ensuring that it looks into the correct structure that holds these custom attributes.

Other choices do not effectively target the necessary approach for the context of retrieving custom fields. For instance, using ExpandoLocalServiceUtil requires the specification of the custom field and might involve additional parameters like company ID or class type, making it less straightforward for this specific task. The user.getExpando() method provides access to the Expando object itself, but lacks the functionality to directly fetch attribute values. Lastly, the PortalUtil class generally serves as a utility for various portal-related tasks rather than specifically managing custom fields for User objects.

Thus, the chosen method correctly fits the

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy