Foren

Best way to deploy an exiting html page with javascript as a portlet

thumbnail
William Gosse, geändert vor 8 Jahren.

Best way to deploy an exiting html page with javascript as a portlet

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Normally i develop my custom portlet using one of the JSF implementations, currently that's Primefaces. However I do have a existing html page that has a pretty extensive piece of JavaScript embedded in it. I was wondering what be the best (maybe the quickest) way to deploy it on liferay.
thumbnail
Miroslav Ligas, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet

Regular Member Beiträge: 152 Beitrittsdatum: 29.07.14 Neueste Beiträge
The simplest way is to use GenericPortlet or LiferayMVC Portlet.
Have a look a this blog post https://www.liferay.com/web/meera.success/blog/-/blogs/liferay-mvc-portlet-development-introduction

Other alternative would be to create a structured web content and include the code in a template.
thumbnail
Philip White, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet

Junior Member Beiträge: 76 Beitrittsdatum: 11.03.15 Neueste Beiträge
Hello Bill,

So the simplest solution would be either what Miroslav suggested first or another alternative, which is to put the HTML markup into a JSP and use the Liferay MVC portlet to dispatch to the JSP. you can find that here.

Here are some other nice instructions.

Hope this helps!

Phil
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Thanks guys! Starting working on the Generic portlet approach with moving the html into the view.jsp. I'm assuming i need to reference any css or external js libraries in the liferay-portlet.xml file?
thumbnail
Miroslav Ligas, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet

Regular Member Beiträge: 152 Beitrittsdatum: 29.07.14 Neueste Beiträge
Yes, you can load external resources. Liferay takes the links form liferay-portlet.xml and adds them in the HTML head (takes care of duplicities).
Don't include files that are added trough liferay-theme.
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
So Is things like:
<header-portlet-javascript>/js/xxx.js</header-portlet-javascript>
for loading JavaScript into the header i assume.

What about something like this:
<script src="https://maps.googleapis.com/maps/api/js?client=gme-moasisgloballlc&amp;sensor=false&amp;v=3.12"></script>
thumbnail
Miroslav Ligas, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet (Antwort)

Regular Member Beiträge: 152 Beitrittsdatum: 29.07.14 Neueste Beiträge
You can also include full URL in the header-portlt-javascript tag. E.g. this works for me:

		<header-portlet-javascript>http://d3js.org/d3.v3.min.js</header-portlet-javascript>
		<header-portlet-javascript>http://dimplejs.org/dist/dimple.v2.1.2.min.js</header-portlet-javascript>
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Best way to deploy an exiting html page with javascript as a portlet

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
This work awesomely great for me. Thanks again for your help