Foren

Plugins SDK can't use "liferay-util:include"

Da Re, geändert vor 14 Jahren.

Plugins SDK can't use "liferay-util:include"

New Member Beiträge: 3 Beitrittsdatum: 24.11.09 Neueste Beiträge
Plugins SDK can't use "liferay-util:include"

Don't believe me? Just try it. Use the SDK to create a JSP Portlet. Create another file called "test.jsp" in the same directory/folder as the view.jsp. Put some random text in the test.jsp file, and try to use the "liferay-util:include" tag to display the contents of test.jsp in the view.jsp.

Good luck.

hint: the problem is that "liferay-util:include" can't accomodate portlet paths that are outside the root context.
thumbnail
Jonas Yuan, geändert vor 14 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Make sure that you have included following in JSP

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>

<portlet:defineobjects />

<liferay-theme:defineobjects />




Thanks

Jonas Yuan
-----------------
The Author of Liferay Books:
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
thumbnail
Amos Fong, geändert vor 14 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
Yea it looks like it is only in the liferay context not your plugin (which can be very useful since these jsps aren't accessible otherwise.) Maybe use <%@ include file="/test.jsp" %> instead?
Da Re, geändert vor 14 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

New Member Beiträge: 3 Beitrittsdatum: 24.11.09 Neueste Beiträge
Amos,

Thanks for your response.

That's exactly what I had to do.

Where this complicates things is when you include several separate JSPs (as with using the "liferay-ui:tabs"): Because these are "pre-compile" includes, I can't use the same variable names for the local variables used within the individual JSPs. It's not a big issue, but it does make re-using code snippets a bit more difficult.

Again, thanks for your feedback.

--
Ren
Amos Fong:
Yea it looks like it is only in the liferay context not your plugin (which can be very useful since these jsps aren't accessible otherwise.) Maybe use <%@ include file="/test.jsp" %> instead?
thumbnail
Jonas Yuan, geändert vor 14 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Amos,

I believe that we could use correct tag format like

<liferay-util:include page="/html/portlet/bookmarks/folder_action.jsp" />


Thanks

Jonas Yuan
-----------------
The Author of Liferay Books:
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
thumbnail
Jakub Liska, geändert vor 13 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Regular Member Beiträge: 187 Beitrittsdatum: 25.03.10 Neueste Beiträge
Hi,

I suppose I duplicated this one here emoticon

I though it was a Spring context issue, but obviously this tag is really to be used only in ROOT portal context ? Please talk to me guys... Da Re is right

Where this complicates things is when you include several separate JSPs (as with using the "liferay-ui:tabs"): Because these are "pre-compile" includes, I can't use the same variable names for the local variables used within the individual JSPs. It's not a big issue, but it does make re-using code snippets a bit more difficult.


Is there anything new about this tag ? Considering the fact that ext will be eventually "deprecated"
thumbnail
Jakub Liska, geändert vor 13 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Regular Member Beiträge: 187 Beitrittsdatum: 25.03.10 Neueste Beiträge
Got it

<liferay-util:include page="/WEB-INF/jsp/customers/invoicesView.jspf" servletcontext="<%=this.getServletContext() %>"></liferay-util:include>


I think I asked the question right before I noticed the servletContext attribute...
thumbnail
delang j, geändert vor 10 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Expert Beiträge: 252 Beitrittsdatum: 14.07.08 Neueste Beiträge
hi guys,

still not working on 6.2. emoticon

<liferay-util:include page="/html/helpdesk/application_acc_req.jsp" servletContext="<%= this.getServletContext() %>" />
thumbnail
meera prince, geändert vor 10 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Liferay Legend Beiträge: 1111 Beitrittsdatum: 08.02.11 Neueste Beiträge
Hi
pass application object as servletContext and this case when we work with plugin portlets.
Use as follows
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<liferay-util:include page="/html/albums/toolbar.jsp" servletContext="<%= application %>" />

Regards,
meera prince
thumbnail
delang j, geändert vor 10 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Expert Beiträge: 252 Beitrittsdatum: 14.07.08 Neueste Beiträge
meera prince:
Hi
pass application object as servletContext and this case when we work with plugin portlets.
Use as follows
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<liferay-util:include page="/html/albums/toolbar.jsp" servletContext="<%= application %>" />

Regards,
meera prince

i couldn't get it. could you post some example.

thanks
thumbnail
meera prince, geändert vor 10 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Liferay Legend Beiträge: 1111 Beitrittsdatum: 08.02.11 Neueste Beiträge
Hi
Simple take the above post code and place in you JSP page it should work.
<liferay-util:include page="/html/albums/toolbar.jsp" servletContext="<%= application %>" />

for page attribute you just pass jsp path and service context use application object siple it should work
if you want some example get the portlet from following location

https://github.com/liferay-labs/jukebox-portlet
thumbnail
Abdollah Esmaeilpour, geändert vor 9 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Junior Member Beiträge: 60 Beitrittsdatum: 22.08.09 Neueste Beiträge
Meera Prince:
Hi
pass application object as servletContext and this case when we work with plugin portlets.
Use as follows
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<liferay-util:include page="/html/albums/toolbar.jsp" servletContext="<%= application %>" />

Regards,
meera prince


So many thanks.
It worked for me in 6.2.
Da Re, geändert vor 14 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

New Member Beiträge: 3 Beitrittsdatum: 24.11.09 Neueste Beiträge
Jonas,

I did exactly that. The trouble with the "liferay-util:include" is that it REQUIRES a forward-slash ("/") as the first character. This is what makes the "liferay-util:include" useless for those of us who are using the Plugins SDK, because the portlets created with the SDK are deployed OUTSIDE the root context. Ergo, that small "feature" (dare I say "design flaw") makes it impossible to reference any files packaged with the WAR file.

I heard a rumor that the latest versions of Liferay are encouraging the use of the SDK over the Extension Environment (a very good idea in my NSHMO). If true, then it would behoove the developers of liferay-util to change the include so that it allows for relative pathing.

Thanks for your feedback - I hope I've clarified my situation.

In my reply below, I explain why being forced to use
&lt;%@ include file="./test.jsp" %&gt;
has its own disadvantage.

--
Ren

Jonas Yuan:
Make sure that you have included following in JSP

&lt;%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %&gt;

<portlet:defineobjects />

<liferay-theme:defineobjects />




Thanks

Jonas Yuan
-----------------
The Author of Liferay Books:
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
thumbnail
Jonas Yuan, geändert vor 14 Jahren.

RE: Plugins SDK can't use "liferay-util:include"

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Da Re,

You may refer to this

<liferay-util:include page="/html/portlet/bookmarks/top_links.jsp" />


Above code is workable in 5.3.

Thanks

Jonas Yuan
-----------------
The Author of Liferay Books:
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets