Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
primefaces treeTable not work in liferay portlet
Hi Liferay-Developer !
I developed a Primeface-treeTable based on the Primeface example. This treeTable works in a normal Web-Application outside a portlet. I deployed this WebApplication (no portlet) on the liferay tomcat. It works fine. If I klick in a row, the sub rows will be shown.
I copy the same classes, jsf-views, css-Files, and js-files into a Liferay portlet and start the portlet. The treeTable will be shown and no errors are printed in the log files. If I click in a row (small triangle) the subrows will not shown. Where is the problem?
I see in the firefox console log, that a http request was send to the server.
The Request:
_EmailClient_WAR_emailcli...
_EmailClient_WAR_emailclientjsfportlet_:form
_EmailClient_WAR_emailcli...
_EmailClient_WAR_emailclientjsfportlet_:form:j_idt9
_EmailClient_WAR_emailcli...
2
javax.faces.ViewState
-7278044843963633805:-504317009044774931
javax.faces.encodedURL
http://localhost:10080/web/...
javax.faces.partial.ajax
true
...
The Respone:
<partial-response id="_EmailClient_WAR_emailclientjsfportlet_"><changes><update id="_EmailClient_WAR_emailclientjsfportlet_
:javax.faces.ViewState:0"><![CDATA[3113752891300741342:-2864814770497568017]]></update></changes></partial-response
>
The XHTML:
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition
template="/META-INF/templates/emailClientTemplateInPortlet.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:mg="http://at.irian/mygourmet" xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:param name="title" value="#{msgs.mytitle}" />
<ui:define name="mycontent">
<h:form id="form" enctype="multipart/form-data">
<p:treeTable value="#{basicView.root}" var="doc">
<p:column headerText="Name">
<h:outputText value="#{doc.name}" />
</p:column>
<p:column headerText="Size">
<h:outputText value="#{doc.size}" />
</p:column>
<p:column headerText="Type">
<h:outputText value="#{doc.type}" />
</p:column>
</p:treeTable>
</h:form>
</ui:define>
</ui:composition>
The Template:
...
<h:body>
<h:outputScript library="scripts" name="primeFacesLoc.js" target="head" />
<h:outputStylesheet name="styles/my.css" />
<div id="mycontainerid">
<div id="mycontentid">
<ui:insert name="mycontent">Default content</ui:insert>
</div>
</div>
</h:body>
</html>
I developed a Primeface-treeTable based on the Primeface example. This treeTable works in a normal Web-Application outside a portlet. I deployed this WebApplication (no portlet) on the liferay tomcat. It works fine. If I klick in a row, the sub rows will be shown.
I copy the same classes, jsf-views, css-Files, and js-files into a Liferay portlet and start the portlet. The treeTable will be shown and no errors are printed in the log files. If I click in a row (small triangle) the subrows will not shown. Where is the problem?
I see in the firefox console log, that a http request was send to the server.
The Request:
_EmailClient_WAR_emailcli...
_EmailClient_WAR_emailclientjsfportlet_:form
_EmailClient_WAR_emailcli...
_EmailClient_WAR_emailclientjsfportlet_:form:j_idt9
_EmailClient_WAR_emailcli...
2
javax.faces.ViewState
-7278044843963633805:-504317009044774931
javax.faces.encodedURL
http://localhost:10080/web/...
javax.faces.partial.ajax
true
...
The Respone:
<partial-response id="_EmailClient_WAR_emailclientjsfportlet_"><changes><update id="_EmailClient_WAR_emailclientjsfportlet_
:javax.faces.ViewState:0"><![CDATA[3113752891300741342:-2864814770497568017]]></update></changes></partial-response
>
The XHTML:
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition
template="/META-INF/templates/emailClientTemplateInPortlet.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:mg="http://at.irian/mygourmet" xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:param name="title" value="#{msgs.mytitle}" />
<ui:define name="mycontent">
<h:form id="form" enctype="multipart/form-data">
<p:treeTable value="#{basicView.root}" var="doc">
<p:column headerText="Name">
<h:outputText value="#{doc.name}" />
</p:column>
<p:column headerText="Size">
<h:outputText value="#{doc.size}" />
</p:column>
<p:column headerText="Type">
<h:outputText value="#{doc.type}" />
</p:column>
</p:treeTable>
</h:form>
</ui:define>
</ui:composition>
The Template:
...
<h:body>
<h:outputScript library="scripts" name="primeFacesLoc.js" target="head" />
<h:outputStylesheet name="styles/my.css" />
<div id="mycontainerid">
<div id="mycontentid">
<ui:insert name="mycontent">Default content</ui:insert>
</div>
</div>
</h:body>
</html>
Moved to Liferay Faces category
Hi Mallex,
although Liferay Faces portlet bridge makes your JSF portlets working without knowing any portlet internals, they doesn't have to work without changing anything if coming from a non portlet environment.
Please take a look on the demo portlets to see what are the needed changes for web.xml, and liferay-portlet.xml.
Additionally, be careful about which Liferay Faces are you using. Read this Liferay Faces version scheme so you can ensure your portlet will work as it should on your Liferay environment.
To say an example about one of the changes you have to do, in portlet environments you have to use <f:view> instead of <html>, due to the portlet environment own characteristics.
although Liferay Faces portlet bridge makes your JSF portlets working without knowing any portlet internals, they doesn't have to work without changing anything if coming from a non portlet environment.
Please take a look on the demo portlets to see what are the needed changes for web.xml, and liferay-portlet.xml.
Additionally, be careful about which Liferay Faces are you using. Read this Liferay Faces version scheme so you can ensure your portlet will work as it should on your Liferay environment.
To say an example about one of the changes you have to do, in portlet environments you have to use <f:view> instead of <html>, due to the portlet environment own characteristics.