掲示板

Blogs portlet source code

thumbnail
9年前 に Raghunadh Parlapalli によって更新されました。

Blogs portlet source code

New Member 投稿: 15 参加年月日: 12/06/28 最新の投稿
Hi,

I have a scenario where i want to use Liferay OOTB blogs portlet as is, and also i want to have another blog portlet (let's say in the same page) with some changes like (opening new blog entry page in maximized mode (chagge required in source), pass one additional parameter to backend, changing date display format).

If i make changes in blogs portlet jsps or i go for hook or Ext options then the changes will be applicable to all the blogs portlet wherever i use on the portal. But, I don't want that to happen. Bot portlets should run independently and the custom portlet changes should not effect OOTB blog portlet.

So i am thinking that i will create a new portlet and utilize the blogs portlet pages & source code. Is that correct approach? Should i need to download the blogs portlet source from liferay SVN or is that enough if i use the JSP and srvice classes comes with liferay source code.zip.

Can anyone suggests the bestway yo do this and also it will be helpful if you can share the i implementation steps.
thumbnail
9年前 に Olaf Kock によって更新されました。

RE: Blogs portlet source code

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
If your custom changes should not affect the OOTB portlet, yes, you're best of creating a totally custom blog portlet.
If you should use Liferay's source code for this? It depends!

What does it depend on?
When you copy the BlogsPortlet code to your own project, you'll be able to identify how much of the core Liferay infrastructure is being used in there - it might be easy, or it might be hard, I don't know, I didn't look at it. However, depending on your requirements you might get along with a less configurable custom Blogs Portlet - thus you can work with a lot less code than Liferay. If you never want to configure certain aspects in your custom portlet (because your requirements already specify what you need), there's no need to copy over (and implement) all of the portlet preferences stuff and the configuration UI - just leave it out. Liferay needs to be generic, as there are so many different users. You might get along with a very straightforward, hardcoded solution that's small and easy to maintain.

Note, you'll find Liferay's source code either on github or (for CE) on sourceforge or (for EE) on the customer portal. I'm not sure if the SVN server is still maintained.
thumbnail
9年前 に Raghunadh Parlapalli によって更新されました。

RE: Blogs portlet source code

New Member 投稿: 15 参加年月日: 12/06/28 最新の投稿
thanks for your quick suggestions. Like you said my requirement is not possible to do with Hook, because as per my understanding if go with hook, changes applies commonly for all blog portlets added on my portal. So i think custom portlet fits in to situation.

So i started with custom portlet creation and followed the below steps:
- downloaded the blogs portlet source code from liferay portal source github and copied to my custom blog portlet src/ package
- copied the blogs portlet jsp pages from tomcat bundle /html/portlet/blogs/ to my custom portlet /html/portlet/blogs folder
- copied the other depency jsp pages from portal-web to /html/portlet folder
- added the below jar files to lib folder following the errors found in the console
displaytag-1.2.jar
javassist.jar
jericho-html-3.1.jar
jstl-1.2.jar
portal-service.jar
portlet.jar
struts-1.2.9.jar
struts-el-1.3.10.jar

Now, When i deploy the portlet it says that

4 10:09:20 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/mycustomblogs-portlet
Jun 30, 2014 10:25:31 AM org.apache.catalina.startup.HostConfig checkResources
INFO: Reloading context [/mycustomblogs-portlet]
Jun 30, 2014 10:25:31 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/mycustomblogs-portlet] has started
Jun 30, 2014 10:25:31 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/mycustomblogs-portlet] created a ThreadLocal with key of type [com.liferay.portal.kernel.util.CentralizedThreadLocal.ThreadLocalMapThreadLocal] (value [com.liferay.portal.kernel.util.CentralizedThreadLocal$ThreadLocalMapThreadLocal@106ce4]) and a value of type [com.liferay.portal.kernel.util.CentralizedThreadLocal.ThreadLocalMap] (value [com.liferay.portal.kernel.util.CentralizedThreadLocal$ThreadLocalMap@5d2322]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jun 30, 2014 10:25:31 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/mycustomblogs-portlet] created a ThreadLocal with key of type [com.liferay.portal.kernel.util.CentralizedThreadLocal.ThreadLocalMapThreadLocal] (value [com.liferay.portal.kernel.util.CentralizedThreadLocal$ThreadLocalMapThreadLocal@adbc8d]) and a value of type [com.liferay.portal.kernel.util.CentralizedThreadLocal.ThreadLocalMap] (value [com.liferay.portal.kernel.util.CentralizedThreadLocal$ThreadLocalMap@3601a5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.


can you help me to fix this problem ??? and also tell me if there are any mistakes in my approach in creating the custom blog portlet.
thumbnail
9年前 に Olaf Kock によって更新されました。

RE: Blogs portlet source code

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
There's probably more required: You'll need some declarations in web.xml for the taglibraries, also, as the blog portlet is a struts portlet, you'll need the relevant sections from struts-config.xml and tiles-defs.xml.

Very important: You must not copy portal-service.jar into your webapplication. This library comes from the appserver's global classpath.

Also: Do you only want to get rid of these log entries or are there any real failures involved that might have more error messages somewhere?
thumbnail
9年前 に Raghunadh Parlapalli によって更新されました。

RE: Blogs portlet source code

New Member 投稿: 15 参加年月日: 12/06/28 最新の投稿
I have removed the portal-service.jar.

Now i am getting so many error messgaes.

An error occurred at line: [131] in the generated java file: [/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/work/Catalina/localhost/mycustomeblog-portlet-6.2.0.1/org/apache/jsp/html/portlet/blogs/view_jsp.java]
Only a type can be imported. com.liferay.portal.plugin.PluginUtil resolves to a package

it looks like portal-service.jar/portal-impl.jar (from SDK) are not getting reference properly or is it because of any other problem?
thumbnail
9年前 に Olaf Kock によって更新されました。

RE: Blogs portlet source code

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
portal-service.jar comes from the global classpath, so it should be there.

portal-impl.jar is not available to plugins, you'll need to change the JSPs and replace any references to classes in portal-impl.jar to different implementations. Do not include portal-impl.jar in your project - this won't work and it's not even worth trying.

Your whole approach won't be easy, thus my former suggestion to simplify the code that you've copied: You probably don't need it as configurable as Liferay delivers it out of the box - just get rid of the generic functionality in the blogs portlet or rewrite a simple portlet that doesn't do much more than displaying the article. As the blogs portlet is part of Liferay's core, it probably references quite a few implementation classes that you don't have available in your own plugin.
thumbnail
9年前 に Raghunadh Parlapalli によって更新されました。

RE: Blogs portlet source code

New Member 投稿: 15 参加年月日: 12/06/28 最新の投稿
thanks Olaf. Actually i got confused with the JAR structure from 5.2 to 6.2 before.

But yes, Now i understood we no need to include the portal JAR to individudal portlets, instead they have the portal JARs in server classpath.