Forums de discussion
PrimeFaces within a Liferay hook?
Richard Oliver Legendi, modifié il y a 11 années.
PrimeFaces within a Liferay hook?
Junior Member Publications: 35 Date d'inscription: 30/11/09 Publications récentes
I would like to include a PrimeFaces portlet for user administration (e.g., under the Miscalleneous list on the right).
It turned out that the issue is a bit tricky. First I had to create a hook and update the portal-ext.properties:
Then I had to create a simple JSP at a specific place (custom_jsps/html/portlet/users_admin/user/new_primefaces_portlet.jsp) with a simple content:
Where primefaces is the name of the portlet and primefaces-portlet is the name of the project (I'm working under the LiferayIDE). Note that the -/_ conversion in the name of the JSP, and elimination of the - characters previously are intended in the content, this is simply how Liferay works.
My problem is that when we are in a hook, the (otherwise working) PrimeFaces portlet becomes disfunctional. The reason is that neither the CSS nor the required JavaScript files are loaded.
As a test, I simply copied one of the theme.css files to primefaces-portlet/docroot/primefaces-aristo, and added the following line to liferay-portlet.xml:
This way my PrimeFaces portlet was rendered properly, but I don't like this solution since I have to copy & enumerate a dozens of files from the primefaces-jar file to the project by hand. Does anyone found a better solution/workaround for this issue?
Thank you guys in advance!
It turned out that the issue is a bit tricky. First I had to create a hook and update the portal-ext.properties:
users.form.update.miscellaneous=new-primefaces-portlet, ...
Then I had to create a simple JSP at a specific place (custom_jsps/html/portlet/users_admin/user/new_primefaces_portlet.jsp) with a simple content:
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<liferay-portlet:runtime portletName="primefaces_WAR_primefacesportlet" />
Where primefaces is the name of the portlet and primefaces-portlet is the name of the project (I'm working under the LiferayIDE). Note that the -/_ conversion in the name of the JSP, and elimination of the - characters previously are intended in the content, this is simply how Liferay works.
My problem is that when we are in a hook, the (otherwise working) PrimeFaces portlet becomes disfunctional. The reason is that neither the CSS nor the required JavaScript files are loaded.
As a test, I simply copied one of the theme.css files to primefaces-portlet/docroot/primefaces-aristo, and added the following line to liferay-portlet.xml:
<header-portlet-css>/primefaces-aristo/theme.css</header-portlet-css>
This way my PrimeFaces portlet was rendered properly, but I don't like this solution since I have to copy & enumerate a dozens of files from the primefaces-jar file to the project by hand. Does anyone found a better solution/workaround for this issue?
Thank you guys in advance!
Neil Griffin, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook?
Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Hi Richard,
I'm so glad you asked this question because there is a more straighforward way to do this with JSF portlets.
Specifically, I would recommend that you take a look at the icefaces3-users-portlet demo source. You won't find the source in the master branch at this time, but you will find it in the 3.1.x branch.
The icefaces3-users-portlet is simply a JSF portlet that is accessible from the Control Panel, rather than on a normal portal page. It's not accomplished with a hook, rather, it's done by specifying the following elements in the WEB-INF/liferay-portlet.xml descriptor:
Creating a PrimeFaces type of portlet should be pretty easy, if you use the icefaces3-users-portlet as an example.
Hope that helps,
Neil
I'm so glad you asked this question because there is a more straighforward way to do this with JSF portlets.
Specifically, I would recommend that you take a look at the icefaces3-users-portlet demo source. You won't find the source in the master branch at this time, but you will find it in the 3.1.x branch.
The icefaces3-users-portlet is simply a JSF portlet that is accessible from the Control Panel, rather than on a normal portal page. It's not accomplished with a hook, rather, it's done by specifying the following elements in the WEB-INF/liferay-portlet.xml descriptor:
<control-panel-entry-category>portal</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<instanceable>false</instanceable>
<ajaxable>false</ajaxable>
<add-default-resource>true</add-default-resource>
Creating a PrimeFaces type of portlet should be pretty easy, if you use the icefaces3-users-portlet as an example.
Hope that helps,
Neil
Richard Oliver Legendi, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook?
Junior Member Publications: 35 Date d'inscription: 30/11/09 Publications récentes
Wow, thanks Neil, you're my superhero! I'm not used to that kind of support and quick reply in the Liferay forums :-)
Let me check those resources tomorrow.
Let me check those resources tomorrow.
Neil Griffin, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook?
Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Thanks for the kind words Richard.
Looking forward to hearing out it works out for you.
Looking forward to hearing out it works out for you.
Richard Oliver Legendi, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook?
Junior Member Publications: 35 Date d'inscription: 30/11/09 Publications récentes
Hi Neil,
Unfortunately my issue is not with putting a JSF portlet on the Control Panel, rather than adding a new element to a portlet within the Control Panel (i.e., it must be done from a hook). Let's say I'd like to show a DataTable for instance at the users' profile for a new link uder the miscellaneous page (as written here).
Are you aware of such an example?
Unfortunately my issue is not with putting a JSF portlet on the Control Panel, rather than adding a new element to a portlet within the Control Panel (i.e., it must be done from a hook). Let's say I'd like to show a DataTable for instance at the users' profile for a new link uder the miscellaneous page (as written here).
Are you aware of such an example?
Neil Griffin, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook? (Réponse)
Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Hi Richard,
Since the out-of-the-box "Organizations and Users" control panel portlet is built with JSP technology, your usage of the <liferay-portlet:runtime /> JSP tag is very clever, and is to be commended.
I would recommend that you read the description from FACES-244 which should explain why your resources are not getting placed in the <head>...</head> section of the portal page when you use the <liferay-portlet:runtime /> JSP tag. According to the description, the resources are probably being rendered near the top of the portlet <div>
Your usage of header-portal-css inside of the WEB-INF/liferay-portlet.xml descriptor is a good choice. But rather than extract resources from the PrimeFaces JAR, you should probably look at the URLs that are rendered near the top of the portlet <div> and then put those inside of header-portal-css instead.
BTW, another approach that is *probably* equivalent would be to override the following JSP in your hook:
portal-web/docroot/html/portlet/users_admin/init-ext.jsp
And then inside the JSP, you could add the <liferay-util:html-top> tag in order to specify resources that are required by your PrimeFaces portlet.
But the header-portal-css approach you came up with is probably more elegant.
Best Regards,
Neil
Since the out-of-the-box "Organizations and Users" control panel portlet is built with JSP technology, your usage of the <liferay-portlet:runtime /> JSP tag is very clever, and is to be commended.
I would recommend that you read the description from FACES-244 which should explain why your resources are not getting placed in the <head>...</head> section of the portal page when you use the <liferay-portlet:runtime /> JSP tag. According to the description, the resources are probably being rendered near the top of the portlet <div>
Your usage of header-portal-css inside of the WEB-INF/liferay-portlet.xml descriptor is a good choice. But rather than extract resources from the PrimeFaces JAR, you should probably look at the URLs that are rendered near the top of the portlet <div> and then put those inside of header-portal-css instead.
BTW, another approach that is *probably* equivalent would be to override the following JSP in your hook:
portal-web/docroot/html/portlet/users_admin/init-ext.jsp
And then inside the JSP, you could add the <liferay-util:html-top> tag in order to specify resources that are required by your PrimeFaces portlet.
But the header-portal-css approach you came up with is probably more elegant.
Best Regards,
Neil
Richard Oliver Legendi, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook?
Junior Member Publications: 35 Date d'inscription: 30/11/09 Publications récentes
Hi Neil,
Thanks for the great ideas! Let me check that issue you mention (is it this issue in your ticketing system?) and play a bit with the approaches you suggested. I'll return to this topic with the results.
Thanks again for the hints!
Thanks for the great ideas! Let me check that issue you mention (is it this issue in your ticketing system?) and play a bit with the approaches you suggested. I'll return to this topic with the results.
Thanks again for the hints!
Neil Griffin, modifié il y a 11 années.
RE: PrimeFaces within a Liferay hook?
Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Yes that's the right issue. Looking forward to hearing more about your results.
Neil Griffin, modifié il y a 11 années.