PD1 User Interface 5 β Questions and Answers
Question 1: Which method of the NavigationMixin allows an LWC component to redirect the user to an external URL?
- this[NavigationMixin.Navigate]({ type: 'standard__webPage', attributes: { url: 'https://...' } }) (Correct answer)
- this.navigate('https://...')
- NavigationMixin.redirect(this, 'https://...')
- window.open('https://...') via the navigation module
Correct answer: this[NavigationMixin.Navigate]({ type: 'standard__webPage', attributes: { url: 'https://...' } })
NavigationMixin.Navigate is called with a page reference object using type 'standard__webPage' to open an external URL.
Question 2: In Aura components, which event type propagates from a child component up through the component hierarchy without requiring explicit event passing?
- Component event
- Application event (Correct answer)
- System event
- Custom DOM event
Correct answer: Application event
Application events in Aura are fired globally and can be handled by any component in the hierarchy, unlike component events which only travel up through direct ancestors.
Question 3: A developer notices that changes to a nested object property in an LWC do not trigger a re-render. What is the most appropriate fix?
- Decorate the property with @track
- Use Object.assign() to create a new object reference and reassign the property (Correct answer)
- Call this.render() manually after the change
- Mark the property with @observable
Correct answer: Use Object.assign() to create a new object reference and reassign the property
LWC's reactivity tracks object references; reassigning a new object (e.g., via spread or Object.assign) triggers re-render even without @track.
Question 4: Which Salesforce feature allows a Lightning Web Component to listen for platform events or Streaming API messages in real time?
- The @wire(getRecord) adapter
- Apex Continuation
- Empathy API via lightning/empathyApi
- Lightning Message Service or the empApi module (Correct answer)
Correct answer: Lightning Message Service or the empApi module
The lightning/empApi module in LWC subscribes to CometD-based Streaming API channels, including Platform Events and PushTopic events.
Question 5: What is the primary purpose of the Lightning Message Service (LMS)?
- To send email notifications from a Lightning component
- To enable communication between LWC, Aura, and Visualforce components on the same page (Correct answer)
- To log user actions to a custom object for auditing
- To replace Apex remote actions with declarative message passing
Correct answer: To enable communication between LWC, Aura, and Visualforce components on the same page
LMS provides a publish-subscribe messaging bus that allows LWC, Aura, and VF components (via a bridge) to communicate across different technology stacks on one page.
Question 6: In Visualforce, how do you invoke a JavaScript remoting call to an Apex method?
- Use <apex:callout> tag with the method name
- Use Visualforce.remoting.Manager.invokeAction() with the fully qualified method name
- Annotate the Apex method with @RemoteAction and call it via JavaScript using Visualforce.remoting (Correct answer)
- Call the Apex method directly using apex.executeAction() in JS
Correct answer: Annotate the Apex method with @RemoteAction and call it via JavaScript using Visualforce.remoting
JavaScript Remoting requires the @RemoteAction annotation on the Apex method, then call it from JS using the Visualforce.remoting.Manager.invokeAction or namespace syntax.
Question 7: A developer needs a custom Lightning component property to appear as a configurable field in Lightning App Builder with a dropdown of options. What must be defined?
- An <apex:inputSelect> inside the component template
- A <targetConfig> element with a <property> tag and datasource attribute in js-meta.xml (Correct answer)
- A @wire adapter that fetches picklist values at design time
- A design resource file (.design) defining the attribute with allowedValues
Correct answer: A <targetConfig> element with a <property> tag and datasource attribute in js-meta.xml
In LWC, <targetConfigs> in js-meta.xml lets you define <property> elements with datasource='\"picklist values\"' to render a dropdown in App Builder.
Which method of the NavigationMixin allows an LWC component to redirect the user to an external URL?