开发者

include Liferay portal jsps from hook

开发者 https://www.devze.com 2023-03-14 23:10 出处:网络
my question is about Liferay hooks and portlets 6.0. I have hook with jsps overiding liferay portlet ones. e.g. document_library/view.jsp - tested - works fine. (I have custom-jsp-dir set etc )

my question is about Liferay hooks and portlets 6.0.

I have hook with jsps overiding liferay portlet ones. e.g. document_library/view.jsp - tested - works fine. (I have custom-jsp-dir set etc )

Now I want to create my portlet in this hook, which at the end renders hook's document_library/view.jsp.

But I get error:

org.apache.jasper.JasperException: /WEB-INF/html/portlet/document_library/view.jsp(17,1) File "/html/portlet/document_library/init.jsp" not found

I didn't create init.jsp - I want this hook to use Liferay document_library o开发者_C百科riginal one.

Can you help me?

I asked also here http://www.liferay.com/community/forums/-/message_boards/message/9583788

Thank you


Short answer: You can't.

Reason: JSPs from a hooks custom-jsp directory will be copied over to the portal - thus they will run in liferay's classloader. Your portlet however will run in your plugin's classloader, thus have no access to liferay's jsps.

JSPs in hooks (those that are declared as custom-jsps for the portal) cannot be used from portlets in the same plugin. This is by design, you can't work around this other than through copying them to a path where your portlet can reach them.

As a best practice, I'd advise to create a hook for modifications to Liferay and a separate portlet plugin with new (additional) portlets. Make the portlets self-contained. There are situations where it's good to combine hooks and portlets, but I like it best if modifications and additions are kept apart.

0

精彩评论

暂无评论...
验证码 换一张
取 消