[Salesforce] Component

hyunsooSong·2022년 9월 14일
0

Salesforce

목록 보기
3/13
post-thumbnail

🧩 Component


1. Component Bundle

  • Component : 필수요소, UI
  • Controller : Event 처리
  • Helper : 재사용 가능한 Func 구현
  • Apex Controller : Helper에서 받은 데이터 DML 처리

2. MVC 구조

💫 MVC - Model(Helper), View(Component), Controller
  • 흐름 : Component → Controller → Helper → ApexController

3. 핸들러에서 사용할 aura 변수 생성

  • 변수명에 해당하는 이름으로 사용한다.
<aura:attribute name=’변수명’>

4. init, change

  • 시작하거나 변경할 때 실행할 함수를 작성할 때는 무조건 name을 init / change로 써야한다.
<aura:handler name=”init” action=”c.fnInit”>
<aura:handler name=”change” value=”v.value” action=”c.fnChange”>

5. aura:component

<aura:component description="StudentInfo" controller="StudentInfoController" implements="force:hasRecordId,force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes">
  • Component의 Controller는 ApexController 를 적어줘야 연결이 됨

  • Component에서 implements 꼭 해줘야함 (작성하지 않을 시, edit page 화면, Quick Action 컴포넌트 선택 창에 노출되지 않는다.)
    • cf) 커뮤니티 화면일 경우 추가 코드 : forceCommunity:availableForAllPageTypes

6. aura:attribute, 변수 선언

<aura:attribute name="objStudent" type="Object" />
<aura:attribute name="recordId" type="String" />

7. aura:handler, 핸들러 선언

<aura:handler name="init" value="{!this}" action="{!c.fnInit}" />
profile
🥕 개발 공부 중 🥕

0개의 댓글