留言板

Directly access portlet html in Liferay 7.0!

thumbnail
Eric Chow,修改在7 年前。

Directly access portlet html in Liferay 7.0!

Junior Member 帖子: 79 加入日期: 05-2-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
Neil Griffin,修改在7 年前。

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend 帖子: 2655 加入日期: 05-7-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
Juan Gonzalez,修改在7 年前。

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.