Foren

Directly access portlet html in Liferay 7.0!

thumbnail
Eric Chow, geändert vor 7 Jahren.

Directly access portlet html in Liferay 7.0!

Junior Member Beiträge: 79 Beitrittsdatum: 25.02.05 Neueste Beiträge
Hello,

I created a WAR (JSF based) portlet and put it into the deploy folder of Liferay portal 7.0.
It deployed successfully and work fine.

In the portlet (TestPortlet), I add a servlet for showing the PDF.

When I tried to access the servlet by using the URL (http://localhost:8080/TestPortlet/servlet/show.pdf).

It just shows portal error (no resources found).

I can do this in Liferay 6.2 but now can't in 7.0.

Best regards,
Eric
thumbnail
Neil Griffin, geändert vor 7 Jahren.

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Eric,

In the forum thread titled Liferay 7: WAR deployment into deploy folder not recognize @annotation it seems like you were able to get your servlet working by registering it with <servlet> in web.xml -- is that correct?

I wanted to mention though, that we recommend that you use a JSF2 ResourceHandler to serve PDFs rather than a servlet. The ResourceHandler mechanism will work in both JSF webapps and portlets, since it is supported by Liferay Faces Bridge. An example ResourceHandler that serves up a PDF can be found in the jsf2-export-pdf-portlet demo.

Kind Regards,

Neil
thumbnail
Juan Gonzalez, geändert vor 7 Jahren.

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträge
Eric Chow:

When I tried to access the servlet by using the URL (http://localhost:8080/TestPortlet/servlet/show.pdf).

It just shows portal error (no resources found).


Hi Eric,

what Neil said is the right way for resource downloading in a JSF portlet.

Anyway, if you want to check the servlet approach, as now the web container "role" will be played by Liferay instead of the traditional web servers, path will be different too, and a "/o" prefix will be added to the web context path.

Can you try using this URL?

http://localhost:8080/o/TestPortlet/servlet/show.pdf

Thanks.