RE: JSP customization error when using 'OSGi fragment' approach

txapeldot ., modified 2 Years ago. Junior Member Posts: 91 Join Date: 1/15/15 Recent Posts

I'm attempting to customize the UI of the 'Documents & Media' Liferay portlet on an 'OSGi Fragment' approach, but a compilation error has arisen in one of the .jsp files I have to customize.

To tackle the intended task, I've created a Liferay Module Fragment project, and I've copied the original /document_library/view.jsp file from Liferay Portal source. This file contain an 'include' directive to include the file document_library/init.jsp. This file contains the following code:

<%
	...
	DLAdminDisplayContext dlAdminDisplayContext = dlAdminDisplayContextProvider.getDLAdminDisplayContext(request, response);
	DLAdminManagementToolbarDisplayContext dlAdminManagementToolbarDisplayContext = dlAdminDisplayContextProvider.getDLAdminManagementToolbarDisplayContext(request, response);
	...
%>

But this code displays the following error message:

dlAdminDisplayContextProvider cannot be resolved

which makes sense as the dlAdminDisplayContextProvider object is not declared in this file but within the file /init.jsp file, included by means of a 'include' directive:

<%
	...
	DLAdminDisplayContextProvider dlAdminDisplayContextProvider = dlWebComponentProvider.getDLAdminDisplayContextProvider();
	...
%>

 

My question is why this error message occurs if I'm using some .jsp files belonging to a functional Liferay portlet. Can anyone explain to me why the dlAdminDisplayContextProvider object is not accesible from the document_library/init.jsp file? Any clarification would really be appreciate.

Thanks in advance.

thumbnail
Russell Bohl, modified 2 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

You might need to exclude the internal packages (all those display context classes are internal) in your bnd file: It's mentioned in the article you linked, here

thumbnail
txapeldot ., modified 2 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

With JSP fragment bundles, they only have visibility on what you put in the fragment. Any errors, any unknown references, the IDE is going to report them all as errors.

It's up to you, the developer, to know that, for example, dlAdminDisplayContextProvider will be available when it is merged into the host bundle.