Fórum
Including jsp fragment into jsp page Liferay 7
Csaba Meszaros, modificado 7 Anos atrás.
Including jsp fragment into jsp page Liferay 7
Junior Member Postagens: 42 Data de Entrada: 10/10/13 Postagens Recentes
I've tried two different approaches:
1.
2.
The view.jsp and priceOffer.jsp both reside in /resources.
But none of them gave me the expected result.
For 1. didn't get any errors, nor anything at all,
For 2. it gave me FileNotFound exception, and pointed to a non-existent place.
I need a short, working snippet. Thank you!
1.
<liferay-util:include page="priceOffer.jsp" servletContext="<%=this.getServletContext() %>">
<liferay-util:param name="name" value="${pricy.userName }" />
<liferay-util:param name="price" value="${pricy.price }" />
<liferay-util:param name="currency" value="USD" />
</liferay-util:include>
2.
<jsp:include page="priceOffer.jsp">
<jsp:param name="name" value="${pricy.userName }" />
<jsp:param name="price" value="${pricy.price }" />
<jsp:param name="currency" value="USD" />
</jsp:include>
The view.jsp and priceOffer.jsp both reside in /resources.
But none of them gave me the expected result.
For 1. didn't get any errors, nor anything at all,
For 2. it gave me FileNotFound exception, and pointed to a non-existent place.
I need a short, working snippet. Thank you!
Enrique Valdes Lacasa, modificado 4 Anos atrás.
RE: Including jsp fragment into jsp page Liferay 7
Junior Member Postagens: 92 Data de Entrada: 29/07/14 Postagens Recentes
I use this and it works on Liferay 7.2.
In your init.jsp add:
And after that just use:
Then, in the included JSP, to get the parameter:
It won't work without specifying the serviceContext with the application object.
According to : https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/using-liferay-util-include:
The servletContext refers to the request context that the included JSP should use. Passing <%= application %> to this attribute lets the included JSP use the same request object as other objects that might be set in the prior JSP.
Kind regards.
In your init.jsp add:
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
And after that just use:
<liferay-util:include page="/jsp/fragment2include.jsp" servletcontext="<%= application %>">
<liferay-util:param name="someParam" value="<%= someParam %>" />
</liferay-util:include>
Then, in the included JSP, to get the parameter:
<%
String someParam = ParamUtil.getString(request, "someParam ");
%>
It won't work without specifying the serviceContext with the application object.
According to : https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/using-liferay-util-include:
The servletContext refers to the request context that the included JSP should use. Passing <%= application %> to this attribute lets the included JSP use the same request object as other objects that might be set in the prior JSP.
Kind regards.