Recent Bloggers

Olaf Kock

Staff
90 Mensagens
18 de Dezembro de 2014

David Kubitza

2 Mensagens
14 de Dezembro de 2014

Meera Prince

19 Mensagens
4 de Dezembro de 2014

James Falkner

Staff
100 Mensagens
2 de Dezembro de 2014

Juan Fernández

Staff
17 Mensagens
28 de Novembro de 2014

Andrea Di Giorgi

2 Mensagens
26 de Novembro de 2014

Gregory Amerson

Staff
26 Mensagens
25 de Novembro de 2014

Cody Hoag

Staff
6 Mensagens
25 de Novembro de 2014

Duke H

Staff
2 Mensagens
24 de Novembro de 2014

Nicholas Gaskill

Staff
1 Mensagens
21 de Novembro de 2014
« Voltar

Liferay Hook Plugin Support | Netbeans Portal Pack 3.0.2

General Blogs 22 de Março de 2009 Por Santh Chetan Chadalavada

 

Portal Pack makes life easier yet again !!. This time with the NetBeans Hook Plugin for Liferay.

Available @ Netbeans PortalPack 3.0.2


Introduction: This plugin has been developed to provide hook tooling support through Netbeans Portal Pack. For more information

on Liferay Hook checkout the Portal Hook Plugins Wiki

This new feature will help creating different kinds of hooks supported by Liferay Portal. Lets look each type of hook and how we can create them using Netbeans Portal Pack plugin.

  • Event Type Hook :  Liferay provides different kind of event type hooks and Portal Pack now supports all the different kinds of event hooks. For example, add a post login hook to do your custom stuff after each user login.
  1. Create a web project:
  2. In Server and Settings choose Liferay Portal Server 5.2.2 and click on Finish the create the project.
  3. Right click on the project. In Categories Select WebSpace/Liferay Plugins -> Hook Plugin. 
  4. Click On Next. From the Hooks Wizard top dropdown choose Event Handler Hook.
  5. Provide ClassName and Package. Choose the Event Type from the bottom drop down and click Finish. 
  6. liferay-hook.xml, portal.properties, Event class files will be generated with the provided information.You can edit the java file put some code and save.
  7. Right click on the project and select Deploy.
  • Model Listener Hook : Using this hooks, you can do specific tasks whenever there is any CRUD operation in a specific model.
  1. Right click on the project-> Select Hook Plugin -> Choose Model Listeners Hook. 
  2. Choose the model by Clicking on Search. 
  3. Click Finish. Modify the code generated by Portal Pack Plugin, save it, Right click on the project and deploy. 
  • Jsp Hook : Using this hook, user can customize the core portal jsps/portlet in a decoupled manner without touching the core. For example, you can change the look and feel of the blog portlet in your hook application. And once you undeploy the hook application, the customization will go away. The Portal Pack provides wizard to create jsp hooks where user can select the core portal components which he/she wants to customize and the required files will be automatically imported to the hooks application. This feature can be used by SI for the portal customization.
  1. From the Hook Plugin Wizard choose the Jsp Hook from the drop down. Liferay Core jsp root folder(html) will be populated in the left pane. 
  2.  
  3. Once clicked on Finish, folder structure will be created under the default custom jsp directory "/WEB-INF/jsp".
  • Portal.properties Hook : You can override certain portal.properties through your hooks application.
  1. Select the Properties Hook from the drop down on a Clean Web Project(Which does not have a hook created to it).
  2. portal.properties will be create with commented pre entires supported to be overriden.

 

Undeploying Hooks:

All the deployed hook plugins can be undeployed from Netbeans -> Services -> Liferay Server -> Global -> Hooks.

Right Click on the Hook Plugin and selecting Undeploy will undeploy it from the Portal Server. 

 

Respostas do tópico Autor Data
Very nice Santh, Keep up the good work! Jorge Ferrer 23 de Março de 2009 11:56
This is very good stuff Chetan! Manish Dixit 25 de Março de 2009 17:02
I have just tried to use the JSP hook facility,... Peter B West 13 de Abril de 2009 18:23
Peter, I guess you are using "Directory... Santh Chetan Chadalavada 13 de Abril de 2009 23:07
Chetan, That worked like a charm. Many thanks.... Peter B West 14 de Abril de 2009 06:16
Chetan, I now have a related problem, based on... Peter B West 15 de Abril de 2009 19:45
It seems to work if I simply explode the... Peter B West 15 de Abril de 2009 21:02
Curiously, this seems to work on mu local... Peter B West 15 de Abril de 2009 21:23
Peter, if I understand correctly ur query, you... Santh Chetan Chadalavada 15 de Abril de 2009 22:24
Thanks Chetan. That works, and I see in the... Peter B West 15 de Abril de 2009 22:53
>>However, the jsp is not being activated. It... satya ranjan 15 de Abril de 2009 23:25
Hmm. It's not there. On my local system, I do... Peter B West 15 de Abril de 2009 23:41
Peter, you said you exploded the war previously... Santh Chetan Chadalavada 16 de Abril de 2009 00:43
I'll see if I can get the server restarted... Peter B West 16 de Abril de 2009 01:31
I removed JSP-hook from webapps, restarted the... Peter B West 16 de Abril de 2009 04:35
Whats the server version(OS + liferay version)?... Santh Chetan Chadalavada 16 de Abril de 2009 05:07
I created a new hook application and tested it... Peter B West 17 de Abril de 2009 01:33
I'm running 5.2.2 on OpenSuSE locally. The... Peter B West 17 de Abril de 2009 02:11
I want to create a auto-login hook. Is that... Tony Lim 18 de Abril de 2009 10:39
It is very much possible. Portal Pack provides... Santh Chetan Chadalavada 21 de Abril de 2009 06:56
Will the portal pack be updated to work with... Marcelo Ruiz Camauër 3 de Agosto de 2010 14:57
Hi Marcelo, You should probably ask Oracle... Jorge Ferrer 4 de Agosto de 2010 01:17
I cannot create a Jsp Hook with the 3.0.2... Thomas Kellerer 14 de Julho de 2009 03:08
Hi Thomas, Hooks works fine with the 3.0.2... Santh Chetan Chadalavada 14 de Julho de 2009 11:16
Hi, I wanted to create a ModelListener, that... Dennis Nes 30 de Setembro de 2009 05:52
Hi Dennis, which version of liferay and... Santh Chetan Chadalavada 30 de Setembro de 2009 07:18
Anyone here who can send me the Plugins please... Darko Joseph Hojnik 4 de Novembro de 2009 20:04
^^ ups webmaster {a} virtualizing.org ;) Darko Joseph Hojnik 4 de Novembro de 2009 20:04
http://blogs.sun.com/lukas/entry/page_not_found... Santh Chetan Chadalavada 4 de Novembro de 2009 21:41
hi Chetan let me thanks for ur good work now... vishal jha 8 de Junho de 2010 05:03
Hello, thank you for the post. Just came across... Mario Rosemario 22 de Dezembro de 2010 05:19
[...] Liferay Hook Plugin Support , Netbeans... Anônimo 4 de Setembro de 2014 01:33

Very nice Santh,

Keep up the good work!
Postado em 23/03/09 11:56.
This is very good stuff Chetan!
Postado em 25/03/09 17:02.
I have just tried to use the JSP hook facility, and nothing much happened. Has anyone else tried this?

My instance is 5.2.2 in Tomcat 5.5. I created web projects using both the default JEE5 and JEE4, although I didn't change the source level from 1.6.

I created a JSP for portal/login, modified the open_id.jsp to include a legend in the fieldset, and deployed. The following output was in NB

23:35:32,052 INFO [AutoDeployDir:183] Processing LifeRayTest-hook.xml
23:35:32,053 INFO [PortletAutoDeployListener:67] Deploying package as a web application
23:35:32,053 INFO [PortletAutoDeployListener:77] Copying portlets for /opt/nb/liferay/liferay-portal-tomcat-5.5-5.2.2/deploy/LifeRayTest-hook.xml
23:35­:32,054 INFO [PortletAutoDeployListener:87] Portlets for /opt/nb/liferay/liferay-portal-tomcat-5.5-5.2.2/deploy/LifeRayTest-hook.xml copied successfully. Deployment will start in a few seconds.
/home/pbw/NetBeansProjects/LifeRayTest-hook/build/web updated successfully.
Time taken for massaging : 22sec.
PortalPack Message : Deployed Successfully.

When I try to access the JSP (by attempting to login with OpenID) my changes are not visible. Searching the tomcat tree for files named open_id.* yields two versions, including the original of the one I modified.

The file that gets deployed is LifeRayTest-hook.xml (my project name is LifeRayTest-hook). It's contents are:
<Context docBase="/home/pbw/NetBeansProjects/LifeRayTest-hook/build/web">
</Context>

What am I doing wrong?
Postado em 13/04/09 18:23.
Peter,

I guess you are using "Directory Deployment Enabled" on the server properties. Hooks type application does not work with Directory Deployment as it has to go through proper war deployment. So workaround is to

1. Goto Server config panel.
2. Uncheck and disable "Directory Deployment Enabled" and click on Apply.
3. Undeploy the application and then redeploy again.

This case was taken care in Glassfish bundle where it does regular deployment for hook application even if Directory Deployment is selected. So we have to handle the same case for tomcat too.

Thanks for bringing this up. Please let us know if you are still facing the issue.

Chetan
Postado em 13/04/09 23:07 em resposta a Peter B West.
Chetan,

That worked like a charm. Many thanks. I'll let you know if anything else crops up.

Peter
Postado em 14/04/09 06:16 em resposta a Santh Chetan Chadalavada.
Chetan,

I now have a related problem, based on my ignorance of Tomcat. I have been deploying my JSP hook from NetbBeans - it's as simple as making sure mysql and the liferay server are running, then invoking Deploy on the menu of the project I have created.

Now I need to deploy on a remote server. I construct the .war file, but what do I have to do to get it recognised and acted upon?

The deployment from my NetBeans project seem to invoke a NetBeans internally defined target called nbjpdaappreloaded.


Peter
Postado em 15/04/09 19:45 em resposta a Santh Chetan Chadalavada.
It seems to work if I simply explode the JSP-hook.war into tomcat.../webapps/JSP-hook.

Is this all I need to do?

Peter
Postado em 15/04/09 21:02 em resposta a Peter B West.
Curiously, this seems to work on mu local system, but no on the server. Are there properties which must be set to enable hooks?

Peter
Postado em 15/04/09 21:23 em resposta a Peter B West.
Peter, if I understand correctly ur query, you want to deploy the JSP-hook.war in a remote server rt?

You can just upload the war file to your server's autodeploy location. for ex: liferay-portal-5.2.2\deploy. You don't need to explicitly explode it into webapps dir.

I don't think you need to make any changes to war unless the portal versions are way too different AFAIK.
Postado em 15/04/09 22:24 em resposta a Peter B West.
Thanks Chetan. That works, and I see in the log that the:

Hook for JSP-hook is available for use

However, the jsp is not being activated. It is possible that the login.jsp has been overridden be something else on the server. I don't know how to check this readily.

One other interesting point: I cannot see the hook in the Control Panel Plugins Installation page, either on my local system, where it works, or on the server, where it does not.

Peter
Postado em 15/04/09 22:53 em resposta a Santh Chetan Chadalavada.
>>However, the jsp is not being activated. It is possible that the login.jsp has been overridden be something else on the server. I don't know how to check this readily.

You can go to the following location and check the content of login.jsp to see your hook login.jsp content are there or not.

$liferay-portal-5.2.2\tomcat-5.5.27\webapps\ROOT\html\portlet\login

During jsp hook deployment, the liferay server basically copies the jsps in your hook application to the core portal deployed location and takes backup of orignal jsps. So whenever you undeploy your hook application, the original jsps get back to their original location.
Postado em 15/04/09 23:25 em resposta a Peter B West.
Hmm. It's not there. On my local system, I do have login.jsp and login.portal.jsp. etc.

Peter
Postado em 15/04/09 23:41 em resposta a satya ranjan.
Peter, you said you exploded the war previously in the webapps dir. That could have messed up something, not sure.
Try undeploying/remove the jsp-hook folder the webapp, restart the server and redeploy again by copying the hook war in deploy location and see if it comes up.

Chetan
Postado em 16/04/09 00:43 em resposta a Peter B West.
I'll see if I can get the server restarted later this evening.

Peter
Postado em 16/04/09 01:31 em resposta a Santh Chetan Chadalavada.
I removed JSP-hook from webapps, restarted the server, dropped the war file in deploy, saw the appropriate message about the hook being available, and the situation is the same. The contents of ROOT/html/portlets/login is unchanged.

Any other suggestions?
Postado em 16/04/09 04:35 em resposta a Peter B West.
Whats the server version(OS + liferay version)? Does you hook application have any portlet? Is the same hook app working on local machine?

If its not a big task, could you create a new hook application and copy all those changes you have to make and then use Netbeans "build" to build the war get the war and deploy it in server.
Postado em 16/04/09 05:07 em resposta a Peter B West.
I created a new hook application and tested it locally. It works. I then tried deploying it on the remote server. Again it didn't work.
Postado em 17/04/09 01:33 em resposta a Santh Chetan Chadalavada.
I'm running 5.2.2 on OpenSuSE locally. The remote system is
SUSE Linux Enterprise Server 10 (i586)
VERSION = 10
PATCHLEVEL = 2

I think the LifeRay version is 5.2.1.
Postado em 17/04/09 02:11 em resposta a Peter B West.
I want to create a auto-login hook. Is that possible using portal pack and net beans? Similar to the one here:

http://wikis.sun.com/display/websynergy/AutoLogin+Hook+for+OpenSSO+Agent?fo­cusedCommentId=92143831

Except I'll be using a different SSO.
Postado em 18/04/09 10:39 em resposta a Peter B West.
It is very much possible. Portal Pack provides you the basic infrastructure for your hook plugin.
Postado em 21/04/09 06:56 em resposta a Tony Lim.
I cannot create a Jsp Hook with the 3.0.2 plugin and NB 6.7

When I select a "normal" Tomcat as the runtime, I do get the dialog where I can select the hook type, but after selecting the JspHook I'm presented with a selection from my userhome(?) and the error message that this can only be used when the runtime is a Liferay Portal server.

So I created a Liferay Portal Server in the Servers tab pointing to my Tomcat directory. When I now select "New -> Other -> PortalHook" I get a very simply dialog that asks for the location of a .java file. I cannot select any Hook type.

What am I missing?
Postado em 14/07/09 03:08.
Hi Thomas, Hooks works fine with the 3.0.2 plugin and NB 6.7. You can use Hooks plugin only with Liferay Portal Server/ Wespace Server runtime i.e you need to add Liferay Portal Server which is pointing to a valid Liferay Home directory.

Once you do that. Create a new Web Project -> Right click on the project -> Other ->
WebSpace/Liferay Plugins -> Hook Plugin and then you should be able to see the hook wizard screen.

If anything goes wrong with the steps above then please check your Liferay installation.

Let us know if the issue is solved.
Postado em 14/07/09 11:16 em resposta a Thomas Kellerer.
Hi, I wanted to create a ModelListener, that fires, when there is a new order in the shop. So the code looks like this:
public void onAfterCreate(Object arg0) throws ModelListenerException {

com.liferay.portlet.shopping.model.ShoppingOrder mdlObj
= (com.liferay.portlet.shopping.model.ShoppingOrder) arg0;

}

But it returns error after the address input portlet:
java.lang.UnsupportedOperationException: Not supported yet.
at com.test.NewHookAction.onBeforeUpdate(NewHookAction.java:76)

Did I do anything wrong, ore is this really not yet supported?
Postado em 30/09/09 05:52.
Hi Dennis, which version of liferay and Netbeans Portal Pack are you using? http://portalpack.netbeans.org/pp30/download302.html Is the latest with some bug fixes.
Postado em 30/09/09 07:18 em resposta a Dennis Nes.
Anyone here who can send me the Plugins please emoticon
http://portalpack.netbeans.org/ is currently not available
I have installed my OS new and now i am missing the plugins :/

webaster {a} virtualizing.org
Postado em 04/11/09 20:04.
^^ ups webmaster {a} virtualizing.org ;)
Postado em 04/11/09 20:04 em resposta a Darko Joseph Hojnik.
http://blogs.sun.com/lukas/entry/page_not_found_at_netbeans
Postado em 04/11/09 21:41 em resposta a Darko Joseph Hojnik.
hi Chetan
let me thanks for ur good work
now kaam ki baat
i m inplementing websynergy
now for blog I need to have modrator i.e. blogs need to go
to administraator before it is available to all
how can we do it
please suggest
Postado em 08/06/10 05:03 em resposta a Santh Chetan Chadalavada.
Will the portal pack be updated to work with Liferay 6.0? Any idea of when? It's an indispensable tool, and currently the Eclipse IDE for Liferay 6 cannot edit Themes...
Postado em 03/08/10 14:57 em resposta a Santh Chetan Chadalavada.
Hi Marcelo,

You should probably ask Oracle directly, we don't have information about it.

Regarding editing of themes in Liferay IDE I think it's already been worked on and will be available soon.
Postado em 04/08/10 01:17 em resposta a Marcelo Ruiz Camauër.
Hello, thank you for the post. Just came across an introduction to creating Java applications with the NetBeans integrated development environment. It covers both using NetBeans with existing Java source code, and also using NetBeans to develop a Java program from scratch. Might be of great use for beginners. Regards!
Postado em 22/12/10 05:19.
[...] Liferay Hook Plugin Support , Netbeans Portal Pack 3.0.2 – Blog – Liferay.com [...] Read More
Postado em 04/09/14 01:33.