掲示板

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

14年前 に Da Re によって更新されました。

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

New Member 投稿: 3 参加年月日: 09/11/24 最新の投稿
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
14年前 に Jonas Yuan によって更新されました。

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

Liferay Master 投稿: 993 参加年月日: 07/04/27 最新の投稿
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
14年前 に Amos Fong によって更新されました。

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

Liferay Legend 投稿: 2047 参加年月日: 08/10/07 最新の投稿
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?
14年前 に Da Re によって更新されました。

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

New Member 投稿: 3 参加年月日: 09/11/24 最新の投稿
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
14年前 に Jonas Yuan によって更新されました。

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

Liferay Master 投稿: 993 参加年月日: 07/04/27 最新の投稿
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
13年前 に Jakub Liska によって更新されました。

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

Regular Member 投稿: 187 参加年月日: 10/03/25 最新の投稿
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
13年前 に Jakub Liska によって更新されました。

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

Regular Member 投稿: 187 参加年月日: 10/03/25 最新の投稿
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
10年前 に delang j によって更新されました。

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

Expert 投稿: 252 参加年月日: 08/07/14 最新の投稿
hi guys,

still not working on 6.2. emoticon

<liferay-util:include page="/html/helpdesk/application_acc_req.jsp" servletContext="<%= this.getServletContext() %>" />
thumbnail
10年前 に meera prince によって更新されました。

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

Liferay Legend 投稿: 1111 参加年月日: 11/02/08 最新の投稿
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
10年前 に delang j によって更新されました。

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

Expert 投稿: 252 参加年月日: 08/07/14 最新の投稿
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
10年前 に meera prince によって更新されました。

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

Liferay Legend 投稿: 1111 参加年月日: 11/02/08 最新の投稿
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
9年前 に Abdollah Esmaeilpour によって更新されました。

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

Junior Member 投稿: 60 参加年月日: 09/08/22 最新の投稿
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.
14年前 に Da Re によって更新されました。

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

New Member 投稿: 3 参加年月日: 09/11/24 最新の投稿
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
14年前 に Jonas Yuan によって更新されました。

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

Liferay Master 投稿: 993 参加年月日: 07/04/27 最新の投稿
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