Forums de discussion

include my own packages and classes

Christian Perez, modifié il y a 10 années.

include my own packages and classes

Junior Member Publications: 36 Date d'inscription: 01/07/13 Publications récentes
Hi I'm making a hook but I want to include my own packages with some classes but I don't know how to specify this classes to can use them in my custom jsps, what are the steps that I have to follow to include and use these classes in my hook any help is good.
I'm using liferay 6.1 with tomcat
thanks
--Chris--
thumbnail
Atin Agarwal, modifié il y a 10 années.

RE: include my own packages and classes

Junior Member Publications: 86 Date d'inscription: 20/02/12 Publications récentes
Firstly, whether you want to include action class or just any other plain java class??

If you want make a simple plain java class you can simply create it and use it in the same way as in other portlets. You can invoke them in your custom jsps also.
And if you want to include action class then you have to make a struts action, make an entry of this struts-action in liferay-hook.xml and call it by making portlet urls in your jsp.
Christian Perez, modifié il y a 10 années.

RE: include my own packages and classes

Junior Member Publications: 36 Date d'inscription: 01/07/13 Publications récentes
thanks, is only a simple java class with some methods, to connect with an external server with some dates,
thumbnail
Atin Agarwal, modifié il y a 10 années.

RE: include my own packages and classes

Junior Member Publications: 86 Date d'inscription: 20/02/12 Publications récentes
Ok, then you can use it in the same way as in any other portlets.

Regards,
Atin Agarwal
thumbnail
Ahmed Hasan, modifié il y a 10 années.

RE: include my own packages and classes

Expert Publications: 306 Date d'inscription: 13/04/07 Publications récentes
Hi Christian,

I am afraid, if you can create your own classes and packages inside your hook and try to access it from the custom_jsp, for the simple reason being, your new class will not be visible to the JSP that you a customising which runs at the PORTAL context and your hook is in a different context inside the tomcat. I would suggest two approaches here:

1) The best approach would be to put your new method with the JSP itself that you are customising through this hook, with the help of
<%! %>
scriplet. You have to write this method at the end of the JSP file.

2) The second approach is little lengthy but give you the flexibility of re-using the new API from any JSP that you are customising. You write a EXT plugin and in that you create the new packages and classes under "ext-service". Once the EXT plugin is deployed the new API will be visible both for the portal and all the other plugins, since it is at the tomcat lib level. Now you can invoke this new API from the JSP that you are customising.

Hope this answer help.

Yours truly,
Ahamed Hasan
Author, Liferay Portlet Cookbook
Christian Perez, modifié il y a 10 années.

RE: include my own packages and classes

Junior Member Publications: 36 Date d'inscription: 01/07/13 Publications récentes
Hi Ahamed
thanks for your reply I know what you mean about the contexts thats my problem originaly, I will try whit the <%! %> because y don't make the ext plugin, is so problematic, now I try the first approach I hope to work
thanks
--Chris--