掲示板

Directly access portlet html in Liferay 7.0!

thumbnail
7年前 に Eric Chow によって更新されました。

Directly access portlet html in Liferay 7.0!

Junior Member 投稿: 79 参加年月日: 05/02/25 最新の投稿
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
7年前 に Neil Griffin によって更新されました。

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
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
7年前 に Juan Gonzalez によって更新されました。

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
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.