Fórum

Directly access portlet html in Liferay 7.0!

thumbnail
Eric Chow, modificado 7 Anos atrás.

Directly access portlet html in Liferay 7.0!

Junior Member Postagens: 79 Data de Entrada: 25/02/05 Postagens Recentes
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, modificado 7 Anos atrás.

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
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, modificado 7 Anos atrás.

RE: Directly access portlet html in Liferay 7.0!

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
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.