Coder Social home page Coder Social logo

vaadin / addressbook-portlet Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 3.0 2.59 MB

Example application of using Portlets with Vaadin 14.2

Home Page: https://vaadin.com

Java 96.08% JavaScript 3.21% TypeScript 0.71%
portlet-applications portal pluto java portlet portlets

addressbook-portlet's Introduction

Address Book Portlet Demo for Liferay 7

An example project to showcase how Vaadin 23.2+ portlet support works in a Liferay 7 container. Clone the repository and import the project to the IDE of your choice as a Maven project. You need to have Java 11 installed.

The documentation for Vaadin Portlet support is available here.

Running the portlet under Liferay

Before the portlet application can be run, it must be deployed to a portal for this branch the portal supported is Liferay:

  1. Build the whole project using mvn install in the root

  2. We assume Liferay is running in http://localhost:8080/, an easy way to run a local copy of Liferay is to use their official docker images. Below is an example of a docker-compose file you can use (note the used Liferay version, 7.2+ should work).

version: "2.2"
services:
    liferay-dev:
        image: liferay/portal:7.2.1-ga2
        environment:
            - LIFERAY_JAVASCRIPT_PERIOD_SINGLE_PERIOD_PAGE_PERIOD_APPLICATION_PERIOD_ENABLED=false
        ports:
            - 8080:8080
            - 8000:8000
        volumes:
            - ./deploy:/mnt/liferay/deploy
            - ./files:/mnt/liferay/files
  1. Add the following to the end of the last line in Tomcat's setenv.sh (/var/liferay/tomcat-<version>/bin) before starting Liferay. When using the above docker-compose file place an edited copy of setenv.sh in ./files/tomcat/bin.
 -Dvaadin.portlet.static.resources.mapping=/o/vaadin-portlet-static/
  1. Download and add the Jna dependency JARs of a certain version into /var/liferay/tomcat-<version>/webapps/ROOT/WEB-INF/lib/ (or shielded-container-lib/):

    How to copy these files is described [here](https://learn.liferay. com/dxp/latest/en/installation-and-upgrades/installing-liferay/using-liferay -docker-images/providing-files-to-the-container.html#using-docker-cp)

    This is needed because Liferay uses an older version of Jna and running Vaadin Portlet in dev mode causes a conflict of dependencies used by Liferay and Vaadin License Checker (NoClassDefFound exception).

    Here is a useful [docs](https://learn.liferay. com/dxp/latest/en/building-applications/reference/jars-excluded-from-wabs. html) describing how to add third-party dependency version you want.

  2. Run docker-compose up

  3. Deploy all wars: addressbook-grid/target/address-book-grid.war, addressbook-form/target/address-book-form.war and addressbook-bundle/target/vaadin-portlet-static.war, to your docker container by copying them to ./deploy/ (the copied files should disappear when deployed).

  4. Wait for the bundles to start, then visit http://localhost:8080/. Set up a new user if you're running Liferay for the first time. Default is [email protected]/test. Log in into Liferay.

  5. The deployed portlet needs to be added to a portal page. Do this by

  • Selecting the Plus or the Pen icon near top right of the page (exact placement and look varies by Liferay version) add elements to the current page.
  • Under Widgets on the right sidebar find Vaadin Sample category under which you will find entries for Contact List and Contact Form, drag and drop them onto the page.
  • If at the top right of the page, in edit mode, you see a Publish button, use it to make your changes public (7.3+).

Remote debugging for Liferay

In order to remote debug your portlet under Liferay add the following to the end of the last line in Tomcat's setenv.sh (/var/liferay/tomcat-<version>/bin) before starting Liferay. When using the above docker-compose file place an edited copy of setenv.sh in ./files/tomcat/bin before docker-compose up.

 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

Remote debugging (JDWP) is now available on port 8000 (to activate in IntelliJ, choose Run -> Attach to Process...).

Production build

To build the production .war run:

mvn package -Pproduction

Deploy all wars: addressbook-grid/target/address-book-grid.war, addressbook-form/target/address-book-form.war and addressbook-bundle/target/vaadin-portlet-static.war, to your web server / portal.

Adding a new Portlet module

To add a new Portlet module to the project create a default vaadin portlet module. The module should contain its own portlet.xml file.

Add to the new module the resource file flow-build-info.json into ./src/main/resources/META-INF/VAADIN/config with the contents:

{
  "externalStatsUrl": "/o/vaadin-portlet-static/VAADIN/config/stats.json"
}

Add the module sources to the bundle module build-helper-maven-plugin as added sources:

<sources>
  <source>../moduleName/src/main/java</source>
  ...
</sources>

Then build the whole project again with mvn install

Current known issues running under Liferay

See Vaadin Portlet release notes for a limitation and known issues list.

addressbook-portlet's People

Contributors

bbmarkus avatar caalador avatar dependabot[bot] avatar mehdi-vaadin avatar mshabarov avatar mstahv avatar ujoni avatar

Watchers

 avatar  avatar  avatar  avatar

addressbook-portlet's Issues

Event from grid to form is not working.

Running addressbook on 1.0.0.alpha5 for some reason the event fired by grid doesn't make the from portlet get an event.

On the client it would seem that both portlets have registered to the hub and the event from the grid seems to be handled correctly by the hub.:

Received xhr message: for(;;);[{"syncId":5,"clientId":5,"execute":[[5,null,[0,9],"return (function() { this.$server['}p']($0, true, $1)}).apply($2)"],[6,null,[0,9],"return (function() { this.$server['}p']($0, true, $1)}).apply($2)"],[[0,12],"return (function() { window.Vaadin.Flow.Portlets.fireEvent('Pluto_address_book_grid_ContactList_510736053_2_', 'contact-selected', {contactId: ['7']})}).apply($0)"]],"timings":[7865,2]}]
VM1014 client-2968C9E98973969FFAE746FDEDC2EE09.cache.js:990 Handling message from server
VM1014 client-2968C9E98973969FFAE746FDEDC2EE09.cache.js:937 Handling dependencies
VM1014 client-2968C9E98973969FFAE746FDEDC2EE09.cache.js:198 handleUIDLMessage: 0 ms
VM1014 client-2968C9E98973969FFAE746FDEDC2EE09.cache.js:198  Processing time was 1ms
portletHub.js:2792 Executing action for portlet: Pluto_address_book_form_ContactForm_510736053_1_
portletHub.js:2833 form element null
portletHub.js:786 impl: executing action. parms=[object Object], element=null
portletHub.js:797 ajax action URL: /pluto/portal/About Apache Pluto/__pdaddress-book-grid.ContactList!510736053%7C2;0/__pdaddress-book-form.ContactForm!510736053%7C1;1/__aa1/__av1;vaadin.ev:contact-selected/__av1;vaadin.uid:0/__av1;vaadin.wn:contextpathservletpath-279733526-0.39708119268467224/__av1;contactId:7/__av1;_csrf:81d1c152-6d4d-408d-a74b-0a1cfb2836f8
portletHub.js:847 ajax action: POST using URL with parameters
portletHub.js:648 Decoding string: >>{"portlets" : {
   "Pluto_address_book_grid_ContactList_510736053_2_" : {
      "state" : {
         "parameters" : {
         }, 
         "portletMode" : "view", 
         "windowState" : "normal"
      },
      "pubParms" : {},
      "allowedPM" : ["view"],
      "allowedWS" : ["normal", "maximized", "minimized"],
      "renderData" : {
         "content" : null,
         "mimeType" : "text/plain"
      },
      "urlpid" : "address-book-grid.ContactList!510736053|2"
   },
   "Pluto_address_book_form_ContactForm_510736053_1_" : {
      "state" : {
         "parameters" : {
         }, 
         "portletMode" : "view", 
         "windowState" : "normal"
      },
      "pubParms" : {},
      "allowedPM" : ["view", "edit"],
      "allowedWS" : ["normal", "maximized", "minimized"],
      "renderData" : {
         "content" : null,
         "mimeType" : "text/plain"
      },
      "urlpid" : "address-book-form.ContactForm!510736053|1"
   }
},
"prpMap" : {
}}<<
portletHub.js:668 decoded state for 2 portlets. # changed = 0
VM1014 client-2968C9E98973969FFAE746FDEDC2EE09.cache.js:198 Sending xhr message to server: {"csrfToken":"b099ef85-8231-4973-8bd5-5b15403125bd","rpc":[{"type":"event","node":1,"event":"ui-poll"}],"syncId":4,"clientId":4}
VM1014 client-2968C9E98973969FFAE746FDEDC2EE09.cache.js:198 

Remove the dependency on flow-server from back-end module

Despite the fact that the backend module doesn't use any class from flow-server, it has a dependency on flow-server to use classes in the dependency hierarchy of flow-server E.g. HashCodeGenerator, elemental.json.* and LoggerFactory. I the required direct dependencies should be added to avoid making backend depend on flow-server.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.