Foren

Using AngularJS + RESTful services with Liferay Portlets

John Jaraceski, geändert vor 9 Jahren.

Using AngularJS + RESTful services with Liferay Portlets

New Member Beiträge: 3 Beitrittsdatum: 09.12.14 Neueste Beiträge
I am working developing a project with Liferay 6.2. In this project, we aren't using any tools or components or issues from Liferay to develop our business routines. The Liferay's resources are restricted to develop routines related to documents, collaboration, socials, wikis, forums, blogs.

For specific and business related routines, we are using AngularJS + UI Bootstrap to code the front-end layer. Whereas the business layer is encapsulated in RESTful services developed with Jersey.

The front-end access the data through a provider written using $resource directives in AngularjS. Then, the front-end communicate only with RESTful services to get and to send data. And the portlet is only used to put the front-end in Liferay.

The back-end is very simple. It is just a traditional service written in Jersey.

The basic strucutre of our portlet is:

[indent][source: RESTful services]
  • MyServices.java

[/indent]
[indent][source : Portlet - Java]
  • MyPortlet.java

[/indent]
[indent][source: Portlet - WebApp]
  • html\myportlet\js
    • app.js
    • controllers.js
    • providers.js
  • partials
    • list.html
    • edit.html
    • confirm.html
  • init.jsp
  • view.jsp

[/indent]
So, I would like some help to validate this architecture. Is that a good approach? Do you have some comments about our architecture?

Also, some more specific questions:

  • Maybe, we will lost some important features of Liferay using this architecture? What are?
  • Are there advantages in using portlet with Liferay PortletMVC or Spring Portlet for this architecture? What are?
  • The access to the service layer could be made via portlet instead of AngularJS? What are the advantages?
  • How we could authenticate the access to the service layer?
    • HTTP Basic Authorization is enough?
    • Spring Security is a better alternative? Why?



Thanks.
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Using AngularJS + RESTful services with Liferay Portlets

Liferay Legend Beiträge: 14916 Beitrittsdatum: 02.09.06 Neueste Beiträge
Your biggest issue, IMHO, is trying to keep these two pieces separate when they really cannot be...

For example, authentication. As a Liferay user you have already logged in and you should have been authenticated. Instead of leveraging that, you are thinking about pulling in http basic auth or spring security?

There is also fun with switching between an angular context and a Liferay context. Imagine you render a page with your angular app on it. User is happily using their angular app, but they click on a nav menu item to go look at a web content article or something. Then they come back to the page w/ your angular app on it - What happens? Has the angular app been storing session state data so when the user comes back their last view can be restored? If your angular app is also instanceable, is it tracking separate copies of the session state data so each instance can be restored?

As far as hosting the app, either spring mvc or liferay mvc will work, in the end they are just containers for the javascript and hosting the services, so it is 6 of one, one half dozen of the other.

Angular will work as a foundation for SPAs in Liferay, but they take a little more thought to get off the ground than a simple portlet. Liferay has a project underway, Senna, which is supposed to help facilitate SPA portlets. You might check it out...
thumbnail
Jack Bakker, geändert vor 8 Jahren.

RE: Using AngularJS + RESTful services with Liferay Portlets

Liferay Master Beiträge: 978 Beitrittsdatum: 03.01.10 Neueste Beiträge
haven't seen much activity wrt sennajs... but now see http://metaljs.com