Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Dave Weitzel
adding custom methods in Hook environment
29 de marzo de 2011 9:24
Respuesta

Dave Weitzel

Ranking: Regular Member

Mensajes: 204

Fecha de incorporación: 18 de noviembre de 2009

Mensajes recientes

I am adding functionality to the calendar portlet using IDE and a hook project.
I am using Liferay In action a s a reference along with as many wiki and ofurm posts as possible!
I have written a new class in <my.custom package>.MyCalEvent.LocalServiceImpl which extends the CalEventLocalServiceWrapper
and in initially I just overrided the getEvent method to trace the event id

a) this only worked once I copied the class file from my portlet structure to the ROOT/WEB-INF/classes folder - how do we set up the system to detected it in the correct place?

I then added a new method that I want to use - at this stage I am not adding any new fields or anything so have no service builder elements.
(this is a skeleton of the real code I want to add here.)


public List<CalEvent> getMyEvents()
throws PortalException, SystemException {
System.out.println("## get MY events " );
int count = this.getCalEventsCount();
List<CalEvent> events = this.getCalEvents(0, count);
return events;
}


However when I try to access this in my jsp file
List myevents = MyCalEventLocalServiceImpl.getMyEvents();
I get the age old error:
"Cannot make a static reference to the non-static method getMyEvents() from the type MyCalEventLocalServiceImpl" which I sort of expected.

b) So what else do I have to do in order to call this method correctly?
Do I have to have a Wrapper class? Or a Util class? If so what do they look like?

Again this is not extending the data (that is next job) just adding new methods to existing service

Thanks
Andrés Cerezo
RE: adding custom methods in Hook environment
30 de mayo de 2011 15:09
Respuesta

Andrés Cerezo

Ranking: Junior Member

Mensajes: 92

Fecha de incorporación: 11 de noviembre de 2010

Mensajes recientes

Hello, I'm trying the same, can you send me the liferay-hook.xml ? I have problems!!
Puj Z
RE: adding custom methods in Hook environment
30 de mayo de 2011 23:43
Respuesta

Puj Z

Ranking: Regular Member

Mensajes: 220

Fecha de incorporación: 14 de enero de 2010

Mensajes recientes

why don't you simply make your method static?
Laxman Rana
RE: adding custom methods in Hook environment
16 de marzo de 2012 9:39
Respuesta

Laxman Rana

Ranking: Junior Member

Mensajes: 42

Fecha de incorporación: 29 de febrero de 2012

Mensajes recientes

@dave

have u done with u r problem...m facing the same prob.....i am getting undefined method error...
Joaquin Cabal
RE: adding custom methods in Hook environment
16 de marzo de 2012 12:09
Respuesta

Joaquin Cabal

Ranking: Junior Member

Mensajes: 54

Fecha de incorporación: 7 de septiembre de 2009

Mensajes recientes

Hi Dave,
I think that Liferay hook plugin only works for override existing methods, if you want to create a new method or functionality , you need to create an Ext plugin

The class that have the static methods is MyCalEvent.LocalServiceUtil, but sure not have your new method, because that class populates with service builder
Vilmos Papp
RE: adding custom methods in Hook environment
16 de marzo de 2012 13:51
Respuesta

Vilmos Papp

LIFERAY STAFF

Ranking: Liferay Master

Mensajes: 521

Fecha de incorporación: 21 de octubre de 2010

Mensajes recientes

The problem with this is that the method is not static, so you have 2 choices:

1.) Modify your method to be static
2.) Create an instance from your class and call that instance's method.

Anyway I would suggest you to check how the service/implementation layers are handled in the portal, what are the naming concepts and how to use the *LocalServiceUtil classes as from what you have written it's not really clear to me why do you extend the wrapper when you try to override the implementation.