SlideShare a Scribd company logo
1 of 61
Aura	
  Framework	
  Overview	
  
Compiled	
  By	
  Rajdeep	
  Dua,	
  
Salesforce	
  Developer	
  Rela=ons	
  
Dec	
  2015	
  
Samples	
  used	
  in	
  this	
  Presenta=on	
  
	
  
hFps://github.com/rajdeepd/aurasamples	
  
	
  
Components	
  
hFps://github.com/rajdeepd/aurasamples/tree/master/src/main/webapp/
WEB-­‐INF/components/docSample	
  
Why	
  Build	
  Using	
  Aura	
  
•  Out	
  of	
  Box	
  Components	
  
•  Performance	
  
•  Event	
  Driven	
  
•  Faster	
  Development	
  
•  Device	
  Aware	
  and	
  Cross	
  Browser	
  Compa=bility	
  :	
  
Supports	
  touch	
  events,	
  HTML	
  5,	
  CSS3	
  
Performance	
  in	
  Aura	
  
•  Stateful	
  Client	
  and	
  Stateless	
  Server-­‐side	
  
•  Uses	
  JSON	
  to	
  communicate	
  between	
  client	
  and	
  the	
  
server	
  
•  Client	
  calls	
  the	
  Server	
  only	
  if	
  necessary	
  to	
  get	
  
metadata	
  
Faster	
  Development	
  
•  Empowers	
  teams	
  to	
  work	
  faster	
  with	
  out-­‐of-­‐the-­‐box	
  components	
  	
  
•  Building	
  an	
  app	
  with	
  components	
  facilitates	
  parallel	
  design,	
  improving	
  overall	
  
development	
  efficiency.	
  	
  
•  Aura	
  provides	
  the	
  basic	
  constructs	
  of	
  inheritance,	
  polymorphism,	
  and	
  
encapsula=on	
  from	
  object-­‐oriented	
  programming	
  and	
  applies	
  them	
  to	
  
presenta=on	
  layer	
  development.	
  	
  
•  Extend	
  a	
  component	
  or	
  implement	
  a	
  component	
  interface.	
  	
  
•  Components	
  are	
  encapsulated	
  	
  
–  internals	
  stay	
  private	
  
–  public	
  shape	
  is	
  visible	
  to	
  consumers	
  of	
  the	
  component.	
  	
  
•  This	
  strong	
  separa=on	
  gives	
  component	
  authors	
  freedom	
  to	
  change	
  the	
  internal	
  
implementa=on	
  details	
  and	
  insulates	
  component	
  consumers	
  from	
  those	
  changes.	
  	
  
Components	
  
•  Components	
  are	
  the	
  self-­‐contained	
  and	
  reusable	
  units	
  of	
  an	
  app.	
  	
  
•  Represent	
  a	
  reusable	
  sec=on	
  of	
  the	
  UI,	
  and	
  can	
  range	
  in	
  granularity	
  from	
  a	
  
single	
  line	
  of	
  text	
  to	
  an	
  en=re	
  app.	
  	
  
•  The	
  framework	
  includes	
  a	
  set	
  of	
  prebuilt	
  components.	
  	
  
–  Assemble	
  and	
  configure	
  components	
  to	
  form	
  new	
  components	
  in	
  an	
  app.	
  
–  Components	
  are	
  rendered	
  to	
  produce	
  HTML	
  DOM	
  elements	
  within	
  the	
  
browser.	
  	
  
•  A	
  component	
  can	
  contain	
  other	
  components,	
  as	
  well	
  as	
  HTML,	
  CSS,	
  
JavaScript,	
  or	
  any	
  other	
  Web-­‐enabled	
  code.	
  	
  
Events	
  
•  Based	
  on	
  event-­‐driven	
  programming	
  paradigm	
  
•  Write	
  handlers	
  that	
  respond	
  to	
  interface	
  events	
  as	
  they	
  occur.	
  	
  
•  A	
  component	
  registers	
  that	
  it	
  may	
  fire	
  an	
  event	
  in	
  its	
  markup.	
  	
  
•  Events	
  are	
  fired	
  from	
  JavaScript	
  controller	
  ac=ons	
  that	
  are	
  typically	
  triggered	
  by	
  a	
  
user	
  interac=ng	
  with	
  the	
  user	
  interface.	
  	
  
•  There	
  are	
  two	
  types	
  of	
  events	
  in	
  the	
  framework:	
  	
  
–  Component	
  events	
  are	
  handled	
  by	
  the	
  component	
  itself	
  or	
  a	
  component	
  that	
  instan=ates	
  or	
  
contains	
  the	
  component.	
  	
  
–  Applica0on	
  events	
  are	
  essen=ally	
  a	
  tradi=onal	
  publish-­‐subscribe	
  model.	
  All	
  components	
  that	
  
provide	
  a	
  handler	
  for	
  the	
  event	
  are	
  no=fied	
  when	
  the	
  event	
  is	
  fired.	
  	
  
Geng	
  started	
  
•  Follow	
  the	
  steps	
  in	
  readme	
  link	
  
•  Create	
  a	
  mvn	
  project	
  with	
  aura	
  archtype	
  
	
  
$	
  mvn	
  archetype:generate	
  -­‐DarchetypeCatalog=hFp://
repo.auraframework.org/libs-­‐release-­‐local/archetype-­‐catalog.xml	
  
mvn	
  is	
  a	
  framework	
  to	
  manage	
  java	
  dependencies	
  and	
  can	
  be	
  installed	
  on	
  command	
  line	
  
Geng	
  started	
  ..	
  1/3	
  
Enter	
  appropriate	
  values	
  for	
  the	
  following	
  
	
  
Define	
  value	
  for	
  property	
  'groupId':	
  org.myGroup	
  
Define	
  value	
  for	
  property	
  'ar=factId':	
  helloWorld	
  
Define	
  value	
  for	
  property	
  'version':	
  1.0-­‐SNAPSHOT	
  
Define	
  value	
  for	
  property	
  'package':	
  org.myGroup	
  
Build	
  and	
  Run	
  the	
  Project	
  
•  On	
  the	
  command	
  line,	
  navigate	
  to	
  the	
  directory	
  for	
  
your	
  new	
  app.	
  
•  Open	
  the	
  Browser	
  and	
  Open	
  the	
  URL	
  
$	
  cd	
  helloWorld	
  
$	
  Build	
  the	
  app.	
  
$	
  mvn	
  clean	
  install	
  
$	
  mvn	
  jeFy:run	
  
hFp://localhost:8080/helloWorld/helloWorld.app	
  
Basis	
  App	
  Created	
  
<aura:application>
hello web, from the Aura sample app
helloWorld
</aura:application>
•  The	
  following	
  diagram	
  shows	
  the	
  folder	
  structure	
  
for	
  the	
  project.	
  Under	
  the	
  components	
  folder,	
  
there	
  is	
  a	
  helloWorld	
  folder	
  represen=ng	
  the	
  
namespace.	
  	
  
•  Under	
  that	
  folder	
  is	
  a	
  sub-­‐folder,	
  also	
  called	
  
helloWorld,	
  which	
  represents	
  the	
  applica=on,	
  
which	
  is	
  a	
  special	
  type	
  of	
  component.	
  	
  
•  This	
  folder	
  can	
  also	
  contain	
  resources,	
  such	
  
as	
  CSS	
  and	
  JavaScript	
  files.	
  We	
  will	
  add	
  a	
  
new	
  component	
  to	
  the	
  helloWorld	
  
namespace.	
  
Add	
  a	
  Component	
  
•  A	
  Component	
  sits	
  inside	
  an	
  App	
  and	
  is	
  stored	
  in	
  
a	
  .cmp	
  file	
  
•  Create	
  a	
  	
  Component	
  in	
  the	
  following	
  path	
  
helloWorld/helloWorld/helloWorld.cmp.	
  	
  
	
  
	
  
	
  
	
  
<aura:component>
Hello, world!
</aura:component>
"Hello,	
  world!"	
  text	
  is	
  wrapped	
  in	
  the	
  
<aura:component>	
  tags,	
  which	
  appear	
  at	
  the	
  
beginning	
  and	
  end	
  of	
  every	
  component	
  defini=on.	
  
Add	
  a	
  Component	
  …contd	
  
•  Open	
  the	
  following	
  url	
  to	
  view	
  the	
  component	
  
Component	
  Bundles	
  
•  All	
  resources	
  in	
  the	
  component	
  bundle	
  
follow	
  the	
  naming	
  conven=on	
  and	
  are	
  
auto-­‐wired.	
  	
  
•  For	
  example,	
  a	
  controller	
  
•  <componentName>Controller.js	
  is	
  auto-­‐
wired	
  to	
  its	
  component,	
  which	
  means	
  
that	
  you	
  can	
  use	
  the	
  controller	
  within	
  
the	
  scope	
  of	
  that	
  component.	
  
Component	
  IDs	
  
•  Every	
  Component	
  has	
  a	
  Local	
  ID	
  and	
  a	
  Global	
  ID	
  
•  A	
  local	
  ID	
  is	
  unique	
  within	
  a	
  component	
  and	
  is	
  only	
  scoped	
  to	
  the	
  component.	
  
•  Create	
  a	
  local	
  ID	
  by	
  using	
  the	
  aura:id	
  	
  aFribute.	
  	
  
•  For	
  example:	
  
•  	
  Find	
  the	
  buFon	
  component	
  by	
  calling	
  cmp.find("button1") in	
  client-­‐side	
  controller,	
  
where	
  cmp	
  	
  is	
  a	
  reference	
  to	
  the	
  component	
  containing	
  the	
  buFon.	
  
•  Get	
  Local	
  ID	
  using	
  cmp.getLocalId()
.	
  
<ui:button aura:id="button1" label="button1"/>
Local	
  ID	
  Sample	
  
<aura:component>
<ui:button aura:id="button_local_id"
label="Get Local ID" press="{!c.getInput}"/>
<br/>
<ui:outputText aura:id="outName" value="" class="text"/>
</aura:component>
({
getInput : function(cmp, evt) {
var localId = cmp.find("button_local_id").getLocalId()
var myText = cmp.find("outName");
myText.set("v.value", localId);
}
})
localId.cmp	
  
localIdController.js	
  
Components	
  :	
  Global	
  IDs	
  
•  Every	
  component	
  has	
  a	
  unique	
  globalId	
  ,	
  which	
  is	
  the	
  generated	
  run=me-­‐unique	
  ID	
  of	
  the	
  
component	
  instance.	
  	
  
•  A	
  global	
  ID	
  is	
  not	
  guaranteed	
  to	
  be	
  the	
  same	
  beyond	
  the	
  life=me	
  of	
  a	
  component,	
  so	
  it	
  should	
  
never	
  be	
  relied	
  on.	
  
•  To	
  create	
  a	
  unique	
  ID	
  for	
  an	
  HTML	
  element,	
  use	
  the	
  globalId	
  	
  as	
  a	
  prefix	
  or	
  suffix	
  for	
  the	
  element.	
  	
  
•  se	
  the	
  getGlobalId()	
  	
  func=on	
  in	
  JavaScript	
  to	
  get	
  a	
  component's	
  global	
  ID.	
  
	
  
	
  	
  
•  Get	
  a	
  component	
  from	
  its	
  global	
  ID.	
  
	
  
	
  	
  
<div	
  id="{!globalId	
  +	
  '_footer'}"></div>	
  
var	
  cmp	
  =	
  $A.getComponent(globalId);	
  
var	
  globalId	
  =	
  cmp.getGlobalId();	
  
CSS	
  in	
  Components	
  
•  To	
  add	
  CSS	
  to	
  a	
  component,	
  add	
  a	
  new	
  file	
  to	
  the	
  component	
  
bundle	
  called	
  <componentName>.css.	
  	
  
•  The	
  framework	
  automa=cally	
  picks	
  up	
  this	
  new	
  file	
  and	
  auto-­‐wires	
  
it	
  when	
  the	
  component	
  is	
  used	
  in	
  a	
  page.	
  
•  All	
  top-­‐level	
  elements	
  in	
  a	
  component	
  have	
  a	
  special	
  THIS	
  CSS	
  class	
  
added	
  to	
  them.	
  	
  
•  This	
  adds	
  namespacing	
  to	
  CSS	
  and	
  helps	
  prevent	
  one	
  component's	
  
CSS	
  from	
  blowing	
  away	
  another	
  component's	
  styling.	
  	
  
•  The	
  framework	
  throws	
  an	
  error	
  if	
  a	
  CSS	
  file	
  doesn’t	
  follow	
  this	
  
conven=on.	
  
CSS	
  in	
  Components	
  example	
  
.THIS	
  {	
  
background-­‐color:	
  grey;	
  
}	
  
.THIS.white	
  {	
  
background-­‐color:	
  white;	
  
}	
  
.THIS	
  .red	
  {	
  
background-­‐color:	
  red;	
  
}	
  
.THIS	
  .blue	
  {	
  
background-­‐color:	
  blue;	
  
}	
  
.THIS	
  .green	
  {	
  
background-­‐color:	
  green;	
  
}	
  
<aura:component>	
  
	
  <div	
  class="white">	
  
	
  Hello,	
  HTML!	
  
	
  </div>	
  
	
  <h2>Check	
  out	
  the	
  style	
  in	
  this	
  list.</h2>	
  
	
  <ul>	
  
	
  <li	
  class="red">I'm	
  red.</li>	
  
	
  <li	
  class="blue">I'm	
  blue.</li>	
  
	
  <li	
  class="green">I'm	
  green.</li>	
  
	
  </ul>	
  
</aura:component>	
  
•  The	
  top-­‐level	
  elements	
  match	
  the	
  THIS	
  class	
  and	
  render	
  with	
  a	
  grey	
  background.	
  
•  The	
  <div	
  class="white">	
  element	
  matches	
  the	
  .THIS.white	
  selector	
  and	
  renders	
  with	
  a	
  white	
  
background.	
  Note	
  that	
  
•  there	
  is	
  no	
  space	
  in	
  the	
  selector	
  as	
  this	
  rule	
  is	
  for	
  top-­‐level	
  elements.	
  
•  The	
  <li	
  class="red">	
  element	
  matches	
  the	
  .THIS	
  .red	
  selector	
  and	
  renders	
  with	
  a	
  red	
  background.	
  	
  
Component	
  AFributes	
  
•  Component	
  aFributes	
  are	
  like	
  member	
  variables	
  on	
  a	
  class	
  in	
  Java.	
  	
  
•  They	
  are	
  typed	
  fields	
  that	
  are	
  set	
  on	
  a	
  specific	
  instance	
  of	
  a	
  component,	
  
and	
  can	
  be	
  referenced	
  from	
  within	
  the	
  component's	
  markup	
  using	
  an	
  
expression	
  syntax.	
  	
  
•  Use	
  the	
  <aura:aFribute>	
  tag	
  to	
  add	
  an	
  aFribute	
  to	
  the	
  component	
  or	
  app.	
  
	
  Sample	
  :	
  helloAFributes.app:	
  
<aura:component>	
  
<aura:aFribute	
  name="whom"	
  type="String"	
  default="world"/>	
  
Hello	
  {!v.whom}!	
  
</aura:component>	
  
Expressions	
  
•  helloA9ributes.cmp	
  contains	
  an	
  expression,	
  {!v.whom},	
  which	
  is	
  
responsible	
  for	
  the	
  component's	
  dynamic	
  output.	
  
•  {!expression}	
  is	
  the	
  framework's	
  expression	
  syntax.	
  	
  
•  In	
  this	
  case,	
  the	
  expression	
  we	
  are	
  evalua=ng	
  is	
  v.whom.	
  The	
  name	
  of	
  the	
  
aFribute	
  we	
  defined	
  is	
  whom,	
  	
  
•  v	
  is	
  the	
  value	
  provider	
  for	
  a	
  component's	
  aFribute	
  set,	
  which	
  represents	
  
the	
  view.	
  
<aura:component>	
  
<aura:aFribute	
  name="whom"	
  type="String"	
  default="world"/>	
  
Hello	
  {!v.whom}!	
  
</aura:component>	
  
Client	
  Side	
  Events	
  
Client	
  Side	
  Events	
  
•  A	
  client-­‐side	
  controller	
  handles	
  events	
  
within	
  a	
  component.	
  	
  
•  It’s	
  a	
  JavaScript	
  file	
  that	
  defines	
  the	
  
func=ons	
  for	
  all	
  of	
  the	
  component’s	
  ac=ons.	
  
•  Each	
  ac=on	
  func=on	
  takes	
  in	
  three	
  
parameters:	
  	
  
–  component	
  to	
  which	
  the	
  controller	
  belongs,	
  	
  
–  event	
  that	
  the	
  ac=on	
  is	
  handling,	
  
–  the	
  helper	
  if	
  it’s	
  used.	
  	
  
•  Client-­‐side	
  controllers	
  are	
  surrounded	
  by	
  
brackets	
  and	
  curly	
  braces	
  to	
  denote	
  a	
  JSON	
  
object	
  containing	
  a	
  map	
  of	
  name-­‐value	
  
pairs.	
  
{(	
  
	
  handleClick	
  :	
  func=on(cmp,	
  event)	
  {	
  
	
  
	
  }	
  
})	
  
myComponentController.js	
  
Calling	
  Client-­‐Side	
  Controller	
  Ac=ons	
  
•  Example	
  of	
  events	
  on	
  different	
  implementa=ons	
  of	
  
an	
  HTML	
  tag.	
  	
  
•  Example	
  component	
  creates	
  three	
  different	
  buFons,	
  
of	
  which	
  only	
  the	
  last	
  two	
  work	
  properly.	
  	
  
•  Clicking	
  on	
  these	
  buFons	
  updates	
  the	
  text	
  	
  
component	
  aFribute	
  with	
  the	
  specified	
  values.	
  
target.get("v.label")	
  	
  refers	
  to	
  the	
  label	
  	
  aFribute	
  
value	
  on	
  the	
  buFon.	
  
Calling	
  Client-­‐Side	
  Controller	
  Ac=ons	
  
<aura:component>	
  
	
  <aura:aFribute	
  name="text"	
  type="String"	
  default="Just	
  a	
  string.	
  Wai=ng	
  for	
  change."/>	
  
	
  <input	
  type="buFon"	
  value="Flawed	
  HTML	
  BuFon"	
  onclick="alert('this	
  will	
  not	
  work')"/>	
  
	
  <br/>	
  
	
  <input	
  type="buFon"	
  value="Hybrid	
  HTML	
  BuFon"	
  onclick="{!c.handleClick}"/>	
  
	
  <br/>	
  
	
  <ui:buFon	
  label="Framework	
  BuFon"	
  press="{!c.handleClick}"/>	
  
	
  <br/>	
  
	
  {!v.text}	
  
</aura:component>	
  
Calling	
  Client-­‐Side	
  Controller	
  Ac=ons	
  
Ac=ons	
  and	
  Events	
  
Ac=ons	
  and	
  Events	
  ..	
  
•  The	
  framework	
  uses	
  events	
  to	
  relay	
  data	
  between	
  components,	
  which	
  are	
  
usually	
  triggered	
  by	
  a	
  user	
  ac=on.	
  	
  
•  User	
  ac=ons	
  trigger	
  events,	
  but	
  events	
  are	
  not	
  always	
  explicitly	
  triggered	
  
by	
  user	
  ac=ons.	
  
Example	
  :	
  The	
  following	
  buFon	
  is	
  wired	
  up	
  to	
  a	
  browser	
  onclick	
  	
  event	
  in	
  
response	
  to	
  a	
  buFon	
  click.	
  
	
  
	
  
Clicking	
  the	
  buFon	
  invokes	
  the	
  handeClick	
  	
  method	
  in	
  the	
  component’	
  s	
  
client-­‐side	
  controller.	
  
	
  	
  
<ui:buFon	
  label	
  =	
  "Click	
  Me"	
  press	
  =	
  "{!c.handleClick}"	
  />	
  
Events	
  
•  	
  A	
  no=fica=on	
  by	
  the	
  browser	
  regarding	
  an	
  ac=on.	
  Browser	
  
events	
  are	
  handled	
  by	
  client-­‐side	
  JavaScript	
  controllers,	
  as	
  
shown	
  in	
  the	
  previous	
  example.	
  	
  
•  Browser	
  event	
  is	
  not	
  the	
  same	
  as	
  a	
  component	
  event	
  	
  or	
  
applica=on	
  event	
  	
  
•  Component	
  event	
  can	
  be	
  created	
  and	
  fired	
  from	
  a	
  component	
  
controller	
  
Ac=ons	
  and	
  Events	
  
Component
markup
Javascript
Controller
Javascript
Helper
Server Side
Controller
Client Server
1
2
3
6
4
5
7
8
Ac=ons	
  and	
  Events	
  
Component
markup
Javascript
Controller
Javascript
Helper
Server Side
Controller
Client Server
1
2
3
6
4
5
7
8
	
  1.	
  User	
  clicks	
  a	
  buFon	
  or	
  interacts	
  with	
  a	
  
component,	
  triggering	
  a	
  browser	
  event.	
  
	
  
	
  2.	
  The	
  buFon	
  click	
  invokes	
  a	
  client-­‐side	
  
JavaScript	
  controller,	
  which	
  provides	
  some	
  
custom	
  logic	
  before	
  invoking	
  a	
  helper	
  
func=on.	
  
	
  	
  
Ac=ons	
  and	
  Events	
  
Component
markup
Javascript
Controller
Javascript
Helper
Server Side
Controller
Client Server
1
2
3
6
4
5
7
8
3.	
  The	
  JavaScript	
  controller	
  invokes	
  a	
  
helper	
  func=on.	
  	
  
	
  Helper	
  func=on	
  improves	
  code	
  reuse	
  
but	
  it’s	
  op=onal	
  for	
  this	
  example.	
  
	
  
	
  4.	
  The	
  helper	
  func=on	
  calls	
  a	
  server-­‐side	
  
controller	
  method	
  and	
  queues	
  the	
  ac=on.	
  
	
  	
  
Ac=ons	
  and	
  Events	
  
Component
markup
Javascript
Controller
Javascript
Helper
Server Side
Controller
Client Server
1
2
3
6
4
5
7
8
5.	
  The	
  server-­‐side	
  method	
  is	
  invoked	
  and	
  
data	
  is	
  returned.	
  
	
  6.	
  A	
  JavaScript	
  callback	
  func=on	
  is	
  
invoked	
  when	
  the	
  server-­‐side	
  method	
  
completes.	
  
	
  7.	
  The	
  JavaScript	
  callback	
  func=on	
  
evaluates	
  logic	
  and	
  updates	
  the	
  
component’s	
  UI.	
  
8.  User	
  sees	
  the	
  updated	
  content	
  
	
  
Component	
  Events	
  
•  	
  A	
  component	
  event	
  is	
  fired	
  from	
  an	
  instance	
  of	
  a	
  component.	
  	
  
•  A	
  component	
  event	
  can	
  be	
  handled	
  by	
  the	
  component	
  that	
  
fired	
  the	
  event	
  or	
  by	
  a	
  component	
  in	
  the	
  containment	
  
hierarchy	
  that	
  receives	
  the	
  bubbled	
  event.	
  
Event	
  Crea=on	
  
•  Events	
  are	
  created	
  in	
  a	
  file	
  .evt	
  with	
  the	
  same	
  bundle	
  name	
  
•  Use	
  type="COMPONENT" in	
  the	
  <aura:event> tag	
  for	
  a	
  component	
  event.	
  	
  
•  docsample:compEvent	
  component	
  event	
  with	
  one	
  message	
  	
  aFribute.	
  
	
  	
  
<!--docsample:compEvent-->
<aura:event type="COMPONENT">
<!-- add aura:attribute tags to define event shape.
One sample attribute here -->
<aura:attribute name="message" type="String"/>
</aura:event>
Fire	
  an	
  Event	
  
•  	
  A	
  component	
  registers	
  that	
  it	
  may	
  fire	
  an	
  event	
  by	
  using	
  
<aura:registerEvent> in	
  its	
  markup	
  
<aura:registerEvent name="sampleComponentEvent”
type="docsample:compEvent"/>
Register	
  an	
  Event	
  with	
  a	
  Component	
  	
  
var compEvent = cmp.getEvent("sampleComponentEvent");
// Optional: set some data for the event (also known as event shape)
// compEvent.setParams({"myParam" : myValue });
compEvent.fire();
Event	
  Handling	
  
•  Component	
  can	
  handle	
  its	
  own	
  event	
  using	
  the	
  aura:handler
•  The	
  ac=on	
  	
  aFribute	
  of	
  <aura:handler> sets	
  the	
  client-­‐side	
  
controller	
  ac=on	
  to	
  handle	
  the	
  event	
  
<aura:registerEvent name="sampleComponentEvent" type="docsample:compEvent"/>
<aura:handler name="sampleComponentEvent" action="{!c.handleSampleEvent}"/>
Component	
  Event	
  Example	
  
1.  	
  A	
  user	
  clicks	
  a	
  buFon	
  in	
  the	
  no=fier	
  
component,	
  ceNotifier.cmp.	
  
2.  	
  The	
  client-­‐side	
  controller	
  for	
  
ceNotifier.cmp	
  sets	
  a	
  message	
  in	
  a	
  
component	
  event	
  and	
  fires	
  the	
  event.	
  
3.  	
  The	
  handler	
  component,	
  
ceHandler.cmp,	
  contains	
  the	
  no=fier	
  
component,	
  and	
  handles	
  the	
  fired	
  event.	
  
4.  The	
  client-­‐side	
  controller	
  for	
  
ceHandler.cmp	
  sets	
  an	
  aFribute	
  in	
  
ceHandler.cmp	
  based	
  on	
  the	
  data	
  sent	
  
in	
  the	
  event.	
  
ceEvent.evt
ceNotifierController.js
ceNotifier.cmp ceHandler.cmp
ceNotifierHandler.js
Event	
  Bubbling	
  
•  Component	
  event	
  bubbling	
  is	
  similar	
  to	
  
standard	
  event	
  bubbling	
  in	
  browsers.	
  	
  
•  When	
  a	
  component	
  event	
  is	
  fired,	
  the	
  
component	
  that	
  fired	
  the	
  event	
  can	
  
handle	
  it	
  
•  The	
  event	
  then	
  bubbles	
  up	
  and	
  can	
  be	
  
handled	
  by	
  a	
  component	
  in	
  the	
  
containment	
  hierarchy	
  that	
  receives	
  the	
  
bubbled	
  event.	
  
Child Component
Event Source
event
Parent Component
Controller
Controller
Event	
  Bubbling	
  Rules	
  
•  	
  A	
  component	
  event	
  can't	
  be	
  handled	
  by	
  
every	
  parent	
  in	
  the	
  containment	
  hierarchy.	
  
Instead,	
  it	
  bubbles	
  to	
  every	
  facet	
  value	
  
provider	
  in	
  the	
  containment	
  hierarchy.	
  	
  
•  A	
  facet	
  value	
  provider	
  is	
  the	
  outermost	
  
component	
  containing	
  the	
  markup	
  that	
  
references	
  the	
  component	
  firing	
  the	
  event.	
  	
  
•  docsample:eventBubblingParent 	
  
contains	
  
docsample:eventBubblingChild	
  ,	
  which	
  
in	
  turn	
  contains	
  
docsample:eventBubblingGrandchild	
  .	
  
<!--docSample:eventBubblingParent-->
<aura:component>
<docSample:eventBubblingChild>
<docSample:eventBubblingGrandchild />
</docSample:eventBubblingChild>
</aura:component>
Event	
  Bubbling	
  Example	
  
eventBubblingEmitter
event
eventBubblingGrandChild
Controller
Controller
eventBubblingChild
eventBubblingParent
Controller
event
1
2
3
4
1.  docsample:eventBubblingGrandchild	
  	
  fires	
  a	
  
component	
  event,	
  it	
  can	
  handle	
  the	
  event	
  itself.	
  	
  
2.  The	
  event	
  then	
  bubbles	
  up	
  the	
  containment	
  hierarchy.	
  
docsample:eventBubblingChild	
  	
  contains	
  
docsample:eventBubblingGrandchild but	
  it's	
  
not	
  the	
  facet	
  value	
  provider	
  as	
  it's	
  not	
  the	
  outermost	
  
component	
  in	
  the	
  markup	
  so	
  it	
  can't	
  handle	
  the	
  
bubbled	
  event.	
  
3.  docsample:eventBubblingParent	
  	
  is	
  the	
  facet	
  
value	
  provider	
  as	
  docsample:eventBubblingChild	
  	
  
is	
  in	
  its	
  markup.	
  
4.  docsample:eventBubblingParent	
  	
  can	
  handle	
  the	
  
event.	
  
Referring	
  External	
  JavaScript	
  Libraries	
  
•  The	
  <aura:clientLibrary> tag	
  enables	
  you	
  to	
  specify	
  JavaScript	
  or	
  CSS	
  
libraries	
  that	
  you	
  want	
  to	
  use.	
  	
  
•  Use	
  the	
  tag	
  in	
  a	
  .cmp	
  or	
  .app	
  resource.	
  
<!-- External URL -->
<aura:clientLibrary url="https://jquery.org/latest/jquery.js" type="JS" />
<!-- Absolute path for local library-->
<aura:clientLibrary url="/absolute/path/to/file.js" type="JS" />
<!-- Relative path for local library-->
<aura:clientLibrary url="relative/path/to/file.css" type="CSS" />
•  Where	
  type	
  is	
  "JS" or	
  "CSS"
Referencing	
  External	
  JS	
  :	
  Sample	
  
Reference	
  :
hFps://github.com/rajdeepd/aurasamples/tree/master/src/main/webapp/WEB-­‐INF/components/docSample/clickEventsExternalJS	
  
external.js
ClickMe
clickEventsExternalJS.cmp
ui:button
{…}
ui:outputText aura:id="outName"
clickEventsExternalJS
Controller.js
<aura:clientLibrary
url="/aura/external.js"
type="JS" />
Toggle	
  with	
  CSS	
  
.THIS.toggle {
display: none;
}
<aura:component>
<div class="blue">
<ui:button label="Toggle" press="{!c.toggle}"/>
</div>
<p aura:id="text">Now you see me</p>
</aura:component>
({
toggle : function(component, event, helper) {
var toggleText = component.find("text");
$A.util.toggleClass(toggleText, "toggle");
}
})
Using	
  Aura	
  with	
  Server	
  Side	
  	
  
Using	
  Java	
  Servlets	
  with	
  Aura	
  
package org.auraframework.demo.controllers;
import org.auraframework.system.Annotations.AuraEnabled;
import org.auraframework.system.Annotations.Controller;
import org.auraframework.system.Annotations.Key;
@Controller
public class SimpleController {
@AuraEnabled	
  
public static String serverEcho(@Key("firstName")String firstName) {
return ("From server: " + firstName);
}
}
Create	
  a	
  server-­‐side	
  controller	
  in	
  Java	
  and	
  use	
  the	
  @Controller	
  and	
  @AuraEnabled	
  
annota=on	
  and	
  to	
  enable	
  client-­‐	
  and	
  server-­‐side	
  access	
  to	
  the	
  controller	
  method.	
  
Using	
  Java	
  Servlets	
  with	
  Aura	
  
package org.auraframework.demo.controllers;
import org.auraframework.system.Annotations.AuraEnabled;
import org.auraframework.system.Annotations.Controller;
import org.auraframework.system.Annotations.Key;
@Controller
public class SimpleController {
@AuraEnabled	
  
public static String serverEcho(@Key("firstName")String firstName) {
return ("From server: " + firstName);
}
}
Create	
  a	
  server-­‐side	
  controller	
  in	
  Java	
  and	
  use	
  the	
  @Controller	
  and	
  @AuraEnabled	
  
annota=on	
  and	
  to	
  enable	
  client-­‐	
  and	
  server-­‐side	
  access	
  to	
  the	
  controller	
  method.	
  
Using	
  Servlet	
  with	
  Aura	
  ..contd	
  
•  Methods	
  must	
  be	
  sta=c	
  and	
  marked	
  public	
  or	
  global.	
  	
  
•  Non-­‐sta=c	
  methods	
  are	
  not	
  supported.	
  
•  If	
  a	
  method	
  returns	
  an	
  object,	
  instance	
  methods	
  that	
  retrieve	
  the	
  value	
  of	
  the	
  
object’s	
  instance	
  field	
  must	
  be	
  public.	
  
@Controller
public class SimpleController {
@AuraEnabled	
  
public static String serverEcho(@Key("firstName")String firstName) {
return ("From server: " + firstName);
}
}
Using	
  Serlvet	
  :	
  Client	
  Side	
  Components	
  
•  Aura	
  Component	
  
•  Aura	
  Client	
  Side	
  Controller	
  
•  Aura	
  App	
  
	
  
Using	
  Servlets	
  :	
  Client	
  Side	
  Components	
  
({
"echo" : function(cmp) {
…..
}
)}
<aura:component controller="org.auraframework.demo.controllers.SimpleController"">
<aura:attribute name="firstName" type="String" default="world"/>
<ui:button label="Call server" press="{!c.echo}"/>
</aura:component>
SimpleClient.cmp	
  
SimpleClientController.js	
  
Using	
  Java	
  Servlets	
  :	
  Client	
  Side	
  Components	
  
•  Client-­‐side	
  controller	
  
includes	
  an	
  echo	
  ac=on	
  
that	
  executes	
  a	
  
serverEcho	
  method	
  on	
  a	
  
server-­‐side	
  controller.	
  
•  The	
  client-­‐side	
  controller	
  
sets	
  a	
  callback	
  ac=on	
  that	
  
is	
  invoked	
  ater	
  the	
  
server-­‐side	
  ac=on	
  returns	
  
	
  
({
"echo" : function(cmp) {
var action = cmp.get("c.serverEcho");
action.setParams({ firstName : cmp.get("v.firstName") });
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
//Update the state and response
}
else if (state === "ERROR") {
…
}
});
$A.enqueueAction(action);
}
})
Using	
  Java	
  Servlet	
  :	
  Client	
  Side	
  Components	
  
•  $A.enqueueAc=on(ac=on
)	
  to	
  add	
  the	
  server-­‐side	
  
controller	
  ac=on	
  to	
  the	
  
queue	
  of	
  ac=ons	
  to	
  be	
  
executed.	
  
({
"echo" : function(cmp) {
var action = cmp.get("c.serverEcho");
action.setParams({ firstName : cmp.get("v.firstName") });
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
//Update the state and response
}
else if (state === "ERROR") {
…
}
});
$A.enqueueAction(action);
}
})
Demo	
  
Using	
  Aura	
  in	
  Force.com	
  
Using	
  Apex	
  with	
  Aura	
  
public with sharing class SimpleServerSideController {
//Use @AuraEnabled to enable client- and server-side access to the method
@AuraEnabled
public static String serverEcho(String firstName) {
return ('Hello from the server, ' + firstName);
}
}
Create	
  a	
  server-­‐side	
  controller	
  in	
  Apex	
  and	
  use	
  the	
  @AuraEnabled	
  annota=on	
  to	
  
enable	
  client-­‐	
  and	
  server-­‐side	
  access	
  to	
  the	
  controller	
  method.	
  
Using	
  Apex	
  with	
  Aura	
  ..contd	
  
public with sharing class SimpleServerSideController {
//Use @AuraEnabled to enable client- and server-side access to the method
@AuraEnabled
public static String serverEcho(String firstName) {
return ('Hello from the server, ' + firstName);
}
}
•  Methods	
  must	
  be	
  sta=c	
  and	
  marked	
  public	
  or	
  global.	
  	
  
•  Non-­‐sta=c	
  methods	
  are	
  not	
  supported.	
  
•  If	
  a	
  method	
  returns	
  an	
  object,	
  instance	
  methods	
  that	
  retrieve	
  the	
  value	
  of	
  the	
  
object’s	
  instance	
  field	
  must	
  be	
  public.	
  
Using	
  Apex	
  :	
  Client	
  Side	
  Components	
  
•  Aura	
  Component	
  
•  Aura	
  Client	
  Side	
  Controller	
  
•  Aura	
  App	
  
	
  
Using	
  Apex	
  :	
  Client	
  Side	
  Components	
  
({
"echo" : function(cmp) {
…..
}
)}
<aura:component controller="SimpleServerSideController">
<aura:attribute name="firstName" type="String" default="world"/>
<ui:button label="Call server" press="{!c.echo}"/>
</aura:component>
SimpleLightningComponent.cmp	
  
SimpleLightningComponentController.js	
  
Using	
  Apex	
  :	
  Client	
  Side	
  Components	
  
•  Client-­‐side	
  controller	
  
includes	
  an	
  echo	
  ac=on	
  
that	
  executes	
  a	
  
serverEcho	
  method	
  on	
  a	
  
server-­‐side	
  controller.	
  
•  The	
  client-­‐side	
  controller	
  
sets	
  a	
  callback	
  ac=on	
  that	
  
is	
  invoked	
  ater	
  the	
  
server-­‐side	
  ac=on	
  returns	
  
	
  
({
"echo" : function(cmp) {
var action = cmp.get("c.serverEcho");
action.setParams({ firstName : cmp.get("v.firstName") });
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
//Update the state and response
}
else if (state === "ERROR") {
…
}
});
$A.enqueueAction(action);
}
})
Using	
  Apex	
  :	
  Client	
  Side	
  Components	
  
•  $A.enqueueAc=on(ac=on
)	
  to	
  add	
  the	
  server-­‐side	
  
controller	
  ac=on	
  to	
  the	
  
queue	
  of	
  ac=ons	
  to	
  be	
  
executed.	
  
({
"echo" : function(cmp) {
var action = cmp.get("c.serverEcho");
action.setParams({ firstName : cmp.get("v.firstName") });
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
//Update the state and response
}
else if (state === "ERROR") {
…
}
});
$A.enqueueAction(action);
}
})
Demo	
  

More Related Content

What's hot

Angular tutorial
Angular tutorialAngular tutorial
Angular tutorialRohit Gupta
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Krishna-Kumar
 
CI/CD with Openshift and Jenkins
CI/CD with Openshift and JenkinsCI/CD with Openshift and Jenkins
CI/CD with Openshift and JenkinsAri LiVigni
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshoploodse
 
API Security : Patterns and Practices
API Security : Patterns and PracticesAPI Security : Patterns and Practices
API Security : Patterns and PracticesPrabath Siriwardena
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroFabrício Rissetto
 
From a monolith to microservices + REST: The evolution of LinkedIn's architec...
From a monolith to microservices + REST: The evolution of LinkedIn's architec...From a monolith to microservices + REST: The evolution of LinkedIn's architec...
From a monolith to microservices + REST: The evolution of LinkedIn's architec...Karan Parikh
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101Deep Datta
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical WritingSarah Maddox
 

What's hot (20)

Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!
 
GitOps with Gitkube
GitOps with GitkubeGitOps with Gitkube
GitOps with Gitkube
 
CI/CD with Openshift and Jenkins
CI/CD with Openshift and JenkinsCI/CD with Openshift and Jenkins
CI/CD with Openshift and Jenkins
 
React-JS.pptx
React-JS.pptxReact-JS.pptx
React-JS.pptx
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshop
 
API Security : Patterns and Practices
API Security : Patterns and PracticesAPI Security : Patterns and Practices
API Security : Patterns and Practices
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
Context API in React
Context API in ReactContext API in React
Context API in React
 
Dockerfile
Dockerfile Dockerfile
Dockerfile
 
Reversing Google Protobuf protocol
Reversing Google Protobuf protocolReversing Google Protobuf protocol
Reversing Google Protobuf protocol
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
From a monolith to microservices + REST: The evolution of LinkedIn's architec...
From a monolith to microservices + REST: The evolution of LinkedIn's architec...From a monolith to microservices + REST: The evolution of LinkedIn's architec...
From a monolith to microservices + REST: The evolution of LinkedIn's architec...
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical Writing
 

Viewers also liked

Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5rajdeep
 
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)Yury Bondarau
 
virtualization-vs-containerization-paas
virtualization-vs-containerization-paasvirtualization-vs-containerization-paas
virtualization-vs-containerization-paasrajdeep
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetesrajdeep
 
Open VSwitch .. Use it for your day to day needs
Open VSwitch .. Use it for your day to day needsOpen VSwitch .. Use it for your day to day needs
Open VSwitch .. Use it for your day to day needsrranjithrajaram
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)rajdeep
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introductionrajdeep
 
Virtualized network with openvswitch
Virtualized network with openvswitchVirtualized network with openvswitch
Virtualized network with openvswitchSim Janghoon
 
Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조Seung-Hoon Baek
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Diverajdeep
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch YongKi Kim
 
Introduction to visualforce
Introduction to visualforceIntroduction to visualforce
Introduction to visualforceRinku Saini
 
Location scouting 2
Location scouting 2Location scouting 2
Location scouting 2Zoe Brant
 
SSO with SAML 2.0
SSO with SAML 2.0SSO with SAML 2.0
SSO with SAML 2.0Thieu Mao
 
Setting up Security in Your Salesforce Instance
Setting up Security in Your Salesforce InstanceSetting up Security in Your Salesforce Instance
Setting up Security in Your Salesforce InstanceSalesforce Developers
 
Code Signing with CPK
Code Signing with CPKCode Signing with CPK
Code Signing with CPKZhi Guan
 
Cloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , KeynoteCloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , Keynoterajdeep
 
Introduction to MidoNet
Introduction to MidoNetIntroduction to MidoNet
Introduction to MidoNetTaku Fukushima
 

Viewers also liked (20)

Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5
 
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
 
virtualization-vs-containerization-paas
virtualization-vs-containerization-paasvirtualization-vs-containerization-paas
virtualization-vs-containerization-paas
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Open VSwitch .. Use it for your day to day needs
Open VSwitch .. Use it for your day to day needsOpen VSwitch .. Use it for your day to day needs
Open VSwitch .. Use it for your day to day needs
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introduction
 
Virtualized network with openvswitch
Virtualized network with openvswitchVirtualized network with openvswitch
Virtualized network with openvswitch
 
Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Dive
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch
 
Introduction to visualforce
Introduction to visualforceIntroduction to visualforce
Introduction to visualforce
 
Location scouting 2
Location scouting 2Location scouting 2
Location scouting 2
 
SSO with SAML 2.0
SSO with SAML 2.0SSO with SAML 2.0
SSO with SAML 2.0
 
Vf ppt (1)
Vf ppt (1)Vf ppt (1)
Vf ppt (1)
 
Setting up Security in Your Salesforce Instance
Setting up Security in Your Salesforce InstanceSetting up Security in Your Salesforce Instance
Setting up Security in Your Salesforce Instance
 
Code Signing with CPK
Code Signing with CPKCode Signing with CPK
Code Signing with CPK
 
MidoNet deep dive
MidoNet deep diveMidoNet deep dive
MidoNet deep dive
 
Cloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , KeynoteCloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , Keynote
 
Introduction to MidoNet
Introduction to MidoNetIntroduction to MidoNet
Introduction to MidoNet
 

Similar to Aura Framework Overview

Building a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignBuilding a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignSalesforce Developers
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven developmentGil Fink
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework BasicMario Romano
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Salesforce Developers
 
Lightning Components Explained
Lightning Components ExplainedLightning Components Explained
Lightning Components ExplainedAtul Gupta(8X)
 
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Atlassian
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupAnsley Rodrigues
 
Lightning web components
Lightning web components Lightning web components
Lightning web components Cloud Analogy
 
Native script overview
Native script overviewNative script overview
Native script overviewBaskar rao Dsn
 
My Very First Zf App Part One
My Very First Zf App   Part OneMy Very First Zf App   Part One
My Very First Zf App Part Oneisaaczfoster
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Nidhi Sharma
 
Native script overview
Native script overviewNative script overview
Native script overviewBaskar rao Dsn
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsDECK36
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshareSaleemMalik52
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting startedTejinderMakkar
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry Vinnik
 

Similar to Aura Framework Overview (20)

Building a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignBuilding a Lightning App with Angular Material Design
Building a Lightning App with Angular Material Design
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1
 
An Overview of Angular 4
An Overview of Angular 4 An Overview of Angular 4
An Overview of Angular 4
 
Lightning Components Explained
Lightning Components ExplainedLightning Components Explained
Lightning Components Explained
 
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setup
 
Maven
MavenMaven
Maven
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
 
sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
Native script overview
Native script overviewNative script overview
Native script overview
 
My Very First Zf App Part One
My Very First Zf App   Part OneMy Very First Zf App   Part One
My Very First Zf App Part One
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
 
Native script overview
Native script overviewNative script overview
Native script overview
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 

More from rajdeep

Openstack Overview
Openstack OverviewOpenstack Overview
Openstack Overviewrajdeep
 
VMware Hybrid Cloud Service - Overview
VMware Hybrid Cloud Service - OverviewVMware Hybrid Cloud Service - Overview
VMware Hybrid Cloud Service - Overviewrajdeep
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overviewrajdeep
 
Openstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overviewOpenstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overviewrajdeep
 
Deploy Cloud Foundry using bosh_bootstrap
Deploy Cloud Foundry using bosh_bootstrapDeploy Cloud Foundry using bosh_bootstrap
Deploy Cloud Foundry using bosh_bootstraprajdeep
 
Managing Activity Backstack
Managing Activity BackstackManaging Activity Backstack
Managing Activity Backstackrajdeep
 
Cloud Foundry Architecture and Overview
Cloud Foundry Architecture and OverviewCloud Foundry Architecture and Overview
Cloud Foundry Architecture and Overviewrajdeep
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundryrajdeep
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platformrajdeep
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Enginerajdeep
 

More from rajdeep (10)

Openstack Overview
Openstack OverviewOpenstack Overview
Openstack Overview
 
VMware Hybrid Cloud Service - Overview
VMware Hybrid Cloud Service - OverviewVMware Hybrid Cloud Service - Overview
VMware Hybrid Cloud Service - Overview
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
 
Openstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overviewOpenstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overview
 
Deploy Cloud Foundry using bosh_bootstrap
Deploy Cloud Foundry using bosh_bootstrapDeploy Cloud Foundry using bosh_bootstrap
Deploy Cloud Foundry using bosh_bootstrap
 
Managing Activity Backstack
Managing Activity BackstackManaging Activity Backstack
Managing Activity Backstack
 
Cloud Foundry Architecture and Overview
Cloud Foundry Architecture and OverviewCloud Foundry Architecture and Overview
Cloud Foundry Architecture and Overview
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platform
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 

Recently uploaded

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 

Aura Framework Overview

  • 1. Aura  Framework  Overview   Compiled  By  Rajdeep  Dua,   Salesforce  Developer  Rela=ons   Dec  2015  
  • 2. Samples  used  in  this  Presenta=on     hFps://github.com/rajdeepd/aurasamples     Components   hFps://github.com/rajdeepd/aurasamples/tree/master/src/main/webapp/ WEB-­‐INF/components/docSample  
  • 3. Why  Build  Using  Aura   •  Out  of  Box  Components   •  Performance   •  Event  Driven   •  Faster  Development   •  Device  Aware  and  Cross  Browser  Compa=bility  :   Supports  touch  events,  HTML  5,  CSS3  
  • 4. Performance  in  Aura   •  Stateful  Client  and  Stateless  Server-­‐side   •  Uses  JSON  to  communicate  between  client  and  the   server   •  Client  calls  the  Server  only  if  necessary  to  get   metadata  
  • 5. Faster  Development   •  Empowers  teams  to  work  faster  with  out-­‐of-­‐the-­‐box  components     •  Building  an  app  with  components  facilitates  parallel  design,  improving  overall   development  efficiency.     •  Aura  provides  the  basic  constructs  of  inheritance,  polymorphism,  and   encapsula=on  from  object-­‐oriented  programming  and  applies  them  to   presenta=on  layer  development.     •  Extend  a  component  or  implement  a  component  interface.     •  Components  are  encapsulated     –  internals  stay  private   –  public  shape  is  visible  to  consumers  of  the  component.     •  This  strong  separa=on  gives  component  authors  freedom  to  change  the  internal   implementa=on  details  and  insulates  component  consumers  from  those  changes.    
  • 6. Components   •  Components  are  the  self-­‐contained  and  reusable  units  of  an  app.     •  Represent  a  reusable  sec=on  of  the  UI,  and  can  range  in  granularity  from  a   single  line  of  text  to  an  en=re  app.     •  The  framework  includes  a  set  of  prebuilt  components.     –  Assemble  and  configure  components  to  form  new  components  in  an  app.   –  Components  are  rendered  to  produce  HTML  DOM  elements  within  the   browser.     •  A  component  can  contain  other  components,  as  well  as  HTML,  CSS,   JavaScript,  or  any  other  Web-­‐enabled  code.    
  • 7. Events   •  Based  on  event-­‐driven  programming  paradigm   •  Write  handlers  that  respond  to  interface  events  as  they  occur.     •  A  component  registers  that  it  may  fire  an  event  in  its  markup.     •  Events  are  fired  from  JavaScript  controller  ac=ons  that  are  typically  triggered  by  a   user  interac=ng  with  the  user  interface.     •  There  are  two  types  of  events  in  the  framework:     –  Component  events  are  handled  by  the  component  itself  or  a  component  that  instan=ates  or   contains  the  component.     –  Applica0on  events  are  essen=ally  a  tradi=onal  publish-­‐subscribe  model.  All  components  that   provide  a  handler  for  the  event  are  no=fied  when  the  event  is  fired.    
  • 8. Geng  started   •  Follow  the  steps  in  readme  link   •  Create  a  mvn  project  with  aura  archtype     $  mvn  archetype:generate  -­‐DarchetypeCatalog=hFp:// repo.auraframework.org/libs-­‐release-­‐local/archetype-­‐catalog.xml   mvn  is  a  framework  to  manage  java  dependencies  and  can  be  installed  on  command  line  
  • 9. Geng  started  ..  1/3   Enter  appropriate  values  for  the  following     Define  value  for  property  'groupId':  org.myGroup   Define  value  for  property  'ar=factId':  helloWorld   Define  value  for  property  'version':  1.0-­‐SNAPSHOT   Define  value  for  property  'package':  org.myGroup  
  • 10. Build  and  Run  the  Project   •  On  the  command  line,  navigate  to  the  directory  for   your  new  app.   •  Open  the  Browser  and  Open  the  URL   $  cd  helloWorld   $  Build  the  app.   $  mvn  clean  install   $  mvn  jeFy:run   hFp://localhost:8080/helloWorld/helloWorld.app  
  • 11. Basis  App  Created   <aura:application> hello web, from the Aura sample app helloWorld </aura:application> •  The  following  diagram  shows  the  folder  structure   for  the  project.  Under  the  components  folder,   there  is  a  helloWorld  folder  represen=ng  the   namespace.     •  Under  that  folder  is  a  sub-­‐folder,  also  called   helloWorld,  which  represents  the  applica=on,   which  is  a  special  type  of  component.     •  This  folder  can  also  contain  resources,  such   as  CSS  and  JavaScript  files.  We  will  add  a   new  component  to  the  helloWorld   namespace.  
  • 12. Add  a  Component   •  A  Component  sits  inside  an  App  and  is  stored  in   a  .cmp  file   •  Create  a    Component  in  the  following  path   helloWorld/helloWorld/helloWorld.cmp.             <aura:component> Hello, world! </aura:component> "Hello,  world!"  text  is  wrapped  in  the   <aura:component>  tags,  which  appear  at  the   beginning  and  end  of  every  component  defini=on.  
  • 13. Add  a  Component  …contd   •  Open  the  following  url  to  view  the  component  
  • 14. Component  Bundles   •  All  resources  in  the  component  bundle   follow  the  naming  conven=on  and  are   auto-­‐wired.     •  For  example,  a  controller   •  <componentName>Controller.js  is  auto-­‐ wired  to  its  component,  which  means   that  you  can  use  the  controller  within   the  scope  of  that  component.  
  • 15. Component  IDs   •  Every  Component  has  a  Local  ID  and  a  Global  ID   •  A  local  ID  is  unique  within  a  component  and  is  only  scoped  to  the  component.   •  Create  a  local  ID  by  using  the  aura:id    aFribute.     •  For  example:   •   Find  the  buFon  component  by  calling  cmp.find("button1") in  client-­‐side  controller,   where  cmp    is  a  reference  to  the  component  containing  the  buFon.   •  Get  Local  ID  using  cmp.getLocalId() .   <ui:button aura:id="button1" label="button1"/>
  • 16. Local  ID  Sample   <aura:component> <ui:button aura:id="button_local_id" label="Get Local ID" press="{!c.getInput}"/> <br/> <ui:outputText aura:id="outName" value="" class="text"/> </aura:component> ({ getInput : function(cmp, evt) { var localId = cmp.find("button_local_id").getLocalId() var myText = cmp.find("outName"); myText.set("v.value", localId); } }) localId.cmp   localIdController.js  
  • 17. Components  :  Global  IDs   •  Every  component  has  a  unique  globalId  ,  which  is  the  generated  run=me-­‐unique  ID  of  the   component  instance.     •  A  global  ID  is  not  guaranteed  to  be  the  same  beyond  the  life=me  of  a  component,  so  it  should   never  be  relied  on.   •  To  create  a  unique  ID  for  an  HTML  element,  use  the  globalId    as  a  prefix  or  suffix  for  the  element.     •  se  the  getGlobalId()    func=on  in  JavaScript  to  get  a  component's  global  ID.         •  Get  a  component  from  its  global  ID.         <div  id="{!globalId  +  '_footer'}"></div>   var  cmp  =  $A.getComponent(globalId);   var  globalId  =  cmp.getGlobalId();  
  • 18. CSS  in  Components   •  To  add  CSS  to  a  component,  add  a  new  file  to  the  component   bundle  called  <componentName>.css.     •  The  framework  automa=cally  picks  up  this  new  file  and  auto-­‐wires   it  when  the  component  is  used  in  a  page.   •  All  top-­‐level  elements  in  a  component  have  a  special  THIS  CSS  class   added  to  them.     •  This  adds  namespacing  to  CSS  and  helps  prevent  one  component's   CSS  from  blowing  away  another  component's  styling.     •  The  framework  throws  an  error  if  a  CSS  file  doesn’t  follow  this   conven=on.  
  • 19. CSS  in  Components  example   .THIS  {   background-­‐color:  grey;   }   .THIS.white  {   background-­‐color:  white;   }   .THIS  .red  {   background-­‐color:  red;   }   .THIS  .blue  {   background-­‐color:  blue;   }   .THIS  .green  {   background-­‐color:  green;   }   <aura:component>    <div  class="white">    Hello,  HTML!    </div>    <h2>Check  out  the  style  in  this  list.</h2>    <ul>    <li  class="red">I'm  red.</li>    <li  class="blue">I'm  blue.</li>    <li  class="green">I'm  green.</li>    </ul>   </aura:component>   •  The  top-­‐level  elements  match  the  THIS  class  and  render  with  a  grey  background.   •  The  <div  class="white">  element  matches  the  .THIS.white  selector  and  renders  with  a  white   background.  Note  that   •  there  is  no  space  in  the  selector  as  this  rule  is  for  top-­‐level  elements.   •  The  <li  class="red">  element  matches  the  .THIS  .red  selector  and  renders  with  a  red  background.    
  • 20. Component  AFributes   •  Component  aFributes  are  like  member  variables  on  a  class  in  Java.     •  They  are  typed  fields  that  are  set  on  a  specific  instance  of  a  component,   and  can  be  referenced  from  within  the  component's  markup  using  an   expression  syntax.     •  Use  the  <aura:aFribute>  tag  to  add  an  aFribute  to  the  component  or  app.    Sample  :  helloAFributes.app:   <aura:component>   <aura:aFribute  name="whom"  type="String"  default="world"/>   Hello  {!v.whom}!   </aura:component>  
  • 21. Expressions   •  helloA9ributes.cmp  contains  an  expression,  {!v.whom},  which  is   responsible  for  the  component's  dynamic  output.   •  {!expression}  is  the  framework's  expression  syntax.     •  In  this  case,  the  expression  we  are  evalua=ng  is  v.whom.  The  name  of  the   aFribute  we  defined  is  whom,     •  v  is  the  value  provider  for  a  component's  aFribute  set,  which  represents   the  view.   <aura:component>   <aura:aFribute  name="whom"  type="String"  default="world"/>   Hello  {!v.whom}!   </aura:component>  
  • 23. Client  Side  Events   •  A  client-­‐side  controller  handles  events   within  a  component.     •  It’s  a  JavaScript  file  that  defines  the   func=ons  for  all  of  the  component’s  ac=ons.   •  Each  ac=on  func=on  takes  in  three   parameters:     –  component  to  which  the  controller  belongs,     –  event  that  the  ac=on  is  handling,   –  the  helper  if  it’s  used.     •  Client-­‐side  controllers  are  surrounded  by   brackets  and  curly  braces  to  denote  a  JSON   object  containing  a  map  of  name-­‐value   pairs.   {(    handleClick  :  func=on(cmp,  event)  {      }   })   myComponentController.js  
  • 24. Calling  Client-­‐Side  Controller  Ac=ons   •  Example  of  events  on  different  implementa=ons  of   an  HTML  tag.     •  Example  component  creates  three  different  buFons,   of  which  only  the  last  two  work  properly.     •  Clicking  on  these  buFons  updates  the  text     component  aFribute  with  the  specified  values.   target.get("v.label")    refers  to  the  label    aFribute   value  on  the  buFon.  
  • 25. Calling  Client-­‐Side  Controller  Ac=ons   <aura:component>    <aura:aFribute  name="text"  type="String"  default="Just  a  string.  Wai=ng  for  change."/>    <input  type="buFon"  value="Flawed  HTML  BuFon"  onclick="alert('this  will  not  work')"/>    <br/>    <input  type="buFon"  value="Hybrid  HTML  BuFon"  onclick="{!c.handleClick}"/>    <br/>    <ui:buFon  label="Framework  BuFon"  press="{!c.handleClick}"/>    <br/>    {!v.text}   </aura:component>  
  • 28. Ac=ons  and  Events  ..   •  The  framework  uses  events  to  relay  data  between  components,  which  are   usually  triggered  by  a  user  ac=on.     •  User  ac=ons  trigger  events,  but  events  are  not  always  explicitly  triggered   by  user  ac=ons.   Example  :  The  following  buFon  is  wired  up  to  a  browser  onclick    event  in   response  to  a  buFon  click.       Clicking  the  buFon  invokes  the  handeClick    method  in  the  component’  s   client-­‐side  controller.       <ui:buFon  label  =  "Click  Me"  press  =  "{!c.handleClick}"  />  
  • 29. Events   •   A  no=fica=on  by  the  browser  regarding  an  ac=on.  Browser   events  are  handled  by  client-­‐side  JavaScript  controllers,  as   shown  in  the  previous  example.     •  Browser  event  is  not  the  same  as  a  component  event    or   applica=on  event     •  Component  event  can  be  created  and  fired  from  a  component   controller  
  • 30. Ac=ons  and  Events   Component markup Javascript Controller Javascript Helper Server Side Controller Client Server 1 2 3 6 4 5 7 8
  • 31. Ac=ons  and  Events   Component markup Javascript Controller Javascript Helper Server Side Controller Client Server 1 2 3 6 4 5 7 8  1.  User  clicks  a  buFon  or  interacts  with  a   component,  triggering  a  browser  event.      2.  The  buFon  click  invokes  a  client-­‐side   JavaScript  controller,  which  provides  some   custom  logic  before  invoking  a  helper   func=on.      
  • 32. Ac=ons  and  Events   Component markup Javascript Controller Javascript Helper Server Side Controller Client Server 1 2 3 6 4 5 7 8 3.  The  JavaScript  controller  invokes  a   helper  func=on.      Helper  func=on  improves  code  reuse   but  it’s  op=onal  for  this  example.      4.  The  helper  func=on  calls  a  server-­‐side   controller  method  and  queues  the  ac=on.      
  • 33. Ac=ons  and  Events   Component markup Javascript Controller Javascript Helper Server Side Controller Client Server 1 2 3 6 4 5 7 8 5.  The  server-­‐side  method  is  invoked  and   data  is  returned.    6.  A  JavaScript  callback  func=on  is   invoked  when  the  server-­‐side  method   completes.    7.  The  JavaScript  callback  func=on   evaluates  logic  and  updates  the   component’s  UI.   8.  User  sees  the  updated  content    
  • 34. Component  Events   •   A  component  event  is  fired  from  an  instance  of  a  component.     •  A  component  event  can  be  handled  by  the  component  that   fired  the  event  or  by  a  component  in  the  containment   hierarchy  that  receives  the  bubbled  event.  
  • 35. Event  Crea=on   •  Events  are  created  in  a  file  .evt  with  the  same  bundle  name   •  Use  type="COMPONENT" in  the  <aura:event> tag  for  a  component  event.     •  docsample:compEvent  component  event  with  one  message    aFribute.       <!--docsample:compEvent--> <aura:event type="COMPONENT"> <!-- add aura:attribute tags to define event shape. One sample attribute here --> <aura:attribute name="message" type="String"/> </aura:event>
  • 36. Fire  an  Event   •   A  component  registers  that  it  may  fire  an  event  by  using   <aura:registerEvent> in  its  markup   <aura:registerEvent name="sampleComponentEvent” type="docsample:compEvent"/> Register  an  Event  with  a  Component     var compEvent = cmp.getEvent("sampleComponentEvent"); // Optional: set some data for the event (also known as event shape) // compEvent.setParams({"myParam" : myValue }); compEvent.fire();
  • 37. Event  Handling   •  Component  can  handle  its  own  event  using  the  aura:handler •  The  ac=on    aFribute  of  <aura:handler> sets  the  client-­‐side   controller  ac=on  to  handle  the  event   <aura:registerEvent name="sampleComponentEvent" type="docsample:compEvent"/> <aura:handler name="sampleComponentEvent" action="{!c.handleSampleEvent}"/>
  • 38. Component  Event  Example   1.   A  user  clicks  a  buFon  in  the  no=fier   component,  ceNotifier.cmp.   2.   The  client-­‐side  controller  for   ceNotifier.cmp  sets  a  message  in  a   component  event  and  fires  the  event.   3.   The  handler  component,   ceHandler.cmp,  contains  the  no=fier   component,  and  handles  the  fired  event.   4.  The  client-­‐side  controller  for   ceHandler.cmp  sets  an  aFribute  in   ceHandler.cmp  based  on  the  data  sent   in  the  event.   ceEvent.evt ceNotifierController.js ceNotifier.cmp ceHandler.cmp ceNotifierHandler.js
  • 39. Event  Bubbling   •  Component  event  bubbling  is  similar  to   standard  event  bubbling  in  browsers.     •  When  a  component  event  is  fired,  the   component  that  fired  the  event  can   handle  it   •  The  event  then  bubbles  up  and  can  be   handled  by  a  component  in  the   containment  hierarchy  that  receives  the   bubbled  event.   Child Component Event Source event Parent Component Controller Controller
  • 40. Event  Bubbling  Rules   •   A  component  event  can't  be  handled  by   every  parent  in  the  containment  hierarchy.   Instead,  it  bubbles  to  every  facet  value   provider  in  the  containment  hierarchy.     •  A  facet  value  provider  is  the  outermost   component  containing  the  markup  that   references  the  component  firing  the  event.     •  docsample:eventBubblingParent   contains   docsample:eventBubblingChild  ,  which   in  turn  contains   docsample:eventBubblingGrandchild  .   <!--docSample:eventBubblingParent--> <aura:component> <docSample:eventBubblingChild> <docSample:eventBubblingGrandchild /> </docSample:eventBubblingChild> </aura:component>
  • 41. Event  Bubbling  Example   eventBubblingEmitter event eventBubblingGrandChild Controller Controller eventBubblingChild eventBubblingParent Controller event 1 2 3 4 1.  docsample:eventBubblingGrandchild    fires  a   component  event,  it  can  handle  the  event  itself.     2.  The  event  then  bubbles  up  the  containment  hierarchy.   docsample:eventBubblingChild    contains   docsample:eventBubblingGrandchild but  it's   not  the  facet  value  provider  as  it's  not  the  outermost   component  in  the  markup  so  it  can't  handle  the   bubbled  event.   3.  docsample:eventBubblingParent    is  the  facet   value  provider  as  docsample:eventBubblingChild     is  in  its  markup.   4.  docsample:eventBubblingParent    can  handle  the   event.  
  • 42. Referring  External  JavaScript  Libraries   •  The  <aura:clientLibrary> tag  enables  you  to  specify  JavaScript  or  CSS   libraries  that  you  want  to  use.     •  Use  the  tag  in  a  .cmp  or  .app  resource.   <!-- External URL --> <aura:clientLibrary url="https://jquery.org/latest/jquery.js" type="JS" /> <!-- Absolute path for local library--> <aura:clientLibrary url="/absolute/path/to/file.js" type="JS" /> <!-- Relative path for local library--> <aura:clientLibrary url="relative/path/to/file.css" type="CSS" /> •  Where  type  is  "JS" or  "CSS"
  • 43. Referencing  External  JS  :  Sample   Reference  : hFps://github.com/rajdeepd/aurasamples/tree/master/src/main/webapp/WEB-­‐INF/components/docSample/clickEventsExternalJS   external.js ClickMe clickEventsExternalJS.cmp ui:button {…} ui:outputText aura:id="outName" clickEventsExternalJS Controller.js <aura:clientLibrary url="/aura/external.js" type="JS" />
  • 44. Toggle  with  CSS   .THIS.toggle { display: none; } <aura:component> <div class="blue"> <ui:button label="Toggle" press="{!c.toggle}"/> </div> <p aura:id="text">Now you see me</p> </aura:component> ({ toggle : function(component, event, helper) { var toggleText = component.find("text"); $A.util.toggleClass(toggleText, "toggle"); } })
  • 45. Using  Aura  with  Server  Side    
  • 46. Using  Java  Servlets  with  Aura   package org.auraframework.demo.controllers; import org.auraframework.system.Annotations.AuraEnabled; import org.auraframework.system.Annotations.Controller; import org.auraframework.system.Annotations.Key; @Controller public class SimpleController { @AuraEnabled   public static String serverEcho(@Key("firstName")String firstName) { return ("From server: " + firstName); } } Create  a  server-­‐side  controller  in  Java  and  use  the  @Controller  and  @AuraEnabled   annota=on  and  to  enable  client-­‐  and  server-­‐side  access  to  the  controller  method.  
  • 47. Using  Java  Servlets  with  Aura   package org.auraframework.demo.controllers; import org.auraframework.system.Annotations.AuraEnabled; import org.auraframework.system.Annotations.Controller; import org.auraframework.system.Annotations.Key; @Controller public class SimpleController { @AuraEnabled   public static String serverEcho(@Key("firstName")String firstName) { return ("From server: " + firstName); } } Create  a  server-­‐side  controller  in  Java  and  use  the  @Controller  and  @AuraEnabled   annota=on  and  to  enable  client-­‐  and  server-­‐side  access  to  the  controller  method.  
  • 48. Using  Servlet  with  Aura  ..contd   •  Methods  must  be  sta=c  and  marked  public  or  global.     •  Non-­‐sta=c  methods  are  not  supported.   •  If  a  method  returns  an  object,  instance  methods  that  retrieve  the  value  of  the   object’s  instance  field  must  be  public.   @Controller public class SimpleController { @AuraEnabled   public static String serverEcho(@Key("firstName")String firstName) { return ("From server: " + firstName); } }
  • 49. Using  Serlvet  :  Client  Side  Components   •  Aura  Component   •  Aura  Client  Side  Controller   •  Aura  App    
  • 50. Using  Servlets  :  Client  Side  Components   ({ "echo" : function(cmp) { ….. } )} <aura:component controller="org.auraframework.demo.controllers.SimpleController""> <aura:attribute name="firstName" type="String" default="world"/> <ui:button label="Call server" press="{!c.echo}"/> </aura:component> SimpleClient.cmp   SimpleClientController.js  
  • 51. Using  Java  Servlets  :  Client  Side  Components   •  Client-­‐side  controller   includes  an  echo  ac=on   that  executes  a   serverEcho  method  on  a   server-­‐side  controller.   •  The  client-­‐side  controller   sets  a  callback  ac=on  that   is  invoked  ater  the   server-­‐side  ac=on  returns     ({ "echo" : function(cmp) { var action = cmp.get("c.serverEcho"); action.setParams({ firstName : cmp.get("v.firstName") }); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { //Update the state and response } else if (state === "ERROR") { … } }); $A.enqueueAction(action); } })
  • 52. Using  Java  Servlet  :  Client  Side  Components   •  $A.enqueueAc=on(ac=on )  to  add  the  server-­‐side   controller  ac=on  to  the   queue  of  ac=ons  to  be   executed.   ({ "echo" : function(cmp) { var action = cmp.get("c.serverEcho"); action.setParams({ firstName : cmp.get("v.firstName") }); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { //Update the state and response } else if (state === "ERROR") { … } }); $A.enqueueAction(action); } })
  • 54. Using  Aura  in  Force.com  
  • 55. Using  Apex  with  Aura   public with sharing class SimpleServerSideController { //Use @AuraEnabled to enable client- and server-side access to the method @AuraEnabled public static String serverEcho(String firstName) { return ('Hello from the server, ' + firstName); } } Create  a  server-­‐side  controller  in  Apex  and  use  the  @AuraEnabled  annota=on  to   enable  client-­‐  and  server-­‐side  access  to  the  controller  method.  
  • 56. Using  Apex  with  Aura  ..contd   public with sharing class SimpleServerSideController { //Use @AuraEnabled to enable client- and server-side access to the method @AuraEnabled public static String serverEcho(String firstName) { return ('Hello from the server, ' + firstName); } } •  Methods  must  be  sta=c  and  marked  public  or  global.     •  Non-­‐sta=c  methods  are  not  supported.   •  If  a  method  returns  an  object,  instance  methods  that  retrieve  the  value  of  the   object’s  instance  field  must  be  public.  
  • 57. Using  Apex  :  Client  Side  Components   •  Aura  Component   •  Aura  Client  Side  Controller   •  Aura  App    
  • 58. Using  Apex  :  Client  Side  Components   ({ "echo" : function(cmp) { ….. } )} <aura:component controller="SimpleServerSideController"> <aura:attribute name="firstName" type="String" default="world"/> <ui:button label="Call server" press="{!c.echo}"/> </aura:component> SimpleLightningComponent.cmp   SimpleLightningComponentController.js  
  • 59. Using  Apex  :  Client  Side  Components   •  Client-­‐side  controller   includes  an  echo  ac=on   that  executes  a   serverEcho  method  on  a   server-­‐side  controller.   •  The  client-­‐side  controller   sets  a  callback  ac=on  that   is  invoked  ater  the   server-­‐side  ac=on  returns     ({ "echo" : function(cmp) { var action = cmp.get("c.serverEcho"); action.setParams({ firstName : cmp.get("v.firstName") }); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { //Update the state and response } else if (state === "ERROR") { … } }); $A.enqueueAction(action); } })
  • 60. Using  Apex  :  Client  Side  Components   •  $A.enqueueAc=on(ac=on )  to  add  the  server-­‐side   controller  ac=on  to  the   queue  of  ac=ons  to  be   executed.   ({ "echo" : function(cmp) { var action = cmp.get("c.serverEcho"); action.setParams({ firstName : cmp.get("v.firstName") }); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { //Update the state and response } else if (state === "ERROR") { … } }); $A.enqueueAction(action); } })