Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LSNA 2016 3rd party JS frameworks

LSNA 2016 3rd party JS frameworks

Integrating 3rd part javascript frameworks in Liferay.

Bryce Osterhaus

September 15, 2016
Tweet

Other Decks in Technology

Transcript

  1. Integrating Liferay DXP with Popular UI Frameworks Or specifically React.js

    Bryce Osterhaus, Software Engineer Michael Hadley, Software Engineer
  2. Workshop Goals • Set up environments • Package application on

    deploy • Rapid development with hot-module-reloading • Create a Todo Application built with React.js • Integrate Application with Liferay’s web services
  3. Setup • Download workshop folder from flash drive • Java

    8 & Node ^4.2.0 • Install NPM dependencies at ./modules/dxp-react-workshop/todo/todo-web npm install
  4. React + Webpack Create modular components Package components into a

    single asset Serve assets and run application
  5. What is React.js? Front-end view layer that handles rendering and

    event binding with unidirectional data flow.
  6. What does a React component do? • Renders HTML or

    other React components • Handles event binding • Manages “state” of component Display State Render
  7. What is Webpack? A module bundler that takes modules with

    dependencies and generates static assets representing those modules.
  8. Todo Application Requirements • Build and deploy application in one

    command • Add “todo” tasks • Render tasks • Complete tasks • Persist tasks in database via Liferay web-services
  9. Modules Located at: workshop/modules/dxp-react-workshop/todo Modules: • todo-api & todo-service -

    See workshop “Create Amazing Web Services with Liferay DXP” • todo-web (The one we care about)
  10. Deploying Modules Navigate back to root directory /workshop Run command:

    or What is happening?: • Building modules into .jars • Deploying them to tomcat bundle ./gradlew deploy gradlew.bat deploy
  11. Deploying App Navigate back to root directory /workshop Run command:

    or What is happening?: • Building modules into .jars • Deploying them to tomcat bundle ./gradlew deploy gradlew.bat deploy
  12. Webpack Configuration From todo-web root run: Modify script in view.jsp

    Re-deploy node ./node_modules/webpack/bin/webpack.js
  13. Webpack + Gradle File: todo-web/build.gradle • Import ExecuteNodeTask • Create

    gradle task • Task depends on npmInstall (due to webpack) • Task classes depends webpack Re-deploy
  14. Re-deploy Modules Navigate back to root directory /workshop Run command:

    Verify that javascript is running ./gradlew deploy
  15. Take Aways (what did we learn?) • Package javascript via

    Webpack • Use Webpack bundle within Liferay • React within Liferay • Develop our javascript without having to re-deploy • Liferay Services integrating within a React component