Fórum

portlet embedding in template problem

thumbnail
omid ahmadi, modificado 10 Anos atrás.

portlet embedding in template problem

Junior Member Postagens: 37 Data de Entrada: 27/08/13 Postagens Recentes
hello all friends
im using liferay 6.1 CE (Liferay Portal Community Edition 6.1.1 CE GA2 (Paton / Build 6101 / July 31, 2012))

when i want to embed for example navigation portlet in template by this code :
$processor.processPortlet("71_INSTANCE_xyz1")
it show just the same code in page not any portlet!!!!!!!!

after search i understand that there is a bug in TemplateProcessor class in portal-impl/src/com/liferay/portlet/layoutconfiguration/util/velocity/TemplateProcessor.java file

TemplateProcessor.processPortlet() ignores supplied portletId

Can i solve this problem by hook or extension ???
if yes witch one ?????

any help please???

when embedding portlet in template i receive the following error in log

09:23:22,898 ERROR [http-bio-8080-exec-2][LiferayMethodExceptionEventHandler:33] java.lang.NullPointerException
java.lang.NullPointerException
at com.liferay.portal.model.PortletConstants.getRootPortletId(PortletConstants.java:85)
at com.liferay.portal.service.impl.PortletLocalServiceImpl.getPortletById(PortletLocalServiceImpl.java:403)
at sun.reflect.GeneratedMethodAccessor254.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
at $Proxy65.getPortletById(Unknown Source)
at com.liferay.portal.service.PortletLocalServiceUtil.getPortletById(PortletLocalServiceUtil.java:353)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:115)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:203)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:190)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:87)
at com.liferay.portlet.layoutconfiguration.util.velocity.TemplateProcessor.processPortlet(TemplateProcessor.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
at org.apache.velocity.Template.merge(Template.java:328)
at org.apache.velocity.Template.merge(Template.java:235)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:381)
at com.liferay.portal.velocity.VelocityEngineImpl.mergeTemplate(VelocityEngineImpl.java:264)
at com.liferay.portal.kernel.velocity.VelocityEngineUtil.mergeTemplate(VelocityEngineUtil.java:73)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.doProcessTemplate(RuntimePortletImpl.java:499)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.doDispatch(RuntimePortletImpl.java:394)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processTemplate(RuntimePortletImpl.java:228)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processTemplate(RuntimePortletImpl.java:216)
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:113)
at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(portlet_jsp.java:529)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) , ..........
.
.
.any help please???
thumbnail
meera prince, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
Hi

Please have a look into following blog

https://www.liferay.com/web/barrie.selack/blog/-/blogs/embedding-a-portlet-in-web-content

Regards,
Meera Prince
thumbnail
omid ahmadi, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Junior Member Postagens: 37 Data de Entrada: 27/08/13 Postagens Recentes
Hi
tanks a lot meera for your help

But this link is about embedding portlet in another portlet (web content display )
I need to embed portlet in page layout template

This is my scenario:
I have many page that is separated into several group according them layout template

All pages in same group have some portlet that is similar for all , thus i decided to embed them in template just one time instead of repeating same operation for many page several time

please any help about embedding portlet in page layout template????
thumbnail
meera prince, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
thumbnail
omid ahmadi, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Junior Member Postagens: 37 Data de Entrada: 27/08/13 Postagens Recentes
tanks Meera alot emoticon
your first link help me
that is exactly what im looking for about 5 hours and cant find!!!!!!

But one problem again?emoticon
i cant determine a fix location for portlet!!!!!
portlet is located out of page template in top of page
any help please????????
thumbnail
meera prince, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
Hi

You can fix in column of layout. may be you may miss to close the tags. check it all tags properly closed or not.



Regards,
Meera Prince
thumbnail
omid ahmadi, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Junior Member Postagens: 37 Data de Entrada: 27/08/13 Postagens Recentes
Hi meera
i cant set correct location in layout for embedded portlet
here is my tpl file code

<table border="1" style="width: 100%">
<tr height="50px">
<td width="25%"> </td>
<td width="50%"></td>
<td width="25%"></td>
</tr>

<tr height="100px">
<td></td>
<td></td>
<td></td>
</tr>

<tr height="150px">
<td style="border: 2px solid green" >
#set ($VOID = $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false"))

#set ($VOID = $velocityPortletPreferences.setValue("portletSetupShowBorders", "false"))
#set ($instanceId = '1a2b')
#set ($myPortletId = "56_INSTANCE_${instanceId}")
$taglibLiferay.runtime($myPortletId, '', $velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())
</td>
<td></td>
<td></td>
</tr>
</table>

and the result is attached

any help pleas?????
thumbnail
meera prince, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
Hi
I think your tpl code seems to not correct we should use some css clasess that given by liferay we cannot write the way you have written,


Example

<table class="portlet-layout">
<tr>
<td class="portlet-column portlet-column-only" id="column-1">
$processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")
</td>
</tr>
</table>

<table class="portlet-layout">
<tr>
<td class="aui-w50 portlet-column portlet-column-first" id="column-2">
$processor.processColumn("column-2", "portlet-column-content portlet-column-content-first")
</td>
<td class="aui-w50 portlet-column portlet-column-last" id="column-3">
$processor.processColumn("column-3", "portlet-column-content portlet-column-content-last")
</td>
</tr>
</table>

<table class="portlet-layout">
<tr>
<td class="portlet-column portlet-column-only" id="column-4">
$processor.processColumn("column-4", "portlet-column-content portlet-column-content-only")
</td>
</tr>
</table>

and we should use css classes like aui-w50,aui-w40, aui-w30 like that we need use like that

Please see some tpl files you can understand..

https://github.com/liferay/liferay-portal/tree/master/portal-web/docroot/layouttpl/custom


You can create layout using Liferay IDE its very easy.
thumbnail
omid ahmadi, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Junior Member Postagens: 37 Data de Entrada: 27/08/13 Postagens Recentes
Hi meera
I cant solve problem
I guess $taglibLiferay.runtime code just embed portlet in theme (out of template) not in template;

tanks anyway
thumbnail
omid ahmadi, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Junior Member Postagens: 37 Data de Entrada: 27/08/13 Postagens Recentes
hi all friends
i'm still trying to extend com.liferay.portlet.layoutconfiguration.util.velocity.TemplateProcessor class to override processPortlet method and correct its bug by ext plugin but dont know how to do this!!!!!!!
any help please????????
thumbnail
Mazhar Alam, modificado 10 Anos atrás.

RE: portlet embedding in template problem

Regular Member Postagens: 191 Data de Entrada: 25/11/11 Postagens Recentes
check this link