Liferay Hook Plugin Support | Netbeans Portal Pack 3.0.2

 

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. 

 

Blogs
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?
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
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
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
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
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.
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
>>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.
Hmm. It's not there. On my local system, I do have login.jsp and login.portal.jsp. etc.

Peter
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
I'll see if I can get the server restarted later this evening.

Peter
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?
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.
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.
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.
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?focusedCommentId=92143831

Except I'll be using a different SSO.
It is very much possible. Portal Pack provides you the basic infrastructure for your hook plugin.
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...
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?
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.
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?
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.
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
^^ ups webmaster {a} virtualizing.org ;)
http://blogs.sun.com/lukas/entry/page_not_found_at_netbeans
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