Plat-Dev-201 practice question 23 of 30

A developer creates a Lightning web component that imports a method within an Apex class. When a Validate button is pressed, the method runs to execute complex validations. In this implementation scenario, which two options are.. of the Controller according to the MVC architecture? Choose 2 answers

Full set: 204 questions
Answer options
A: HTML file
B: Apex class Correct answer
C: JavaScript file Correct answer
D: XML file
Correct Answer:
B. Apex class; C. JavaScript file
Explanation

In the Model-View-Controller (MVC) architecture as applied to Lightning Web Components, the controller is responsible for handling user input and mediating between the Model (data) and the View (UI). The JavaScript file (.js) acts as the client-side controller, managing events and component state. The Apex class (.cls) functions as the server-side controller, executing business logic and accessing the database (the Model).

Why Incorrect

A. The HTML file (.html) defines the structure and presentation of the component, making it the View in the MVC pattern.
D. The XML file (.js-meta.xml) is a configuration file that defines metadata for the component, such as its visibility in the Lightning App Builder. It is not part of the MVC architecture.

References

1. Lightning Web Components Dev Guide, "Component Architecture". The guide describes the roles: HTML for the view, JavaScript for the controller logic, and Apex for server-side control and data access.

2. Trailhead, "Lightning Web Components Basics" module, "Create a Lightning Web Component" unit. It explains, "The HTML file provides the structure for your component. The JavaScript file defines the core business logic and event handling. The XML file defines the metadata values for the component."

3. Salesforce Architects, "Architect's Guide to Building Forms on Salesforce", section "Lightning Web Components". It describes LWC's architecture, mapping the JavaScript to the client-side controller and Apex to the server-side controller.

Scroll to Top